Skip to content

Commit

Permalink
Add requires_ordering property to SqlWindowFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Jun 13, 2024
1 parent b16ee3c commit 4b0b005
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions metricflow/sql/sql_exprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -952,6 +952,16 @@ class SqlWindowFunction(Enum):
LAST_VALUE = "LAST_VALUE"
AVERAGE = "AVG"

@property
def requires_ordering(self) -> bool:
"""Asserts whether or not ordering the window function will have an impact on the resulting value."""
if self is SqlWindowFunction.FIRST_VALUE or self is SqlWindowFunction.LAST_VALUE:
return True
elif self is SqlWindowFunction.AVERAGE:
return False
else:
assert_values_exhausted(self)


@dataclass(frozen=True)
class SqlWindowOrderByArgument:
Expand Down

0 comments on commit 4b0b005

Please sign in to comment.