feat(parquet): apply column default values when reading missing fields (2/4)#792
Open
huan233usc wants to merge 1 commit into
Open
feat(parquet): apply column default values when reading missing fields (2/4)#792huan233usc wants to merge 1 commit into
huan233usc wants to merge 1 commit into
Conversation
925d8cd to
378150c
Compare
…s (2/4) When a column is present in the read schema but missing from a Parquet data file (written before the column existed), fill it with the column's v3 initial-default instead of null. Adds a shared Arrow materializer (arrow/literal_util) that turns a Literal into an Arrow scalar/array, and a kDefault projection branch in the Parquet schema/data projection paths. The materializer wraps the storage array in the extension type for extension types such as `arrow.uuid` (compute::Cast has no storage->extension kernel). Part 2 of the v3 column-default-values work (POC apache#731), built on the schema support merged in apache#746.
6b08bed to
8db3067
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Part 2 of 4 of Iceberg v3 column default-value support (POC #731), built on the
schema-layer support merged in #746.
When a column is present in the read (table) schema but absent from a Parquet
data file — because the column was added after those rows were written — fill it
with the column's v3
initial-defaultinstead ofnull.Changes
arrow/literal_util(new): a shared Arrow materializer that converts aLiteralto an Arrow scalar (ToArrowScalar), to a constant-filled array(
MakeDefaultArray), or appends it once to a builder(
AppendDefaultToBuilder). Covers all primitive types, includingdecimal/uuid/fixed and the four timestamp variants.
parquet_schema_util.cc): when a field is missingfrom the file and carries an
initial-default, project it asFieldProjection::Kind::kDefault, mirroring the genericschema_util.ccpathalready merged in feat(schema): represent, serialize and validate v3 column default values (1/4) #746.
parquet_data_util.cc): materialize thekDefaultbranchvia
MakeDefaultArray.Tests
literal_util_test: scalar/array/builder conversion across primitive types,null and narrowing-sentinel handling, and casting to the target Arrow type.
parquet_data_test:ProjectRecordBatchfills missing required and optionaldefault fields, including a nested struct.
parquet_test: end-to-end — write a file with an old schema, then read itthrough
ReaderFactoryRegistrywith an evolved schema carrying defaults(
ReadMissingFieldsWithDefaults).Stack
addColumn/updateColumnDefault(follows)