Skip to content

Conversation

@wypoon
Copy link
Contributor

@wypoon wypoon commented Apr 26, 2024

This builds on #10107.
It borrows and adapts code and the test TestSparkParquetPageSkipping from @zhongyujiang's #6967.
The difference in approach here is that we do not make use of any Parquet internal API. We simply convert the Iceberg filter to a Parquet filter and use ParquetFileReader#readFilteredRowGroup(int) and PageReadStore#getRowIndexes().
We borrow and adapt the code from #6967 for synchronizing the column readers (as each column might have different number of pages and so the columns might be at different row indexes when a filtered row group is read).
There are some limitations:
In this PR, we only implement the page skipping for the non-vectorized read path. We plan to work on the vectorized read path separately. In TestSparkParquetPageSkipping, we test both vectorized and non-vectorized reads and there one can see the difference in the rows that are read (as page skipping is not implemented for the vectorized path).
Due to the fact that before it performs the filtering, Parquet validates that the column type in predicates in the filter match the type of the column in the Parquet file, we have to skip using Parquet filtering in some cases, e.g., when a column is an INT96 timestamp.
Currently, ParquetFilters.ConvertFilterToParquet handles only a small set of operators, so e.g., a filter with IN does not get converted. This can be improved independently.

- When converting an Iceberg filter to a Parquet filter, and then using
the converted filter in Parquet to filter row groups, Parquet checks that
the type of a column in a filter predicate matches the type in the Parquet
file as a validation step before applying the filter. This validation fails
for some cases, e.g., INT96 timestamp columns. When doing the conversion,
we thus need to check that such a type mismatch does not occur and fail
the conversion if it does.
- When converting the Iceberg filter to a Parquet filter fails, we need
to handle the failure, and in ReadConf, we need to use the internally
computed total number of rows instead of the values returned by the
ParquetFileReader's getFilteredRecordCount().
- In ParquetReader.FileIterator, since we have to handle both cases where
a Parquet record filter is used and where it is not, we avoid the
skipNextRowGroup() and readNextFilteredRowGroup() methods of ParquetFileReader
and instead proceed row group by row group and call readFilteredRowGroup(int)
with the index of the row group.
@wypoon wypoon force-pushed the parquet_filtered_row_groups branch from 147ac9e to fa0bd05 Compare May 1, 2024 22:36
@wypoon wypoon changed the title [draft] Parquet page skipping (using filtered row groups) Parquet: page skipping using filtered row groups for non-vectorized read May 1, 2024
@wypoon
Copy link
Contributor Author

wypoon commented May 2, 2024

@zhongyujiang I would be happy to make you a co-author, but it was not easy to pull in commits from your PR directly. If you like, you can open a PR against my branch (even a dummy commit) and I can merge it and have you show up as a co-author.
@rdblue @aokolnychyi @flyrain please take a look.

@wypoon
Copy link
Contributor Author

wypoon commented May 2, 2024

@sunchao @chenjunjiedada you may be interested in this.

@github-actions
Copy link

github-actions bot commented Nov 1, 2024

This pull request has been marked as stale due to 30 days of inactivity. It will be closed in 1 week if no further activity occurs. If you think that’s incorrect or this pull request requires a review, please simply write any comment. If closed, you can revive the PR at any time and @mention a reviewer or discuss it on the [email protected] list. Thank you for your contributions.

@github-actions github-actions bot added the stale label Nov 1, 2024
@github-actions
Copy link

github-actions bot commented Nov 9, 2024

This pull request has been closed due to lack of activity. This is not a judgement on the merit of the PR in any way. It is just a way of keeping the PR queue manageable. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

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