Skip to content

fix: Exclude out-of-range rollupLambda partitions - #11446

Open
mvanhorn wants to merge 1 commit into
cube-js:masterfrom
mvanhorn:fix/11317-rollup-lambda-range-filter
Open

fix: Exclude out-of-range rollupLambda partitions#11446
mvanhorn wants to merge 1 commit into
cube-js:masterfrom
mvanhorn:fix/11317-rollup-lambda-range-filter

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Aug 1, 2026

Copy link
Copy Markdown

Summary

A rollupLambda query can treat the last member's most-recent partition as valid even when that member's build range has no overlap with the requested date range.

Extend the rollup-lambda result filter in PreAggregationPartitionRangeLoader.loadPreAggregations() so a candidate with a partitionRange is retained only when that range intersects matchedTimeDimensionDateRange, while preserving current behavior when no matched query range is supplied. Keep the existing lastRollupLambda completeness exception and prior-member boundary ordering intact for genuinely overlapping partitions; removing that exception alone does not reject a fully built but irrelevant placeholder. When every candidate is out of range, reuse the existing emptyResult path so Cube still exposes a structurally compatible table expression guarded by WHERE 1 = 0 rather than unioning the placeholder as data. Add direct loader regression coverage using the existing mocks in PreAggregations.test.ts, without introducing a helper or seam used only by tests.

Why this matters

A rollupLambda query can treat the last member's most-recent partition as valid even when that member's build range has no overlap with the requested date range. partitionRanges() deliberately supplies that partition as a structural placeholder, but loadPreAggregations() currently filters only for build completeness and ordering against earlier lambda members. Because lastRollupLambda bypasses the completeness half of that predicate, the irrelevant placeholder can enter the union and contribute to silent empty or incomplete results when another member is stale. The issue is reproducible across partition granularities and database drivers, and a maintainer has confirmed the loader-level root cause.

Testing

  • A fully built last rollupLambda member whose placeholder partition is wholly after the requested batch-only range is rejected, and its returned target expression is guarded by WHERE 1 = 0 rather than treated as a valid union contributor.
  • A last-member partition that overlaps the requested range remains eligible, including a range that straddles the batch/hot boundary, so valid hot data is not removed.
  • A load without matchedTimeDimensionDateRange preserves the existing lambda filtering behavior instead of treating the absent range as non-overlap.
  • Boundary-touching ranges continue to count as an intersection under the loader's inclusive date-range semantics.

Check List

  • Tests have been run in packages where changes have been made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Fixes #11317

@mvanhorn
mvanhorn requested a review from a team as a code owner August 1, 2026 11:19
@github-actions github-actions Bot added javascript Pull requests that update Javascript code pr:community Contribution from Cube.js community members. labels Aug 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code pr:community Contribution from Cube.js community members.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rollupLambda silently drops/loses data outside the last-listed rollup's build range

1 participant