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
native_datafusion: BINARY column without DecimalLogicalTypeAnnotation should be rejected when read as DECIMAL #4351
When a Parquet column is plain BINARY (no DecimalLogicalTypeAnnotation), Spark's vectorized reader rejects reading it as a DecimalType via ParquetVectorUpdaterFactory.getUpdater's BINARY case (lines 199-205): canReadAsDecimal and canReadAsBinaryDecimal both require the column to have a DecimalLogicalTypeAnnotation. Without the annotation, Spark falls through and throws SchemaColumnConvertNotSupportedException.
native_datafusion's schema_adapter.rs currently allows this conversion silently. The first rejection block (lines 599-619) lists Decimal128(_, _) | Decimal256(_, _) in the allowed targets, intending to permit a "binary-encoded decimal", but Arrow already exposes a Parquet BINARY column with DecimalLogicalTypeAnnotation as DataType::Decimal128, never as DataType::Binary. So when physical_type == Binary is observed in the adapter, the source is unambiguously a non-decimal BINARY column.
When the cast falls through, DataFusion can't actually cast Binary to Decimal128; the column reaches Arrow's RecordBatch::try_new validation and fails with:
Invalid argument error: column types must match schema types, expected Decimal128(37, 1) but found Binary at column index 0
surfaced to the JVM as CometNativeException instead of the Spark-equivalent SchemaColumnConvertNotSupportedException.
Reproducer
SPARK-34212 Parquet should read decimals correctly in ParquetQuerySuite (Spark 4.1.x):
The d DECIMAL(37, 1) iteration fails because native_datafusion doesn't reject the BINARY → DECIMAL read.
Fix
Drop DataType::Decimal128(_, _) | DataType::Decimal256(_, _) from the allowed-targets match at native/core/src/parquet/schema_adapter.rs:608-609. Add a regression test in the parquet_string_read_as_int_errors style.
Activity
fix: reject BINARY-as-DECIMAL, re-ignore parquet-mr permissive tests (a…
test: regression guard for BINARY -> DECIMAL rejection (apache#4351)
test: drop apache#3720 references from spark diffs in favor of specif…