feat: preserve filters over planned summaries - #366
Merged
Conversation
zzylol
force-pushed
the
feat/clickhouse-sql-filter
branch
from
September 10, 2026 04:38
e2abfbb to
3df6f87
Compare
zzylol
force-pushed
the
feat/clickhouse-sql-filter
branch
from
September 10, 2026 06:20
3df6f87 to
4bdb8b8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before this PR
PR #365 preserves SQL
Projectnodes while recursively materializing their aggregate children. A filter above a derived aggregate still becomes one opaqueKeepPreAsapsubtree, however. For example:The canonical DAG contains
Limit -> Sort -> Project -> Filter -> Project -> Aggregate, but the Filter hides the summary-bound aggregate from the final executable DAG.After this PR
Filter is an explicit read-time
ValueOperationthat preserves its canonical predicate and output schema. Global selection materializes the Filter child independently, so the example retains the complete Project/Filter/Sort/Limit chain overSummaryEstimate -> SummaryAgg.The two selection scopes remain separate:
service = 'api'stays in the raw Scan that populates the summary, whilet.p > 100executes only after summary readout. If a child is unsupported, only that child remains an opaque fallback leaf and the supported Filter stays explicit.The operation uses the existing shared post-ASAP value-operation and execution-data-state contracts. No predicate is reordered across an aggregate.
Verification
mainincluding feat: add MetricsQL canonical frontend #368cargo test --workspace --lockedcargo clippy --workspace --all-targets --all-features --locked -- -D warningscargo test -p asap-integration-tests --test sql_to_post_asap(7 passed)cargo fmt --all -- --checkgit diff --checkLimitations
KeepPreAsapfallbacks.ValueOperation::Filterbefore executing the newly explicit node.