Skip to content

HIVE-29857: Iceberg: Fix ROW__POSITION on vectorized VARIANT reads - #6743

Open
deniskuzZ wants to merge 2 commits into
apache:masterfrom
deniskuzZ:variant-rowpos-fix
Open

HIVE-29857: Iceberg: Fix ROW__POSITION on vectorized VARIANT reads#6743
deniskuzZ wants to merge 2 commits into
apache:masterfrom
deniskuzZ:variant-rowpos-fix

Conversation

@deniskuzZ

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

  • A VARIANT table's reader is wrapped in ParquetVariantRecordReader, which declared only RecordReader, so the test failed and rowOffset kept the marker that stands for an unknown position. Let the wrapper carry the interface and answer from the reader it wraps.

Why are the changes needed?

Fix ROW__POSITION on vectorized VARIANT reads

Does this PR introduce any user-facing change?

How was this patch tested?

variant_type_row_position.q

ROW__POSITION came back as Long.MIN_VALUE for every VARIANT table read
vectorized, and row lineage and positional deletes read the same value.

HiveBatchIterator takes the position of a batch from the record reader, but only
when the reader is a RowPositionAwareVectorizedRecordReader:

    if (batch.size != 0 && recordReader instanceof RowPositionAwareVectorizedRecordReader) {
      rowOffset = ((RowPositionAwareVectorizedRecordReader) recordReader).getRowNumber();
    }

A VARIANT table's reader is wrapped in ParquetVariantRecordReader, which declared
only RecordReader, so the test failed and rowOffset kept the marker that stands
for an unknown position. Let the wrapper carry the interface and answer from the
reader it wraps, and let it fail rather than hand back the marker.

That uncovered a second fault underneath. Variant row group pruning handed the
reader a footer holding only the row groups that survived, and the reader counted
row positions by walking that footer and summing row counts. A position is
absolute within the file, so counting it over a footer that is missing row groups
placed every row group after a pruned one too low - the first row of the second
row group reported position 0 rather than 200. The same footer also fed the scan
statistics, which under reported the rows and bytes a variant scan covers.

The reader now keeps the file's own footer and is told separately which row groups
to read, as ORC's readers are. Parquet records where each row group's first row
sits in the file, so the position is read from the footer rather than counted up,
and stays right whatever subset of row groups a split reads.

VariantParquetFilters.pickRowGroups already returned that decision as a boolean
per row group for the non-vectorized reader; the vectorized path now takes the
same answer instead of a pruned footer, so pruneVariantRowGroups has no caller
left and is removed.

variant_type_row_position.q prunes an early row group and checks that the
surviving rows keep the positions they were written at. Without the first fix the
positions are the unknown marker, without the second they are short by the pruned
row group's row count.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants