Type validation missing in Table::Make allowing mismatched column types
- Dominant language
- C++
- Stars
- 17.1k
- Forks
- 4.3k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 88
Description
### Describe the bug, including details regarding any error messages, version, and platform.
Description
Table::Make does not validate that the data types in the schema match the actual data types of the provided columns. This allows tables to be created with mismatched types, leading to potential crashes, data corruption, or undefined behavior when later accessing the data.
SIGABT from using acero with this tab
Steps to reproduce
```
#include
#include
#include
int main() {
// Create string data but will mismatch with schema
std::vector string_data = {"one", "two", "three"};
arrow::StringBuilder string_builder;
ARROW_RETURN_NOT_OK(string_builder.AppendValues(string_data));
std::shared_ptr string_array = string_builder.Finish().ValueOrDie();
auto string_chunked = std::make_shared(string_array);
// Numeric data (correctly typed in schema)
std::vector numeric_data = {1.0, 2.0, 3.0};
arrow::DoubleBuilder double_builder;
ARROW_RETURN_NOT_OK(double_builder.AppendValues(numeric_data));
std::shared_ptr double_array = double_builder.Finish().ValueOrDie();
auto double_chunked = std::make_shared(double_array);
// Column vector with mismatched types
std::vector> columns = {string_chunked, double_chunked};
// Schema incorrectly claims first column is double
auto incorrect_schema = arrow::schema({
arrow::field("column1", arrow::float64()), // Wrong! This is actually string data
arrow::field("column2", arrow::float64()) // This is correct
});
// No validation error is raised!
auto table = arrow::Table::Make(incorrect_schema, columns);
// Trying to access will likely cause corrupt data or crashes
std::cout << "Table created with incorrect types: " << table->ToString() << std::endl;
std::cout << "First column data: " << table->column(0)->ToString() << std::endl;
return 0;
}
```
### Component(s)
C++
Contributor guide
Assessment
This issue has not been assessed yet.