Skip to content

Commit

Permalink
fix: measure & dimension check
Browse files Browse the repository at this point in the history
  • Loading branch information
nextchamp-saqib committed Jan 13, 2024
1 parent 843a7e3 commit 641d1ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions insights/insights/doctype/insights_query/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,11 @@ def from_dicts(dicts):
return [Column(**d) for d in dicts]

def is_aggregate(self):
return self.aggregation and self.aggregation != "custom"
return (
self.aggregation
and self.aggregation.lower() != "custom"
and self.aggregation.lower() != "group by"
)

def is_expression(self):
return (
Expand All @@ -306,8 +310,11 @@ def is_string_type(self):
return self.type in ["String", "Text"]

def is_measure(self):
return self.aggregation.lower() != "group by" and (
self.is_numeric_type() or self.is_aggregate() or self.is_expression()
# TODO: if is_expression and is_aggregate then it is a measure (can't determine if aggregation is set)
return (
self.is_numeric_type()
or self.is_aggregate()
or (self.is_expression() and self.is_numeric_type())
)

def is_dimension(self):
Expand Down
2 changes: 1 addition & 1 deletion insights/insights/query_builders/sql_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def make_sql_column(column, for_filter=False):
if column.is_expression():
_column = self.expression_processor.process(column.expression.ast)

if column.is_aggregate() and column.aggregation.lower() != "group by":
if column.is_aggregate():
_column = self.aggregations.apply(column.aggregation, _column)

if column.has_granularity() and not for_filter:
Expand Down

0 comments on commit 641d1ad

Please sign in to comment.