-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Spark: Add _row_id and _last_updated_sequence_number readers #12836
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
Conversation
35b8714 to
4f984c5
Compare
parquet/src/main/java/org/apache/iceberg/parquet/ParquetValueReaders.java
Outdated
Show resolved
Hide resolved
| ParquetValueReader<?> reader = | ||
| ParquetValueReaders.replaceWithMetadataReader( | ||
| id, readersById.get(id), idToConstant, constantDefinitionLevel); | ||
| reorderedFields.add(defaultReader(field, reader, constantDefinitionLevel)); |
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.
The changes here were needed to reduce the complexity of the struct method that was failing checkstyle. I refactored into 2 components:
ParquetValueReaders.replaceWithMetadataReaderhandles metadata columns and constantsdefaultReaderhandles defaults based on the schema; this requiresconvertConstantso it is not shared inParquetValueReaders
I also simplified the constant handling that was introduced in #4627. That PR introduced a map with the max definition level for columns that are replaced with constants and defaults the definition level to the parent struct's value when there is no underlying column (for instance, _pos). This was over-complicated because the fields don't need a column-specific DL. If the parent struct is non-null then the constant should be added to it, so the DL can always be the parent's DL.
| public static ParquetValueReader<Long> lastUpdated( | ||
| Long baseRowId, Long fileLastUpdated, ParquetValueReader<?> seqReader) { | ||
| if (fileLastUpdated != null && baseRowId != null) { | ||
| return new LastUpdatedSeqReader(fileLastUpdated, (ParquetValueReader<Long>) seqReader); |
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.
baseRowId is used to detect non-v3 snapshots. It is required for v3 snapshots so when it is missing, the values should be null. That's required by the spec update in #12781.
0dc3d17 to
a18b51f
Compare
parquet/src/main/java/org/apache/iceberg/parquet/ParquetValueReaders.java
Show resolved
Hide resolved
| } | ||
|
|
||
| ConstantReader(C constantValue, int definitionLevel) { | ||
| ConstantReader(C constantValue, int parentDl) { |
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.
Nit: I'd probably use the full form "parentDefinitionLevel"
|
Thanks @rdblue ! |
This adds readers for
_row_idand_last_updated_sequence_numberin Spark and the generic data model.