Skip to content

Commit

Permalink
[WIP] BI-4882 Remove unbound expressions from GROUP BY during query c…
Browse files Browse the repository at this point in the history
…ompilation
  • Loading branch information
KonstantAnxiety committed Dec 25, 2023
1 parent 7a0ddf2 commit d56cfb6
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
contains_extended_aggregations,
contains_lookup_functions,
get_toplevel_dimension_set,
is_bound_only_to,
is_window_expression,
)
from dl_formula.mutation.general import (
Expand Down Expand Up @@ -270,6 +271,15 @@ def mutate_query(self, compiled_query: CompiledQuery) -> CompiledQuery:
)
compiled_query = mutator.mutate_query(compiled_query)

# Don't group by unbound expressions (ones that don't refer to source fields)
compiled_query = compiled_query.clone(
group_by=[
group_by_item
for group_by_item in compiled_query.group_by
if not is_bound_only_to(group_by_item.formula_obj, NodeSet())
]
)

filter_mutator = IgnoreFormulaAtomicQueryMutator(ignore_formula_checks=[formula_is_true])
compiled_query = filter_mutator.mutate_query(compiled_query)

Expand Down

0 comments on commit d56cfb6

Please sign in to comment.