diff --git a/cpp/src/arrow/table.cc b/cpp/src/arrow/table.cc
index 967e78f6b4db1..5dc5e4c1a9a8c 100644
--- a/cpp/src/arrow/table.cc
+++ b/cpp/src/arrow/table.cc
@@ -619,6 +619,7 @@ TableBatchReader::TableBatchReader(const Table& table)
for (int i = 0; i < table.num_columns(); ++i) {
column_data_[i] = table.column(i).get();
}
+ DCHECK(table_.Validate().ok());
}
TableBatchReader::TableBatchReader(std::shared_ptr
table)
@@ -632,6 +633,7 @@ TableBatchReader::TableBatchReader(std::shared_ptr table)
for (int i = 0; i < owned_table_->num_columns(); ++i) {
column_data_[i] = owned_table_->column(i).get();
}
+ DCHECK(table_.Validate().ok());
}
std::shared_ptr TableBatchReader::schema() const { return table_.schema(); }
diff --git a/cpp/src/arrow/table.h b/cpp/src/arrow/table.h
index a7508430c132b..79675fa92b1f3 100644
--- a/cpp/src/arrow/table.h
+++ b/cpp/src/arrow/table.h
@@ -241,6 +241,8 @@ class ARROW_EXPORT Table {
///
/// The conversion is zero-copy: each record batch is a view over a slice
/// of the table's columns.
+///
+/// The table is expected to be valid prior to using it with the batch reader.
class ARROW_EXPORT TableBatchReader : public RecordBatchReader {
public:
/// \brief Construct a TableBatchReader for the given table
diff --git a/cpp/src/parquet/arrow/reader.cc b/cpp/src/parquet/arrow/reader.cc
index d6ad7c25bc7c1..285e2a597389d 100644
--- a/cpp/src/parquet/arrow/reader.cc
+++ b/cpp/src/parquet/arrow/reader.cc
@@ -1043,6 +1043,16 @@ Status FileReaderImpl::GetRecordBatchReader(const std::vector& row_groups,
}
}
+ // Check all columns has same row-size
+ if (!columns.empty()) {
+ int64_t row_size = columns[0]->length();
+ for (size_t i = 1; i < columns.size(); ++i) {
+ if (columns[i]->length() != row_size) {
+ return ::arrow::Status::Invalid("columns do not have the same size");
+ }
+ }
+ }
+
auto table = ::arrow::Table::Make(batch_schema, std::move(columns));
auto table_reader = std::make_shared<::arrow::TableBatchReader>(*table);