-
Notifications
You must be signed in to change notification settings - Fork 2.1k
fix(tesseract): Push ad-hoc filters into view measure aggregation #11137
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
Open
ovr
wants to merge
2
commits into
master
Choose a base branch
from
fix/tesseract-ad-hoc-measure-aggregation
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+94
−4
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
7 changes: 7 additions & 0 deletions
7
...planner__tests__member_expressions_on_views__many_to_one_view_patched_measure_filter.snap
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| source: cubesqlplanner/src/tests/member_expressions_on_views.rs | ||
| expression: result | ||
| --- | ||
| filtered_root_sum | ||
| ----------------- | ||
| 30.00 |
Oops, something went wrong.
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.
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.
@claude please double verify that without this change, test test_many_to_one_view_patched_measure_filter fails. Please verify it carefully
Uh oh!
There was an error while loading. Please reload this page.
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.
Claude finished @ovr's task in 2m 45s —— View job
Verified: the test fails without the change ✔
Answer to @ovr: Yes — without this change
test_many_to_one_view_patched_measure_filterfails, and it fails before theCASE WHENassert or the PG snapshot ever run, onbuild_sql_from_options(...)?atmember_expressions_on_views.rs:246.The failing path, step by step (with the fix reverted)
The view measure
many_to_one_view.root_val_sumcompiles to aMeasureSymbolwith:is_reference = true— set atmeasure_symbol.rs:748(is_view && is_sql_is_direct_ref), andkind = Calculated(Number)— because the view exposes the measure withmeasure_type = "number", soMeasureKind::from_type_str("number", …)yieldsCalculated(measure_symbol.rs:716).With the fix removed, the branch reads
if let Ok(source_measure) = source_measure_compiled.as_measure():as_measure()succeeds. The symbol is aMemberSymbol::Measure, soas_measure()returnsOk(member_symbol.rs:297-305). So we enter thenew_patchedbranch — the error path, not the harmlesselsefallback.new_patchedrejects the filter.add_filtersis non-empty (the ad-hoc{…root_test_dim} = 'rt_x'),result_kindisCalculated(Number), andCalculatedhits the_ => falsearm ofsupports_additional_filters()(measure_kinds/mod.rs:184-197). Sonew_patchedreturnsErr("Unsupported additional filters for measure root_val_sum type number")(measure_symbol.rs:194-200).?propagates.query_properties_compiler.rs:283uses?, so theErrbubbles out of the compile step → out ofbuild_sql_from_options.let sql = ctx.build_sql_from_options(options.clone())?;— the?returns theErras the test'sResult, so the#[tokio::test]reports failure with that error message. (Earlier, beforechore: up code quality, this was an.unwrap()and would have panicked at the same point — same outcome, louder.)Why the fix makes it pass
resolve_reference_chain()walksreference_member()(member_symbol.rs:214-220) from the view measure to the owning cube measure, whosekindisAggregated(Sum).Sumdoes support additional filters, sonew_patchedsucceeds and the filter is rendered inside the aggregation (SUM(CASE WHEN … END)) — which is exactly what theassert!(sql.contains("CASE WHEN"))and the PG snapshot (30.00 = 10 + 20) then verify.Conclusion: The regression guard is genuine. Remove the two changed lines and the test stops at step 4 with
Unsupported additional filters for measure root_val_sum type number— it never reaches the assertion or snapshot. The fix is load-bearing.·
fix/tesseract-ad-hoc-measure-aggregation