You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Type validation missing in Table::Make allowing mismatched column types #45888
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 <arrow/api.h>
#include <iostream>
#include <vector>
int main() {
// Create string data but will mismatch with schema
std::vector<std::string> string_data = {"one", "two", "three"};
arrow::StringBuilder string_builder;
ARROW_RETURN_NOT_OK(string_builder.AppendValues(string_data));
std::shared_ptr<arrow::Array> string_array = string_builder.Finish().ValueOrDie();
auto string_chunked = std::make_shared<arrow::ChunkedArray>(string_array);
// Numeric data (correctly typed in schema)
std::vector<double> numeric_data = {1.0, 2.0, 3.0};
arrow::DoubleBuilder double_builder;
ARROW_RETURN_NOT_OK(double_builder.AppendValues(numeric_data));
std::shared_ptr<arrow::Array> double_array = double_builder.Finish().ValueOrDie();
auto double_chunked = std::make_shared<arrow::ChunkedArray>(double_array);
// Column vector with mismatched types
std::vector<std::shared_ptr<arrow::ChunkedArray>> 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;
}
Thanks for reporting this! I'm going through older bug issues to see if we can close them out.
Table::Make constructs the table without checking the columns against the schema; the check is Table::Validate() (or ValidateFull()), as suggested above. Running the program above against Arrow C++ 26.0.0 with those calls added:
table->Validate(): Invalid: Column data for field 0 with type string is inconsistent with schema double
table->ValidateFull(): Invalid: Column data for field 0 with type string is inconsistent with schema double
So calling Validate() after Table::Make on input that isn't trusted catches this case before the table is passed on (to Acero, for example).
Activity
kou commentedon Mar 22, 2025
Can we use
arrow::Table::Validate()orarrow::Table::ValidateFull()for the case?thisisnic commentedon Nov 26, 2026
Thanks for reporting this! I'm going through older bug issues to see if we can close them out.
Table::Makeconstructs the table without checking the columns against the schema; the check isTable::Validate()(orValidateFull()), as suggested above. Running the program above against Arrow C++ 26.0.0 with those calls added:So calling
Validate()afterTable::Makeon input that isn't trusted catches this case before the table is passed on (to Acero, for example).Closing as not a bug.