fix(tesseract): keep pre-aggregations for RBAC access-denied 1=0 segment#11123
Conversation
A member-expression segment with no member dependencies (the rlsAccessDenied '1 = 0' segment RBAC injects on access denial) must not disqualify pre-aggregation matching. Adds a crate-level cubesqlplanner test (segment injected by hand) and a schema-compiler integration test (run with and without the Tesseract flags in CI). Both currently fail under the native planner and pass on the legacy planner.
…egment An ad-hoc member-expression segment that references no members (the rlsAccessDenied '1 = 0' segment RBAC injects on access denial) was disqualifying pre-aggregation matching in the native planner, sending denied queries to the raw source instead of the rollup. Such a constant is a filter pushable on top of any rollup, so the segment matcher now treats it as a full match. Named cube segments still require coverage. This matches the legacy planner, which ignores member-expression segments when selecting pre-aggregations. Covered by an inline DimensionMatcher test.
|
Claude finished @waralexrom's task in 1m 4s —— View job Code ReviewVerdict: LGTM — 0 high, 0 medium, 2 low (nits). Click to expand.Tasks
Correctness The fix is well-targeted and the reasoning is sound:
Test coverage Three layers — unit Nits (low priority, not blocking)
Security / performance No concerns. The fast-path is · |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #11123 +/- ##
==========================================
- Coverage 83.63% 79.14% -4.49%
==========================================
Files 256 473 +217
Lines 79019 96411 +17392
Branches 0 3524 +3524
==========================================
+ Hits 66086 76303 +10217
- Misses 12933 19594 +6661
- Partials 0 514 +514
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
When a cube's access policy denies the queried members, RBAC (
CompilerApi.applyRowLevelSecurity) appends a constant member-expression segment{ expression: () => '1 = 0', name: 'rlsAccessDenied' }. Under the Tesseract native planner this segment was disqualifying pre-aggregation matching, so denied queries (typically against a view) were sent to the raw data source instead of the rollup. The legacy planner doesn't have this problem.Changes
dimension_matcher.rs: an ad-hoc member-expression segment with no member dependencies (a constant filter pushable on top of any rollup) is treated as a full match instead ofNotMatched. Named cube segments still require pre-aggregation coverage.base_segment.rs: trackis_member_expressionto distinguish ad-hoc query-level expressions from registered named segments (both compile to aMemberExpression, only their construction differs).DimensionMatchertest, a crate-level pre-aggregation SQL test (segment injected by hand, since the crate has no RBAC), and aschema-compilerintegration test. Small test-harness helpers to inject member-expression segments.Testing
cargo testincubesqlplanner: 1016 passed / 0 failed (the new tests verified red without the fix, green with it).schema-compilerpre-aggregation integration suites: 70 passed underCUBEJS_TESSERACT_*flags, 67 passed on the legacy planner, 0 failed.WHERE (1 = 0)applied on top.