Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/boring_semantic_layer/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@


def to_untagged(expr):
from .ops import _rebind_to_canonical_backend

if isinstance(expr, SemanticTable):
return expr.op().to_untagged()
return _rebind_to_canonical_backend(expr.op().to_untagged())

result = safe(lambda: expr.to_untagged())()
if isinstance(result, Success):
return result.unwrap()
return _rebind_to_canonical_backend(result.unwrap())

raise TypeError(f"Cannot convert {type(expr)} to Ibis expression")

Expand Down
8 changes: 7 additions & 1 deletion src/boring_semantic_layer/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -2510,7 +2510,13 @@ def _to_untagged_with_preagg(
)

# --- 3. Partition agg_specs by source table ---
partitioned = _partition_agg_specs_by_source(dict(plan.agg_specs), all_roots)
# Partition by the join's per-table roots, not ``all_roots``. When a
# wrapper SemanticTableOp from ``SemanticJoin.with_measures()`` /
# ``with_dimensions()`` is in the tree, ``all_roots`` collapses to a
# single name=None root, so prefixed aggregates would all fall into the
# unprefixed bucket and bypass per-grain pre-aggregation.
partition_roots = _find_all_root_models(join_op)
partitioned = _partition_agg_specs_by_source(dict(plan.agg_specs), partition_roots)

# --- 4. Pre-aggregate each source table on its raw table ---
_preagg_results: list = []
Expand Down
Loading