mirror of
https://github.com/apache/arrow.git
synced 2026-10-29 09:05:47 +08:00
Check size of target
This commit is contained in:
1 parent
8b472da8a4
commit
386e5bc953
2 files changed
+12
No files matched your search
@@ -175,6 +175,10 @@ TEST(TestTupleVectorFromTable, PrimitiveTypes) {
|
||||
ASSERT_OK(TupleRangeFromTable(*table, cast_options, &ctx, &rows));
|
||||
ASSERT_EQ(rows, expected_rows);
|
||||
|
||||
// The number of rows must match
|
||||
std::vector<primitive_types_tuple> too_few_rows(1);
|
||||
ASSERT_RAISES(Invalid, TupleRangeFromTable(*table, cast_options, &ctx, &too_few_rows));
|
||||
|
||||
// The number of columns must match
|
||||
std::shared_ptr<Table> corrupt_table;
|
||||
ASSERT_OK(table->RemoveColumn(0, &corrupt_table));
|
||||
|
||||
@@ -346,6 +346,14 @@ Status TupleRangeFromTable(const Table& table, const compute::CastOptions& cast_
|
||||
return Status::Invalid(ss.str());
|
||||
}
|
||||
|
||||
// TODO: Use std::size with C++17
|
||||
if (rows->size() != table.num_rows()) {
|
||||
std::stringstream ss;
|
||||
ss << "Number of rows in the table does not match the size of the target: ";
|
||||
ss << table.num_rows() << " != " << rows->size();
|
||||
return Status::Invalid(ss.str());
|
||||
}
|
||||
|
||||
// Check that all columns have the correct type, otherwise cast them.
|
||||
std::shared_ptr<Table> table_owner;
|
||||
std::reference_wrapper<const ::arrow::Table> current_table(table);
|
||||
|
||||
Reference in new issue
Block a user