diff --git a/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py b/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py index 647e86d28a..3b85139004 100644 --- a/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py +++ b/bigframes/core/compile/sqlglot/aggregations/unary_compiler.py @@ -527,7 +527,7 @@ def _( else: result = apply_window_if_present(result, window) - if op.should_floor_result: + if op.should_floor_result or column.dtype == dtypes.TIMEDELTA_DTYPE: result = sge.Cast(this=sge.func("FLOOR", result), to="INT64") return result diff --git a/bigframes/core/compile/sqlglot/expressions/generic_ops.py b/bigframes/core/compile/sqlglot/expressions/generic_ops.py index 2f486fc9d5..003a7296fc 100644 --- a/bigframes/core/compile/sqlglot/expressions/generic_ops.py +++ b/bigframes/core/compile/sqlglot/expressions/generic_ops.py @@ -252,7 +252,7 @@ def _cast_to_json(expr: TypedExpr, op: ops.AsTypeOp) -> sge.Expression: sg_expr = expr.expr if from_type == dtypes.STRING_DTYPE: - func_name = "PARSE_JSON_IN_SAFE" if op.safe else "PARSE_JSON" + func_name = "SAFE.PARSE_JSON" if op.safe else "PARSE_JSON" return sge.func(func_name, sg_expr) if from_type in (dtypes.INT_DTYPE, dtypes.BOOL_DTYPE, dtypes.FLOAT_DTYPE): sg_expr = sge.Cast(this=sg_expr, to="STRING") diff --git a/tests/system/small/test_session.py b/tests/system/small/test_session.py index 698f531d57..0501df3f8c 100644 --- a/tests/system/small/test_session.py +++ b/tests/system/small/test_session.py @@ -352,7 +352,7 @@ def test_read_gbq_w_primary_keys_table( pd.testing.assert_frame_equal(result, sorted_result) # Verify that we're working from a snapshot rather than a copy of the table. - assert "FOR SYSTEM_TIME AS OF TIMESTAMP" in df.sql + assert "FOR SYSTEM_TIME AS OF" in df.sql def test_read_gbq_w_primary_keys_table_and_filters( diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_json/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_json/out.sql index 2defc2e72b..4ffaf7256a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_json/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_generic_ops/test_astype_json/out.sql @@ -13,7 +13,7 @@ WITH `bfcte_0` AS ( PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bfcol_6`, PARSE_JSON(`string_col`) AS `bfcol_7`, PARSE_JSON(CAST(`bool_col` AS STRING)) AS `bfcol_8`, - PARSE_JSON_IN_SAFE(`string_col`) AS `bfcol_9` + SAFE.PARSE_JSON(`string_col`) AS `bfcol_9` FROM `bfcte_0` ) SELECT