Repository navigation
feat(read): read identity partition columns from file scan tasks - #1068
Conversation
for the record: apache/iceberg#10835 this might be the most relevant discussion and per iceberg spec: partition source data columns might be always produced unless the data files are migrated from hive tables. However java's reference implementation prefers id constant from partition data. |
wgtmac
left a comment
There was a problem hiding this comment.
Sorry for the long delay! Do you want to revive this?
| EXPECT_EQ(parsed->spec()->spec_id(), 7); | ||
| ICEBERG_UNWRAP_OR_FAIL( | ||
| auto split, FileScanTask::MakeSplit(parsed->data_file(), 0, parsed->length(), {}, | ||
| nullptr, parsed->spec())); |
There was a problem hiding this comment.
Use a proper subrange and assert is_split(); this range is canonicalized to a whole-file task, so it does not cover spec propagation through the partial-split constructor.
There was a problem hiding this comment.
You're right,thx! Use [0, length - 1) and added ASSERT_TRUE(split->is_split())` before checking that the spec is preserved.
Yes, I'd like to continue with this PR. I've addressed all review comments and resolved conflicts,PTAL when you have time, thanks! |
Check partition tuple arity against the spec and use bounds-checked access when reading identity partition constants. Replace the throwing specs_by_id_.at() lookup in ManifestGroup with a checked find. Make the split test use a proper sub-range so the split constructor path is exercised.
Read the physical Avro or Parquet column when its native field ID is present, including when the stored value is null. For a missing ID, use the identity partition value before name mapping or the initial default. This keeps Parquet row-group pruning consistent with the values returned by the reader. Pass the file's writing spec to planner-generated splits. Reject a task whose spec ID conflicts with the data file, and preserve physical-column reads for tasks created without a spec. Share Arrow scalar conversion across both formats to handle unknown nulls and decimal precision promotion. Fix Avro field-ID detection for legacy files and publish the read context only after initialization succeeds. Keep partition handling in the format readers and restore the original schema-to-schema Project signature. Cover split planning, task serialization, partition evolution, and equality deletes on identity columns omitted from the output projection.
7e94460 to
2d73d2f
Compare
wgtmac
left a comment
There was a problem hiding this comment.
Thanks for improving this PR! To save another review round, I rebased the branch and pushed a follow-up directly. I narrowed the change to filling missing identity partition columns, so Avro and Parquet keep the stored value whenever the file has the field ID. That also lets us keep the existing Parquet pruning logic.
Preserve identity partition precedence from apache#1068 and apply the per-file name-mapping rules clarified in apache/iceberg#19037. Co-authored-by: Manu Zhang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <[email protected]>
Preserve identity partition precedence from apache#1068 and apply the per-file name-mapping rules clarified in apache/iceberg#19037. Co-authored-by: Manu Zhang <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Codex <[email protected]>
Data files imported from Hive may omit identity-partitioned source columns whose values are stored in the partition tuple. This PR carries each file’s writing spec through scan planning, JSON/REST tasks and splits, and supplies identity source constants to Parquet and Avro readers.
Reading behavior
id_to_constantmap keyed by source field ID, using the task’s own historicalPartitionSpec. Tasks constructed without a spec can still read physical columns. A supplied spec must match the file’s spec ID when present.Projectentry points and select them during recursive field projection, including primitive leaves of existing structs. Both formats use the projected Arrow type for nulls and for promotions such as decimal precision widening.Scope
Identity source columns only: bucket and other transforms do not reconstruct source values.
_partition,_spec_idand_fileare not added to this constant map. Nested/struct constant values and reconstruction of an entirely absent parent struct are outside this change. JSON tasks must retain the historical source-type information needed to decode partition values.The reader flow follows Java’s
PartitionUtil.constantsMap,GenericReaderand recursive Parquet reader construction. Feedback on spec ownership and the constant-map interface is welcome.Validation
Rebased onto
60447e78c. All 26 local CTest suites and pre-commit passed for2d73d2f4b.Earlier validation
Merged upstream
mainat748162b3and resolved the task-reader and Parquet-reader conflicts. After restoring the original metrics filter interface, rebuilt and passeddata_test(200) andparquet_test(193), plus pre-commit and clang-tidy 22.1.8 on the changed reader and metrics filter. Earlier validation also passedschema_test(566) andavro_test(255).For local Apple-toolchain testing only, an existing upstream
std::ranges::iotacall was temporarily replaced with equivalentstd::iota; the source was restored and that workaround is not committed. Clang-tidy 22.1.8 found two diagnostics in the external AvroGenericDatum.hh; both were reproduced against unmodified upstreamavro_data_util.cc.