Repository navigation
feat: apply write defaults in Parquet and Avro writers #942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
huan233usc
wants to merge
13
commits into
apache:main
Choose a base branch
from
huan233usc:feat/write-default-e2e
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+759
−16
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
c6e1875
✨ feat(schema): Add write-default and strict projection options
huan233usc 1769080
✨ feat(arrow): Align batches to write schemas
huan233usc 8e01c0e
✨ feat(data): Apply write defaults in writers
huan233usc 744fdd8
🐛 fix(data): Harden write schema alignment
huan233usc 2e5c330
♻️ refactor(data): Centralize schema alignment
huan233usc 23d3a06
🐛 fix(arrow): Correct write alignment DLL export
huan233usc f202b30
♻️ refactor(data): Drop unrelated schema check
huan233usc 02ca050
♻️ refactor(data): Narrow write alignment scope
huan233usc e53ce78
✅ test(data): Trim duplicate alignment coverage
huan233usc 824f03b
♻️ refactor(arrow): Internalize alignment pool
huan233usc 669aa21
♻️ refactor(writer): Skip redundant alignment
huan233usc d5cf171
♻️ refactor(test): Parameterize write alignment
huan233usc fed2dd2
🐛 fix(writer): Address review feedback
huan233usc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,6 +31,7 @@ | |
| #include <vector> | ||
|
|
||
| #include "iceberg/arrow_c_data.h" | ||
| #include "iceberg/iceberg_bundle_export.h" | ||
| #include "iceberg/iceberg_export.h" | ||
| #include "iceberg/result.h" | ||
| #include "iceberg/type_fwd.h" | ||
|
|
@@ -242,4 +243,20 @@ ICEBERG_EXPORT Result<ArrowArray> ProjectBatch(ArrowArray* input_batch, | |
| std::span<const int32_t> row_indices, | ||
| ProjectionContext& projection); | ||
|
|
||
| namespace arrow { | ||
|
|
||
| /// \brief Align an Arrow batch to an Iceberg write schema. | ||
| /// | ||
| /// Fields are matched by Iceberg field id. Missing fields are materialized from their | ||
| /// `write-default`, or as null when optional. Missing required fields without a | ||
| /// `write-default` are rejected. Existing values, including explicit nulls, are | ||
| /// preserved. Structs, lists, and maps are aligned recursively. | ||
| /// | ||
| /// `input_batch` is consumed even when alignment fails. | ||
| ICEBERG_BUNDLE_EXPORT Result<ArrowArray> AlignBatchForWrite(ArrowArray* input_batch, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we remove |
||
| const Schema& input_schema, | ||
| const Schema& write_schema); | ||
|
|
||
| } // namespace arrow | ||
|
|
||
| } // namespace iceberg | ||
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In write mode, Project still turns a concrete input into null when the target type is unknown, before reaching the type check. An optional int containing 123 is therefore silently written as null. Reject concrete-to-unknown writes and add the reverse of the unknown-input test.