-
Notifications
You must be signed in to change notification settings - Fork 4.8k
HIVE-29341:Iceberg: [V3] NULL initial default for STRUCT column #6565
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
Changes from all commits
40da855
2646e4e
9426be3
59bb37c
34aff7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -53,6 +53,7 @@ | |
| import org.apache.iceberg.data.parquet.GenericParquetReaders; | ||
| import org.apache.iceberg.encryption.EncryptedFiles; | ||
| import org.apache.iceberg.expressions.Expression; | ||
| import org.apache.iceberg.hive.HiveSchemaUtil; | ||
| import org.apache.iceberg.io.CloseableIterable; | ||
| import org.apache.iceberg.io.CloseableIterator; | ||
| import org.apache.iceberg.io.InputFile; | ||
|
|
@@ -63,6 +64,7 @@ | |
| import org.apache.iceberg.orc.ORC; | ||
| import org.apache.iceberg.parquet.Parquet; | ||
| import org.apache.iceberg.relocated.com.google.common.base.Preconditions; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Maps; | ||
| import org.apache.iceberg.types.Type; | ||
| import org.apache.iceberg.types.TypeUtil; | ||
| import org.apache.iceberg.types.Types; | ||
|
|
@@ -173,7 +175,29 @@ private CloseableIterable openGeneric(FileScanTask task, Schema readSchema) { | |
| default -> throw new UnsupportedOperationException( | ||
| String.format("Cannot read %s file: %s", file.format().name(), file.location())); | ||
| }; | ||
| return applyResidualFiltering(iterable, residual, readSchema); | ||
| return applyResidualFiltering(withStructInitialDefaultsBackfill(iterable, readSchema), residual, readSchema); | ||
| } | ||
|
|
||
| private CloseableIterable<T> withStructInitialDefaultsBackfill(CloseableIterable<T> iterable, Schema readSchema) { | ||
| Map<String, Record> initialDefaultStructsByColumn = Maps.newHashMap(); | ||
| for (Types.NestedField column : readSchema.columns()) { | ||
| if (column.type().isStructType()) { | ||
| Record initialDefaultStruct = HiveSchemaUtil | ||
| .buildStructFromDefaults(column.type().asStructType(), Types.NestedField::initialDefault); | ||
| if (initialDefaultStruct != null) { | ||
| initialDefaultStructsByColumn.put(column.name(), initialDefaultStruct); | ||
| } | ||
| } | ||
| } | ||
| if (initialDefaultStructsByColumn.isEmpty()) { | ||
| return iterable; | ||
| } | ||
| return CloseableIterable.transform(iterable, row -> { | ||
|
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. The
Contributor
Author
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. my bad, optimized it to build default struct only once and then set the field of the row record for that particular field |
||
| if (row instanceof Record curIceRecord) { | ||
| HiveSchemaUtil.backfillStructInitialDefaults(curIceRecord, initialDefaultStructsByColumn); | ||
| } | ||
| return row; | ||
| }); | ||
| } | ||
|
|
||
| private CloseableIterable<T> newAvroIterable( | ||
|
|
||
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.
same #6565 (comment)