Skip to content

Commit

Permalink
Remove generic time delta language to differentiate from date add expr
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Dec 11, 2024
1 parent 7782067 commit 4bcec27
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion metricflow/sql/render/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def visit_extract_expr(self, node: SqlExtractExpression) -> SqlExpressionRenderR
)

@override
def visit_time_delta_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult:
def visit_subtract_time_interval_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult:
"""Render time delta for BigQuery, which requires ISO prefixing for the WEEK granularity value."""
column = node.arg.accept(self)

Expand Down
2 changes: 1 addition & 1 deletion metricflow/sql/render/duckdb_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def supported_percentile_function_types(self) -> Collection[SqlPercentileFunctio
}

@override
def visit_time_delta_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult:
def visit_subtract_time_interval_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult:
"""Render time delta expression for DuckDB, which requires slightly different syntax from other engines."""
arg_rendered = node.arg.accept(self)

Expand Down
4 changes: 3 additions & 1 deletion metricflow/sql/render/expr_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ def render_date_part(self, date_part: DatePart) -> str:

return date_part.value

def visit_time_delta_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult: # noqa: D102
def visit_subtract_time_interval_expr(
self, node: SqlSubtractTimeIntervalExpression
) -> SqlExpressionRenderResult: # noqa: D102
arg_rendered = node.arg.accept(self)

count = node.count
Expand Down
2 changes: 1 addition & 1 deletion metricflow/sql/render/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def supported_percentile_function_types(self) -> Collection[SqlPercentileFunctio
return {SqlPercentileFunctionType.CONTINUOUS, SqlPercentileFunctionType.DISCRETE}

@override
def visit_time_delta_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult:
def visit_subtract_time_interval_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult:
"""Render time delta operations for PostgreSQL, which needs custom support for quarterly granularity."""
arg_rendered = node.arg.accept(self)

Expand Down
2 changes: 1 addition & 1 deletion metricflow/sql/render/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def visit_generate_uuid_expr(self, node: SqlGenerateUuidExpression) -> SqlExpres
)

@override
def visit_time_delta_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult:
def visit_subtract_time_interval_expr(self, node: SqlSubtractTimeIntervalExpression) -> SqlExpressionRenderResult:
"""Render time delta for Trino, require granularity in quotes and function name change."""
arg_rendered = node.arg.accept(self)

Expand Down
8 changes: 5 additions & 3 deletions metricflow/sql/sql_exprs.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ def visit_extract_expr(self, node: SqlExtractExpression) -> VisitorOutputT: # n
pass

@abstractmethod
def visit_time_delta_expr(self, node: SqlSubtractTimeIntervalExpression) -> VisitorOutputT: # noqa: D102
def visit_subtract_time_interval_expr(
self, node: SqlSubtractTimeIntervalExpression
) -> VisitorOutputT: # noqa: D102
pass

@abstractmethod
Expand Down Expand Up @@ -1285,11 +1287,11 @@ def requires_parenthesis(self) -> bool: # noqa: D102
return False

def accept(self, visitor: SqlExpressionNodeVisitor[VisitorOutputT]) -> VisitorOutputT: # noqa: D102
return visitor.visit_time_delta_expr(self)
return visitor.visit_subtract_time_interval_expr(self)

@property
def description(self) -> str: # noqa: D102
return "Time delta"
return "Subtract time interval"

def rewrite( # noqa: D102
self,
Expand Down

0 comments on commit 4bcec27

Please sign in to comment.