fix: preserve preagg + canonical backend through with_measures on joins#261
Open
hussainsultan wants to merge 1 commit intomainfrom
Open
fix: preserve preagg + canonical backend through with_measures on joins#261hussainsultan wants to merge 1 commit intomainfrom
hussainsultan wants to merge 1 commit intomainfrom
Conversation
SemanticJoin.with_measures()/with_dimensions() wraps the joined table in a new SemanticTableOp with name=None. _to_untagged_with_preagg partitioned aggregates via _partition_agg_specs_by_source(plan.agg_specs, all_roots) where all_roots = [wrapper_op]; since the wrapper has no name, prefixed aggregates collapsed into the unprefixed bucket and bypassed per-grain pre-aggregation, fanning out the coarser table's measures. Partition by _find_all_root_models(join_op) instead, recovering the original per-table roots from the SemanticJoinOp. For non-wrapper paths this is equivalent to all_roots; only the wrapper case changes behavior. Also: to_untagged() now applies _rebind_to_canonical_backend so callers of to_untagged()/to_tagged() get expressions that .execute() directly. SemanticTable.execute()/.compile()/.sql() already did this rebind; the public conversion functions did not, surfacing "Multiple backends found" errors on join + preagg lowering. to_tagged() benefits transitively. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
SemanticJoin.with_measures()/with_dimensions()wraps the join in aSemanticTableOpwithname=None. Pre-agg partitioning usedall_roots = [wrapper], so prefixed aggregates collapsed into the unprefixed bucket and bypassed per-grain pre-aggregation — fanning out the coarser table by the finer table's row count. Fix: partition by_find_all_root_models(join_op)instead.to_untagged()/to_tagged()returned expressions that raisedXorqError: Multiple backends foundon.execute(), even thoughSemanticTable.execute()worked (it already wraps with_rebind_to_canonical_backend). Apply the same rebind insideto_untagged();to_tagged()benefits transitively.Test plan
expr.execute(),to_untagged(expr).execute(),to_tagged(expr).execute()all return correct numbers for grain-matched and grain-mismatched joins🤖 Generated with Claude Code