Skip to content

Commit

Permalink
Fix dialect-specific rendering issues
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Dec 18, 2024
1 parent b0b1f2d commit 0048a87
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions metricflow/sql/render/big_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def visit_add_time_expr(self, node: SqlAddTimeExpression) -> SqlExpressionRender
count = node.count_expr.accept(self)

return SqlExpressionRenderResult(
sql=f"DATE_ADD(CAST({column.sql} AS {self.timestamp_data_type}), INTERVAL {count} {node.granularity.value})",
bind_parameter_set=column.bind_parameter_set,
sql=f"DATE_ADD(CAST({column.sql} AS {self.timestamp_data_type}), INTERVAL {count.sql} {node.granularity.value})",
bind_parameter_set=column.bind_parameter_set.merge(count.bind_parameter_set),
)

@override
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 @@ -76,7 +76,7 @@ def visit_add_time_expr(self, node: SqlAddTimeExpression) -> SqlExpressionRender
count_sql = f"({count_rendered.sql})" if count_expr.requires_parenthesis else count_rendered.sql

return SqlExpressionRenderResult(
sql=f"{arg_rendered.sql} + MAKE_INTERVAL({granularity.value}s => {count_sql})",
sql=f"{arg_rendered.sql} + MAKE_INTERVAL({granularity.value}s => CAST ({count_sql} AS INTEGER))",
bind_parameter_set=SqlBindParameterSet.merge_iterable(
(arg_rendered.bind_parameter_set, count_rendered.bind_parameter_set)
),
Expand Down

0 comments on commit 0048a87

Please sign in to comment.