Spark: Add _row_id and _last_updated_sequence_number readers#12836
Spark: Add _row_id and _last_updated_sequence_number readers#12836amogh-jahagirdar merged 11 commits intoapache:mainfrom
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.
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.
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.
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.