Repository navigation
Conversation
This was referenced Nov 26, 2026
👷 Deploy request for thriving-cassata-78ae72 pending review.Visit the deploys page to approve it
|
Miskho
marked this pull request as ready for review
November 26, 2026 09:14
Contributor
[Medium impact] The reviewed changes appear safe to merge. SummaryThe PR aggregates fact inputs to the requested dimensions before joining them, preventing repeated rows from inflating totals.
|
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.
Summary
Combining a daily download total with distinct visitor metrics can inflate the download total. This PR aggregates each safely aggregatable input to the requested output dimensions before joining facts.
For example, request downloads, distinct visitors, and distinct mobile visitors grouped by day. The following simplified intermediate inputs come from the regression fixture (without its optional NULL-account row).
A — downloads aggregated by day
B — visitor membership retained for exact distinct counts
B retains account identities because the metrics count distinct accounts. Two raw visits by account 101 have already collapsed into one membership row. Joining A to B on day still repeats A's total:
A final
SUM(downloads)then returns43 × 3 = 129. The visitor counts remain correct in this example, which can make the inflated download total easy to miss.Collapse safely aggregatable inputs to the requested output grain before joining facts. Preserve each component's merge function, exact DISTINCT operator, selected dimensions, and AVG operands. Reject incompatible DISTINCT operators and unsafe cross-fact SQL-window shapes instead of returning inflated results; safe DISTINCT/MIN/MAX windows and fixed-grain broadcasts remain supported.
DISTINCT operator and merge-metadata lookup is scoped to the owning fact group, including base metrics of derived requests. Same-named columns in separate facts do not cause false conflicts; incompatible operators sharing one wrapper remain rejected.
Test Plan
Local execution used Python 3.13 and DuckDB. Native Spark/Trino, other Python CI versions, and optional integration stacks were not run locally.
Deployment Plan
No schema migration. Queries with unsafe cross-fact SQL-window fanout now return a validation error rather than an incorrect result.
Companion compiler fixes, validated together: #2755 (output-dimension filters) and #2756 (CTE identity). These PRs share compiler files; later PRs may need rebasing after the first merge.