diff --git a/metricflow/sql/render/big_query.py b/metricflow/sql/render/big_query.py index 5745ab2f8..186f23110 100644 --- a/metricflow/sql/render/big_query.py +++ b/metricflow/sql/render/big_query.py @@ -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 diff --git a/metricflow/sql/render/postgres.py b/metricflow/sql/render/postgres.py index 92e910eb1..f5a4a8858 100644 --- a/metricflow/sql/render/postgres.py +++ b/metricflow/sql/render/postgres.py @@ -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) ),