-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Prune unused stats columns when reading Delta checkpoint #19848
Prune unused stats columns when reading Delta checkpoint #19848
Conversation
a934893
to
cd7a3a3
Compare
@@ -600,10 +699,14 @@ private CheckpointEntryIterator createCheckpointEntryIterator( | |||
metadataEntry, | |||
protocolEntry, | |||
new FileFormatDataSourceStats(), | |||
new ParquetReaderConfig().toParquetReaderOptions(), | |||
new ParquetReaderConfig() | |||
.setMaxBufferSize(DataSize.ofBytes(500)) |
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.
These changes were necessary to be able to showcase the effectiveness of the stats_parsed
projection functionality.
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.
Thank you for adding this!
I mostly have nitpicks for you :)
We could perhaps just pass the underlying set for addStatsColumnFilter
around, instead of a function. Then it could be renamed projectedColumns
. Maybe we could even pass the projectedColumns
to the CheckpointEntryIterator
. That would set us up for supporting statistics projection of non-base columns in the future.
Perhaps unrelated to this PR, but it might be good to have a test case which tests performance of checkpoint reads from tables with a very wide schema (e.g., internally we have a table with 276 columns).
...n/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/TableSnapshot.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/trino/plugin/deltalake/transactionlog/checkpoint/CheckpointEntryIterator.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/trino/plugin/deltalake/transactionlog/checkpoint/CheckpointSchemaManager.java
Outdated
Show resolved
Hide resolved
...st/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointEntryIterator.java
Outdated
Show resolved
Hide resolved
...st/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointEntryIterator.java
Outdated
Show resolved
Hide resolved
...st/java/io/trino/plugin/deltalake/transactionlog/checkpoint/TestCheckpointEntryIterator.java
Outdated
Show resolved
Hide resolved
...-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/TransactionLogAccess.java
Outdated
Show resolved
Hide resolved
cd7a3a3
to
ac0d251
Compare
My initial version of the code contained See in
It seems weird to pass |
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeMetadata.java
Outdated
Show resolved
Hide resolved
plugin/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/DeltaLakeSplitManager.java
Outdated
Show resolved
Hide resolved
...ake/src/main/java/io/trino/plugin/deltalake/statistics/FileBasedTableStatisticsProvider.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/trino/plugin/deltalake/transactionlog/checkpoint/CheckpointSchemaManager.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/trino/plugin/deltalake/transactionlog/checkpoint/CheckpointEntryIterator.java
Outdated
Show resolved
Hide resolved
if (projectedColumns.isPresent()) { | ||
Set<String> baseColumnNames = projectedColumns.get().stream() | ||
.filter(DeltaLakeColumnHandle::isBaseColumn) // Only base column stats are supported | ||
.map(DeltaLakeColumnHandle::getColumnName) |
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.
Normalized (lowercased) or not?
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.
We are using here the original column names - e.g a_NuMbEr
instead of a_number
.
See corresponding test io.trino.plugin.deltalake.TestDeltaLakeBasic#testCheckpointFilteringForParsedStatsWithCaseSensitiveColumnNames
and test resource: databricks133/parsed_stats_case_sensitive/_delta_log/00000000000000000002.checkpoint.parquet
optional group stats_parsed {
optional int64 numRecords;
optional group minValues {
optional int32 a_NuMbEr;
optional binary a_StRiNg (STRING);
}
...-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/TransactionLogAccess.java
Show resolved
Hide resolved
...n/trino-delta-lake/src/main/java/io/trino/plugin/deltalake/transactionlog/TableSnapshot.java
Outdated
Show resolved
Hide resolved
5f2e6bd
to
9487eeb
Compare
e27c336
to
b425db6
Compare
Add support for stats projection in Delta checkpoint iterator
b425db6
to
5478483
Compare
Description
Follow-up work from #19588 used to retrieve from the checkpoint file only the add file statistics for the columns projected in the query.
This change can save up CPU and IO time from deserializing unnecessary
add
.stats_parsed
....
columns in a Delta Lake query.Used for testing a multi-part checkpoint file (25 parts , each around 12MB ~ 300MB in total) for testing this feature while storing the checkpoint in local MinIO and came up with the following results:
As can be seen on the listing above, compared to the partition pruning change from #19588 , the change here does not provide an explosive improvement in efficiency, but it manages to shave off a noticeable wait time in processing the checkpoint.
Fixes #19733
Additional context and related issues
Same as in #19588 , the add stats projection functioanlity is effective only when the session setting
checkpoint_filtering_enabled
is set totrue
Release notes
( ) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required. Please propose a release note for me.
(x) Release notes are required, with the following suggested text: