Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bigframes/core/compile/sqlglot/expressions/generic_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def _(expr: TypedExpr) -> sge.Expression:
@register_unary_op(ops.invert_op)
def _(expr: TypedExpr) -> sge.Expression:
if expr.dtype == dtypes.BOOL_DTYPE:
return sge.Not(this=expr.expr)
return sge.BitwiseNot(this=expr.expr)
return sge.Not(this=sge.paren(expr.expr))
return sge.BitwiseNot(this=sge.paren(expr.expr))


@register_unary_op(ops.isnull_op)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _(expr: TypedExpr) -> sge.Expression:

@register_unary_op(ops.neg_op)
def _(expr: TypedExpr) -> sge.Expression:
return sge.Neg(this=expr.expr)
return sge.Neg(this=sge.paren(expr.expr))


@register_unary_op(ops.pos_op)
Expand Down
2 changes: 1 addition & 1 deletion tests/system/small/engines/test_generic_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def test_engines_isin_op(scalars_array_value: array_value.ArrayValue, engine):
assert_equivalence_execution(arr.node, REFERENCE_ENGINE, engine)


@pytest.mark.parametrize("engine", ["polars", "bq"], indirect=True)
@pytest.mark.parametrize("engine", ["polars", "bq", "bq-sqlglot"], indirect=True)
def test_engines_isin_op_nested_filter(
scalars_array_value: array_value.ArrayValue, engine
):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ WITH `bfcte_0` AS (
), `bfcte_1` AS (
SELECT
*,
~`bfcol_2` AS `bfcol_6`,
~`bfcol_1` AS `bfcol_7`,
NOT `bfcol_0` AS `bfcol_8`
~(
`bfcol_2`
) AS `bfcol_6`,
~(
`bfcol_1`
) AS `bfcol_7`,
NOT (
`bfcol_0`
) AS `bfcol_8`
FROM `bfcte_0`
)
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,43 @@ WITH `bfcte_0` AS (
`bfcol_8` AS `bfcol_16`,
`bfcol_9` AS `bfcol_17`,
CASE
WHEN -`bfcol_7` = CAST(0 AS INT64)
WHEN -(
`bfcol_7`
) = CAST(0 AS INT64)
THEN CAST(0 AS INT64) * `bfcol_7`
WHEN -`bfcol_7` < CAST(0 AS INT64)
WHEN -(
`bfcol_7`
) < CAST(0 AS INT64)
AND (
MOD(`bfcol_7`, -`bfcol_7`)
MOD(`bfcol_7`, -(
`bfcol_7`
))
) > CAST(0 AS INT64)
THEN -`bfcol_7` + (
MOD(`bfcol_7`, -`bfcol_7`)
THEN -(
`bfcol_7`
) + (
MOD(`bfcol_7`, -(
`bfcol_7`
))
)
WHEN -`bfcol_7` > CAST(0 AS INT64)
WHEN -(
`bfcol_7`
) > CAST(0 AS INT64)
AND (
MOD(`bfcol_7`, -`bfcol_7`)
MOD(`bfcol_7`, -(
`bfcol_7`
))
) < CAST(0 AS INT64)
THEN -`bfcol_7` + (
MOD(`bfcol_7`, -`bfcol_7`)
THEN -(
`bfcol_7`
) + (
MOD(`bfcol_7`, -(
`bfcol_7`
))
)
ELSE MOD(`bfcol_7`, -`bfcol_7`)
ELSE MOD(`bfcol_7`, -(
`bfcol_7`
))
END AS `bfcol_18`
FROM `bfcte_1`
), `bfcte_3` AS (
Expand Down Expand Up @@ -152,23 +172,43 @@ WITH `bfcte_0` AS (
`bfcol_56` AS `bfcol_72`,
`bfcol_57` AS `bfcol_73`,
CASE
WHEN CAST(-`bfcol_52` AS BIGNUMERIC) = CAST(0 AS INT64)
WHEN CAST(-(
`bfcol_52`
) AS BIGNUMERIC) = CAST(0 AS INT64)
THEN CAST('NaN' AS FLOAT64) * CAST(`bfcol_52` AS BIGNUMERIC)
WHEN CAST(-`bfcol_52` AS BIGNUMERIC) < CAST(0 AS INT64)
WHEN CAST(-(
`bfcol_52`
) AS BIGNUMERIC) < CAST(0 AS INT64)
AND (
MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-`bfcol_52` AS BIGNUMERIC))
MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-(
`bfcol_52`
) AS BIGNUMERIC))
) > CAST(0 AS INT64)
THEN CAST(-`bfcol_52` AS BIGNUMERIC) + (
MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-`bfcol_52` AS BIGNUMERIC))
THEN CAST(-(
`bfcol_52`
) AS BIGNUMERIC) + (
MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-(
`bfcol_52`
) AS BIGNUMERIC))
)
WHEN CAST(-`bfcol_52` AS BIGNUMERIC) > CAST(0 AS INT64)
WHEN CAST(-(
`bfcol_52`
) AS BIGNUMERIC) > CAST(0 AS INT64)
AND (
MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-`bfcol_52` AS BIGNUMERIC))
MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-(
`bfcol_52`
) AS BIGNUMERIC))
) < CAST(0 AS INT64)
THEN CAST(-`bfcol_52` AS BIGNUMERIC) + (
MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-`bfcol_52` AS BIGNUMERIC))
THEN CAST(-(
`bfcol_52`
) AS BIGNUMERIC) + (
MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-(
`bfcol_52`
) AS BIGNUMERIC))
)
ELSE MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-`bfcol_52` AS BIGNUMERIC))
ELSE MOD(CAST(`bfcol_52` AS BIGNUMERIC), CAST(-(
`bfcol_52`
) AS BIGNUMERIC))
END AS `bfcol_74`
FROM `bfcte_5`
), `bfcte_7` AS (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ WITH `bfcte_0` AS (
), `bfcte_1` AS (
SELECT
*,
-`bfcol_0` AS `bfcol_1`
-(
`bfcol_0`
) AS `bfcol_1`
FROM `bfcte_0`
)
SELECT
Expand Down