Repository navigation
Conversation
Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/ObjectStorage/StorageObjectStorage.cpp
|
Workflow [PR], commit [39509c5] Summary: ❌
AI ReviewSummaryThe PR enables Missing context / blind spots
Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block. Close the nested-CDF guard gap, add its focused regression, and supply evidence for the performance claim. |
| #endif | ||
| #if USE_PARQUET && USE_DELTA_KERNEL_RS | ||
| if constexpr (std::is_same_v<DataLakeMetadata, DeltaLakeMetadata>) | ||
| return true; |
There was a problem hiding this comment.
[P1] Disable PREWHERE for CDF until its source executes the filter
This also enables PREWHERE for Delta table functions with delta_lake_snapshot_start_version set. Those reads take the separate branch in StorageObjectStorage::read and use ReadFromDeltaLakeTableChangesStep: its updatePrewhereInfo only stores the DAG, and neither initializePipeline nor TableChanges::next evaluates it. Once the optimizer moves a whole WHERE condition, it removes the corresponding FilterStep, so the predicate is lost. The kernel's EnginePredicate only performs statistics/partition pruning; an expression such as length(email) = 7 is not translated at all.
For example, a CDF query selecting id, email with PREWHERE length(email) = 7 returns nonmatching rows from a file containing different email lengths. Ordinary WHERE queries can also regress when automatically moved. Please disable both explicit and automatic PREWHERE in CDF mode, or apply the filter to the Arrow chunks, and add a CDF regression with matching and nonmatching rows in the same file.
There was a problem hiding this comment.
39509c58 handles the top-level case, but src/Storages/ObjectStorage/StorageObjectStorage.cpp:474-475 still checks the outer thread query context. A nested query's SETTINGS are applied to a separate context (QueryTreeBuilder.cpp:457-466), which is also used to execute its table function (QueryAnalyzer.cpp:5791-5800). The read therefore enters CDF mode while this guard still sees delta_lake_snapshot_start_version = -1 and admits PREWHERE.
Using the new test's CDF fixture, with the outer setting left at its default:
SELECT *
FROM
(
SELECT id, email
FROM deltaLakeLocal('<ROOT>/cdf')
PREWHERE length(email) = 4
SETTINGS delta_lake_snapshot_start_version = 1
);This must return only IDs 0–9. The current CDF source still never evaluates the admitted predicate, so the source trace leaves IDs 10–19 unfiltered too. Please derive the capability from the effective read context (for example, retain the CDF mode on the table-function storage), and cover nested queries with both explicit and automatically moved PREWHERE. Runtime confirmation needs a kernel-enabled build; the available fast-test binary omits these formats.
| SELECT 'prewhere output', id, length(email) AS l FROM t_unpart PREWHERE length(email) = 7 ORDER BY id LIMIT 3; | ||
| SELECT 'prewhere count', count() FROM t_unpart PREWHERE email LIKE 'u1%'; | ||
| SELECT 'prewhere virtual', _file != '', id FROM t_unpart PREWHERE email = 'u7@x'; | ||
| SELECT 'moved to prewhere', trim(explain) FROM (EXPLAIN actions = 1 SELECT id FROM t_unpart WHERE email = 'u1500@x') WHERE explain LIKE '%Prewhere filter column%'; |
There was a problem hiding this comment.
[P2] Add evidence for the claimed performance improvement
The new tests check result equality and an EXPLAIN marker, but do not show that enabling PREWHERE actually saves read or decoding work for Delta tables. There are no before/after measurements in the PR description either. Since the selected changelog category is Performance Improvement, please provide a focused comparison with optimize_move_to_prewhere = 0 and 1 on the same Delta fixture, using a selective predicate and a substantial payload that cannot be eliminated by file statistics. Measured read/decoded bytes or a repeatable timing benchmark would establish the claimed benefit.
`updateFormatPrewhereInfo` rebuilt `requested_columns` and `source_header` from the physical format header, so a subcolumn read through its storage column (`arr.size0` read as `arr`, `n.null` read as `n`) disappeared, and queries failed with `NOT_FOUND_COLUMN_IN_BLOCK`. This also affected plain `Parquet` files on master. Keep the requested columns as they were requested instead. `ReadFromDeltaLakeTableChangesStep` applies neither `PREWHERE` nor the row-level filter, so report no `PREWHERE` support when `delta_lake_snapshot_start_version` is set. Addresses review comments in #126099 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes25 object files changed (+93.07 KiB total), 0 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units123 translation units recompiled, 1281 s compile time in total, 122 of them have a recent master baseline. Median compile-time ratio to the baselines is ×1.08 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Support prewhere in delta lake
Workflow [PR]
Sync PR [sync-upstream/pr/126099]