Repository navigation
Do not infer Nullable(Tuple) in Arrow, ArrowStream, ORC, Parquet and Avro schema inference unless the type is enabled - #109185
Conversation
…uet unless enabled
|
Workflow [PR], commit [25ba1dc] Summary: ✅
AI ReviewSummaryThis PR fixes the Findings❌ Blockers
Final Verdict
|
…_tuple_type in schema cache info
… in the Arrow readers
… schema inference cache key
| arrow_column->type()->id() != arrow::Type::LARGE_LIST && | ||
| arrow_column->type()->id() != arrow::Type::FIXED_SIZE_LIST && | ||
| arrow_column->type()->id() != arrow::Type::MAP && | ||
| (arrow_column->type()->id() != arrow::Type::STRUCT || allow_nullable_struct) && |
There was a problem hiding this comment.
This fallback still loses the parent STRUCT null map. When allow_experimental_nullable_tuple_type = 0, nullable structs skip the outer Nullable(Tuple) wrapper here and fall through to the plain Tuple path, but the STRUCT reader below only re-reads struct_chunk.field(i) for each child and never merges the parent struct null bitmap into those children. For Arrow, that means a row where the whole struct is NULL keeps the child values stored underneath instead of becoming null/default elements. The new 04493 reference already shows it: the default Arrow read returns (10, 'x') for a row whose s value in the file was NULL. So CREATE TABLE ... AS file(..., 'Arrow') now succeeds by silently materializing wrong data instead of preserving the null semantics.
If we need to fall back from Nullable(Tuple) to Tuple, please still read the outer nullable struct and then propagate its null map into the tuple elements before returning it, e.g. with the same Nested::unwrapNullableTuple pattern already used for Nested array elements.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 87/89 (97.75%) · Uncovered code |
|
@nihalzp Can be merged? |
…d Avro schema inference unless the type is enabled Cherry-pick of #109185 to 26.5. Without `allow_experimental_nullable_tuple_type`, schema inference for Arrow, ArrowStream, ORC, Parquet, and Avro formats must not infer `Nullable(Tuple)` for nullable struct/record columns, because `CREATE TABLE` rejects that type by default. Instead, the struct null map is propagated into the tuple elements as it worked before `Nullable(Tuple)` was supported. Also adds `schema_inference_allow_nullable_tuple_type` to the schema inference cache keys for all row-based formats, Arrow, ArrowStream, ORC, and Avro/AvroConfluent.
…rowStream, ORC, Parquet and Avro schema inference unless the type is enabled
Backport #109185 to 26.6: Do not infer `Nullable(Tuple)` in Arrow, ArrowStream, ORC, Parquet and Avro schema inference unless the type is enabled
Cherry pick #109185 to 26.5: Do not infer `Nullable(Tuple)` in Arrow, ArrowStream, ORC, Parquet and Avro schema inference unless the type is enabled
…rowStream, ORC, Parquet and Avro schema inference unless the type is enabled
…e + PR changes Replace all files changed by PR #109185 with 26.4-compatible versions by applying only the PR-specific changes to the 26.4 base, instead of using the master versions that caused merge conflicts. Changes made: - EscapingRuleUtils.cpp: add schema_inference_allow_nullable_tuple_type to format string - ArrowBlockInputFormat.cpp: add schema_inference_allow_nullable_tuple_type to both Arrow/ArrowStream cache getters - ArrowColumnToCHColumn.cpp: add allow_nullable_struct guard for STRUCT type - AvroRowInputFormat.cpp: add allow_nullable_tuple_type parameter to avroNodeToDataTypeImpl, add cache getter - AvroRowInputFormat.h: update avroNodeToDataType/avroNodeToDataTypeImpl signatures - ORCBlockInputFormat.cpp: add schema_inference_allow_nullable_tuple_type, use_fast_decoder, dictionary_as_low_cardinality to ORC cache getter - 03212/03526/03627 reference files: add schema_inference_allow_nullable_tuple_type=false to cache key strings - Remove 04262_skip_first_lines_with_names_schema_cache.{reference,sh} (not in 26.4 base, only modified by PR not created)
Cherry pick #109185 to 26.4: Do not infer `Nullable(Tuple)` in Arrow, ArrowStream, ORC, Parquet and Avro schema inference unless the type is enabled
…rowStream, ORC, Parquet and Avro schema inference unless the type is enabled
Backport #109185 to 26.5: Do not infer `Nullable(Tuple)` in Arrow, ArrowStream, ORC, Parquet and Avro schema inference unless the type is enabled
Backport #109185 to 26.4: Do not infer `Nullable(Tuple)` in Arrow, ArrowStream, ORC, Parquet and Avro schema inference unless the type is enabled
…schema-inference Do not infer `Nullable(Tuple)` in Arrow, ArrowStream, ORC, Parquet and Avro schema inference unless the type is enabled
Related: #101272
Since #101272 (26.4), schema inference in the Arrow-based readers returns
Nullable(Tuple(...))for optional (nullable) struct columns. TheNullable(Tuple)type is gated byallow_experimental_nullable_tuple_type(disabled by default), andvalidateDataTyperejects it when creating columns. As a result, under default settingsDESCRIBE s3(...)succeeds whileCREATE TABLE ... AS s3(...)orINSERT ... SELECTfrom the inferred schema fails:The affected readers are
Arrow,ArrowStream,ORCwithinput_format_orc_use_fast_decoder = 0, and the legacy Arrow-basedParquetreader (used wheninput_format_parquet_use_native_reader_v3 = 0; removed in 26.5). The native Parquet v3 and native ORC readers were never affected.cc: @fm4v
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix schema inference for the
Arrow,ArrowStream,Avroformats and the legacyORCandParquetreaders returningNullable(Tuple)for nullable struct columns while theNullable(Tuple)type is not allowed (allow_experimental_nullable_tuple_typeis disabled).DESCRIBEreturned a type thatCREATE TABLErejects, so creating a table or inserting data using the inferred schema failed with the errorNullable Tuple type is not allowed.Version info
26.7.1.549(included in26.7and later)26.6.2.34,26.5.6.27,26.4.5.114