diff --git a/bigframes/testing/compiler_session.py b/bigframes/testing/compiler_session.py index 35114d95d0..da43e2d7df 100644 --- a/bigframes/testing/compiler_session.py +++ b/bigframes/testing/compiler_session.py @@ -16,7 +16,9 @@ import typing import bigframes.core -import bigframes.core.compile.sqlglot as sqlglot +from bigframes.core.compile import configs +from bigframes.core.compile.ibis_compiler import ibis_compiler + import bigframes.session.executor @@ -24,8 +26,6 @@ class SQLCompilerExecutor(bigframes.session.executor.Executor): """Executor for SQL compilation using sqlglot.""" - compiler = sqlglot - def to_sql( self, array_value: bigframes.core.ArrayValue, @@ -38,6 +38,6 @@ def to_sql( # Compared with BigQueryCachingExecutor, SQLCompilerExecutor skips # caching the subtree. - return self.compiler.SQLGlotCompiler().compile( - array_value.node, ordered=ordered - ) + request = configs.CompileRequest(array_value.node, sort_rows=ordered) + compiled = ibis_compiler.compile_sql(request) + return compiled.sql diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_size/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_size/out.sql index 78104eb578..71b54d2fa5 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_size/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_size/out.sql @@ -1,12 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COUNT(1) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col_agg` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + COUNT(1) AS `string_col_agg` + FROM ( + SELECT + `t0`.`string_col` + FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/out.sql b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/out.sql index e748f71278..138fddc7c2 100644 --- a/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/out.sql +++ b/tests/unit/core/compile/sqlglot/aggregations/snapshots/test_unary_compiler/test_sum/out.sql @@ -1,12 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - COALESCE(SUM(`bfcol_0`), 0) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col_agg` -FROM `bfcte_1` \ No newline at end of file + * +FROM ( + SELECT + COALESCE(SUM(`t1`.`int64_col`), 0) AS `int64_col_agg` + FROM ( + SELECT + `t0`.`int64_col` + FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` + ) AS `t1` +) AS `t2` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric/out.sql index 44335805e4..bb7e2937f4 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric/out.sql @@ -1,54 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` + `bfcol_1` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` + 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` + CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) + `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_add_int`, - `bfcol_40` AS `int_add_1`, - `bfcol_41` AS `int_add_bool`, - `bfcol_42` AS `bool_add_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` + `t0`.`int64_col` AS `int_add_int`, + `t0`.`int64_col` + 1 AS `int_add_1`, + `t0`.`int64_col` + CAST(`t0`.`bool_col` AS INT64) AS `int_add_bool`, + CAST(`t0`.`bool_col` AS INT64) + `t0`.`int64_col` AS `bool_add_int` +FROM ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_string/out.sql index de5129a6a3..8704ebd1fc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_string/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CONCAT(`bfcol_0`, 'a') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT(`t0`.`string_col`, 'a') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_timedelta/out.sql index a47531999b..563f4b248b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_timedelta/out.sql @@ -1,60 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1`, - `timestamp_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_6`, - `bfcol_2` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - TIMESTAMP_ADD(CAST(`bfcol_0` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - TIMESTAMP_ADD(`bfcol_7`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - TIMESTAMP_ADD(CAST(`bfcol_16` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - TIMESTAMP_ADD(`bfcol_25`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - 172800000000 AS `bfcol_50` - FROM `bfcte_4` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `timestamp_col`, - `bfcol_38` AS `date_col`, - `bfcol_39` AS `date_add_timedelta`, - `bfcol_40` AS `timestamp_add_timedelta`, - `bfcol_41` AS `timedelta_add_date`, - `bfcol_42` AS `timedelta_add_timestamp`, - `bfcol_50` AS `timedelta_add_timedelta` -FROM `bfcte_5` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`date_col`, + TIMESTAMP_ADD(CAST(`t0`.`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `date_add_timedelta`, + TIMESTAMP_ADD(`t0`.`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timestamp_add_timedelta`, + TIMESTAMP_ADD(CAST(`t0`.`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_date`, + TIMESTAMP_ADD(`t0`.`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timedelta_add_timestamp`, + 172800000000 AS `timedelta_add_timedelta` +FROM ( + SELECT + `date_col`, + `rowindex`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_div_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_div_numeric/out.sql index c1f4e0cb69..948f50b5dd 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_div_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_div_numeric/out.sql @@ -1,54 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - IEEE_DIVIDE(`bfcol_1`, `bfcol_1`) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - IEEE_DIVIDE(`bfcol_7`, 1) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - IEEE_DIVIDE(`bfcol_15`, CAST(`bfcol_16` AS INT64)) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - IEEE_DIVIDE(CAST(`bfcol_26` AS INT64), `bfcol_25`) AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_div_int`, - `bfcol_40` AS `int_div_1`, - `bfcol_41` AS `int_div_bool`, - `bfcol_42` AS `bool_div_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + ieee_divide(`t0`.`int64_col`, `t0`.`int64_col`) AS `int_div_int`, + ieee_divide(`t0`.`int64_col`, 1) AS `int_div_1`, + ieee_divide(`t0`.`int64_col`, CAST(`t0`.`bool_col` AS INT64)) AS `int_div_bool`, + ieee_divide(CAST(`t0`.`bool_col` AS INT64), `t0`.`int64_col`) AS `bool_div_int` +FROM ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_div_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_div_timedelta/out.sql index 6e05302fc9..ad669bf3c5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_div_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_div_timedelta/out.sql @@ -1,21 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1`, - `timestamp_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_6`, - `bfcol_2` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - CAST(FLOOR(IEEE_DIVIDE(86400000000, `bfcol_0`)) AS INT64) AS `bfcol_9` - FROM `bfcte_0` -) SELECT - `bfcol_6` AS `rowindex`, - `bfcol_7` AS `timestamp_col`, - `bfcol_8` AS `int64_col`, - `bfcol_9` AS `timedelta_div_numeric` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`int64_col`, + CAST(FLOOR(ieee_divide(86400000000, `t0`.`int64_col`)) AS INT64) AS `timedelta_div_numeric` +FROM ( + SELECT + `int64_col`, + `rowindex`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_json_set/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_json_set/out.sql index b226066b16..bab2a998f0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_json_set/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_json_set/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_SET(`bfcol_0`, '$.a', 100) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_set(`t0`.`json_col`, '$.a', 100) AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_mul_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_mul_numeric/out.sql index a9c81f4744..47602e1e08 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_mul_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_mul_numeric/out.sql @@ -1,54 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` * `bfcol_1` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` * 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` * CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) * `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_mul_int`, - `bfcol_40` AS `int_mul_1`, - `bfcol_41` AS `int_mul_bool`, - `bfcol_42` AS `bool_mul_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` * `t0`.`int64_col` AS `int_mul_int`, + `t0`.`int64_col` * 1 AS `int_mul_1`, + `t0`.`int64_col` * CAST(`t0`.`bool_col` AS INT64) AS `int_mul_bool`, + CAST(`t0`.`bool_col` AS INT64) * `t0`.`int64_col` AS `bool_mul_int` +FROM ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_mul_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_mul_timedelta/out.sql index 082a714845..bdaafaac30 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_mul_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_mul_timedelta/out.sql @@ -1,31 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1`, - `timestamp_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_6`, - `bfcol_2` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - CAST(FLOOR(86400000000 * `bfcol_0`) AS INT64) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - CAST(FLOOR(`bfcol_8` * 86400000000) AS INT64) AS `bfcol_18` - FROM `bfcte_1` -) SELECT - `bfcol_14` AS `rowindex`, - `bfcol_15` AS `timestamp_col`, - `bfcol_16` AS `int64_col`, - `bfcol_17` AS `timedelta_mul_numeric`, - `bfcol_18` AS `numeric_mul_timedelta` -FROM `bfcte_2` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`int64_col`, + CAST(FLOOR(86400000000 * `t0`.`int64_col`) AS INT64) AS `timedelta_mul_numeric`, + CAST(FLOOR(`t0`.`int64_col` * 86400000000) AS INT64) AS `numeric_mul_timedelta` +FROM ( + SELECT + `int64_col`, + `rowindex`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_obj_make_ref/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_obj_make_ref/out.sql index e3228feaaa..f80a566c09 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_obj_make_ref/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_obj_make_ref/out.sql @@ -1,15 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`bfcol_1`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_4` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + `OBJ.MAKE_REF`(`t0`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') AS `string_col` +FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_numeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_numeric/out.sql index a43fa2df67..302c940800 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_numeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_numeric/out.sql @@ -1,54 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_1` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - `bfcol_1` - `bfcol_1` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - `bfcol_7` - 1 AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - `bfcol_15` - CAST(`bfcol_16` AS INT64) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - CAST(`bfcol_26` AS INT64) - `bfcol_25` AS `bfcol_42` - FROM `bfcte_3` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `int64_col`, - `bfcol_38` AS `bool_col`, - `bfcol_39` AS `int_add_int`, - `bfcol_40` AS `int_add_1`, - `bfcol_41` AS `int_add_bool`, - `bfcol_42` AS `bool_add_int` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col`, + `t0`.`bool_col`, + `t0`.`int64_col` - `t0`.`int64_col` AS `int_add_int`, + `t0`.`int64_col` - 1 AS `int_add_1`, + `t0`.`int64_col` - CAST(`t0`.`bool_col` AS INT64) AS `int_add_bool`, + CAST(`t0`.`bool_col` AS INT64) - `t0`.`int64_col` AS `bool_add_int` +FROM ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_timedelta/out.sql index 41e45d3333..a6f3090eb2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_sub_timedelta/out.sql @@ -1,60 +1,16 @@ -WITH `bfcte_0` AS ( - SELECT - `date_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1`, - `timestamp_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_6`, - `bfcol_2` AS `bfcol_7`, - `bfcol_0` AS `bfcol_8`, - TIMESTAMP_SUB(CAST(`bfcol_0` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - `bfcol_6` AS `bfcol_14`, - `bfcol_7` AS `bfcol_15`, - `bfcol_8` AS `bfcol_16`, - `bfcol_9` AS `bfcol_17`, - TIMESTAMP_SUB(`bfcol_7`, INTERVAL 86400000000 MICROSECOND) AS `bfcol_18` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_14` AS `bfcol_24`, - `bfcol_15` AS `bfcol_25`, - `bfcol_16` AS `bfcol_26`, - `bfcol_17` AS `bfcol_27`, - `bfcol_18` AS `bfcol_28`, - TIMESTAMP_DIFF(CAST(`bfcol_16` AS DATETIME), CAST(`bfcol_16` AS DATETIME), MICROSECOND) AS `bfcol_29` - FROM `bfcte_2` -), `bfcte_4` AS ( - SELECT - *, - `bfcol_24` AS `bfcol_36`, - `bfcol_25` AS `bfcol_37`, - `bfcol_26` AS `bfcol_38`, - `bfcol_27` AS `bfcol_39`, - `bfcol_28` AS `bfcol_40`, - `bfcol_29` AS `bfcol_41`, - TIMESTAMP_DIFF(`bfcol_25`, `bfcol_25`, MICROSECOND) AS `bfcol_42` - FROM `bfcte_3` -), `bfcte_5` AS ( - SELECT - *, - 0 AS `bfcol_50` - FROM `bfcte_4` -) SELECT - `bfcol_36` AS `rowindex`, - `bfcol_37` AS `timestamp_col`, - `bfcol_38` AS `date_col`, - `bfcol_39` AS `date_sub_timedelta`, - `bfcol_40` AS `timestamp_sub_timedelta`, - `bfcol_41` AS `timestamp_sub_date`, - `bfcol_42` AS `date_sub_timestamp`, - `bfcol_50` AS `timedelta_sub_timedelta` -FROM `bfcte_5` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`timestamp_col`, + `t0`.`date_col`, + TIMESTAMP_SUB(CAST(`t0`.`date_col` AS DATETIME), INTERVAL 86400000000 MICROSECOND) AS `date_sub_timedelta`, + TIMESTAMP_SUB(`t0`.`timestamp_col`, INTERVAL 86400000000 MICROSECOND) AS `timestamp_sub_timedelta`, + DATE_DIFF(`t0`.`date_col`, `t0`.`date_col`, DAY) * 86400000000 AS `timestamp_sub_date`, + TIMESTAMP_DIFF(`t0`.`timestamp_col`, `t0`.`timestamp_col`, MICROSECOND) AS `date_sub_timestamp`, + 0 AS `timedelta_sub_timedelta` +FROM ( + SELECT + `date_col`, + `rowindex`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_abs/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_abs/out.sql index 6f315f8113..f2e6bdd442 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_abs/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_abs/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ABS(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ABS(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccos/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccos/out.sql index df695b7fbc..2eafbad35f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccos/out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN ABS(`bfcol_0`) > 1 THEN CAST('NaN' AS FLOAT64) ELSE ACOS(`bfcol_0`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) <= 1 + ), + CAST('NaN' AS FLOAT64), + acos(`t0`.`float64_col`) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccosh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccosh/out.sql index 5272e4a6a8..7411c9598a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccosh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arccosh/out.sql @@ -1,13 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < 1 THEN CAST('NaN' AS FLOAT64) ELSE ACOSH(`bfcol_0`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` >= 1 + ), + CAST('NaN' AS FLOAT64), + LN(`t0`.`float64_col` + SQRT(( + `t0`.`float64_col` * `t0`.`float64_col` + ) - 1)) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arcsin/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arcsin/out.sql index 3afc7c64b8..be7dd54b52 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arcsin/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arcsin/out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN ABS(`bfcol_0`) > 1 THEN CAST('NaN' AS FLOAT64) ELSE ASIN(`bfcol_0`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) <= 1 + ), + CAST('NaN' AS FLOAT64), + asin(`t0`.`float64_col`) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arcsinh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arcsinh/out.sql index 6313e80e5f..a36321cf8f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arcsinh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arcsinh/out.sql @@ -1,13 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ASINH(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + LN( + ABS(`t0`.`float64_col`) + SQRT(( + `t0`.`float64_col` * `t0`.`float64_col` + ) + 1) + ) * SIGN(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctan/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctan/out.sql index ec6a22e653..1997b950cf 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctan/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctan/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ATAN(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + atan(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctanh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctanh/out.sql index 39b5f565fe..4bbd0a5eb5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctanh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_arctanh/out.sql @@ -1,13 +1,17 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN ABS(`bfcol_0`) > 1 THEN CAST('NaN' AS FLOAT64) ELSE ATANH(`bfcol_0`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) < 1 + ), + IF( + ABS(`t0`.`float64_col`) = 1, + CAST('Infinity' AS FLOAT64) * `t0`.`float64_col`, + CAST('NaN' AS FLOAT64) + ), + ieee_divide(LN(ieee_divide(`t0`.`float64_col` + 1, 1 - `t0`.`float64_col`)), 2) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_index/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_index/out.sql index 4398084227..558444e9a3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_index/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_index/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0`[SAFE_OFFSET(1)] AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`string_list_col`[safe_offset(1)] AS `string_list_col` +FROM ( + SELECT + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.046629') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_slice_with_only_start/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_slice_with_only_start/out.sql index 1ffc3ee8f9..4d46eaf608 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_slice_with_only_start/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_slice_with_only_start/out.sql @@ -1,19 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`bfcol_0`) AS el WITH OFFSET AS slice_idx - WHERE - slice_idx >= 1 - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY( + SELECT + el + FROM UNNEST(`t0`.`string_list_col`) AS el WITH OFFSET AS bq_arr_slice + WHERE + bq_arr_slice >= IF(1 < 0, ARRAY_LENGTH(`t0`.`string_list_col`) + 1, 1) + ) AS `string_list_col` +FROM ( + SELECT + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.046629') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_slice_with_start_and_stop/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_slice_with_start_and_stop/out.sql index 878b60e5e2..2ac7b36af7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_slice_with_start_and_stop/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_slice_with_start_and_stop/out.sql @@ -1,19 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`bfcol_0`) AS el WITH OFFSET AS slice_idx - WHERE - slice_idx >= 1 AND slice_idx < 5 - ) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY( + SELECT + el + FROM UNNEST(`t0`.`string_list_col`) AS el WITH OFFSET AS bq_arr_slice + WHERE + bq_arr_slice >= IF(1 < 0, ARRAY_LENGTH(`t0`.`string_list_col`) + 1, 1) + AND bq_arr_slice < IF(5 < 0, ARRAY_LENGTH(`t0`.`string_list_col`) + 5, 5) + ) AS `string_list_col` +FROM ( + SELECT + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.046629') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_to_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_to_string/out.sql index 4dbd602bea..491d5d0564 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_to_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_array_to_string/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_list_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY_TO_STRING(`bfcol_0`, '.') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + ARRAY_TO_STRING(`t0`.`string_list_col`, '.') AS `string_list_col` +FROM ( + SELECT + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.046629') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_capitalize/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_capitalize/out.sql index 7af1708347..c51ca44e83 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_capitalize/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_capitalize/out.sql @@ -1,13 +1,22 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - INITCAP(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CONCAT( + UPPER( + SUBSTRING(`t0`.`string_col`, IF(( + 0 + 1 + ) >= 1, 0 + 1, 0 + 1 + LENGTH(`t0`.`string_col`)), 1) + ), + LOWER( + SUBSTRING( + `t0`.`string_col`, + IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(`t0`.`string_col`)), + LENGTH(`t0`.`string_col`) + ) + ) + ) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_ceil/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_ceil/out.sql index 0959f3a0ad..f2fae85d93 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_ceil/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_ceil/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CEIL(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + CEIL(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cos/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cos/out.sql index 126d2a63f2..be63c59fa7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cos/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - COS(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + cos(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cosh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cosh/out.sql index f44dfaac41..c43faa8e61 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cosh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_cosh/out.sql @@ -1,17 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`bfcol_0`) > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE COSH(`bfcol_0`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) < 709.78 + ), + CAST('Infinity' AS FLOAT64), + ieee_divide(EXP(`t0`.`float64_col`) + EXP(-( + `t0`.`float64_col` + )), 2) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_date/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_date/out.sql index 615a4a92bb..c0fbcdfc31 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_date/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_date/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - DATE(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + DATE(`t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_day/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_day/out.sql index 460823fa20..df4c16cf92 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_day/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_day/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAY FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(day FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_dayofweek/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_dayofweek/out.sql index e6c17587d0..eed336b04b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_dayofweek/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_dayofweek/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAYOFWEEK FROM `bfcol_0`) - 1 AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(MOD(EXTRACT(dayofweek FROM `t0`.`timestamp_col`) + 5, 7) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_dayofyear/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_dayofyear/out.sql index 4b60bcc4ca..498e2181fd 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_dayofyear/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_dayofyear/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAYOFYEAR FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(dayofyear FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_exp/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_exp/out.sql index 6afa3f85a5..2413ac134a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_exp/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_exp/out.sql @@ -1,17 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `bfcol_0` > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE EXP(`bfcol_0`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` < 709.78 + ), + CAST('Infinity' AS FLOAT64), + EXP(`t0`.`float64_col`) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_expm1/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_expm1/out.sql index f3768deb4a..ad5958e0af 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_expm1/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_expm1/out.sql @@ -1,17 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN `bfcol_0` > 709.78 - THEN CAST('Infinity' AS FLOAT64) - ELSE EXP(`bfcol_0`) - END - 1 AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` < 709.78 + ), + CAST('Infinity' AS FLOAT64), + EXP(`t0`.`float64_col`) + ) - 1 AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_floor/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_floor/out.sql index 56be1019e5..22b8ec9a04 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_floor/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_floor/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FLOOR(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + FLOOR(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_area/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_area/out.sql index 9b4b6894e0..e3d9905370 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_area/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_area/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_AREA(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_area(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_astext/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_astext/out.sql index 9557e2f1d6..f103d5a227 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_astext/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_astext/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_ASTEXT(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_astext(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_boundary/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_boundary/out.sql index 31c0b45034..0263240d23 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_boundary/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_boundary/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_BOUNDARY(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_boundary(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_geogfromtext/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_geogfromtext/out.sql index ba4d9dd182..06a4a8009d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_geogfromtext/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_geogfromtext/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_GEOGFROMTEXT(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + st_geogfromtext(`t0`.`string_col`) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_isclosed/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_isclosed/out.sql index d905e8470b..e144bf2a2b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_isclosed/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_isclosed/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_ISCLOSED(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_isclosed(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_length/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_length/out.sql index a023691d63..78ac579870 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_length/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_st_length/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ST_LENGTH(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_length(`t0`.`geography_col`, TRUE) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_x/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_x/out.sql index d4c0370ca8..9e29455ebc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_x/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_x/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_X(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_x(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_y/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_y/out.sql index 196c2fcad6..e2a473ebea 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_y/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_geo_y/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `geography_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SAFE.ST_Y(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `geography_col` -FROM `bfcte_1` \ No newline at end of file + st_y(`t0`.`geography_col`) AS `geography_col` +FROM ( + SELECT + `geography_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_hash/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_hash/out.sql index 14d6df6d22..af7c60cf99 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_hash/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_hash/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FARM_FINGERPRINT(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + farm_fingerprint(`t0`.`string_col`) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_hour/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_hour/out.sql index 8cc9b9081f..d1b1ef969f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_hour/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_hour/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(HOUR FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(hour FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_invert/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_invert/out.sql index 28f2aa6e06..4f363665b2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_invert/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_invert/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - ~`bfcol_0` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + ~`t0`.`int64_col` AS `int64_col` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_is_in/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_is_in/out.sql index 36941df71b..29ffbaff66 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_is_in/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_is_in/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0` IN (1, 2, 3) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`int64_col` IN (1, 2, 3) AS `int64_col` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isalnum/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isalnum/out.sql index 02e0094742..ce0e0b43ae 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isalnum/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isalnum/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^(\\p{N}|\\p{L})+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^(\\p{N}|\\p{Lm}|\\p{Lt}|\\p{Lu}|\\p{Ll}|\\p{Lo})+$') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isalpha/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isalpha/out.sql index 2615d0452f..9337fa833e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isalpha/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isalpha/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\p{L}+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^(\\p{Lm}|\\p{Lt}|\\p{Lu}|\\p{Ll}|\\p{Lo})+$') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isdecimal/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isdecimal/out.sql index bc1fce3dbc..636c22b10e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isdecimal/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isdecimal/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\d+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^(\\p{Nd})+$') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isdigit/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isdigit/out.sql index 1cb3a883ab..dad052cf46 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isdigit/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isdigit/out.sql @@ -1,13 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\p{Nd}+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains( + `t0`.`string_col`, + '^[\\p{Nd}\\x{00B9}\\x{00B2}\\x{00B3}\\x{2070}\\x{2074}-\\x{2079}\\x{2080}-\\x{2089}]+$' + ) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_islower/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_islower/out.sql index a621b71a3b..3fab4372d0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_islower/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_islower/out.sql @@ -1,13 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LOWER(`bfcol_0`) = `bfcol_0` AND UPPER(`bfcol_0`) <> `bfcol_0` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '\\p{Ll}') + AND NOT ( + regexp_contains(`t0`.`string_col`, '\\p{Lu}|\\p{Lt}') + ) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isnull/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isnull/out.sql index 55a2ebb970..f4e234a031 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isnull/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isnull/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0` IS NULL AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`float64_col` IS NULL AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isnumeric/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isnumeric/out.sql index 6566c1dd4c..c73d06885c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isnumeric/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isnumeric/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\pN+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^(\\pN+)$') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_day/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_day/out.sql index d389172fda..5280f2da56 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_day/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_day/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(DAYOFWEEK FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(MOD(EXTRACT(dayofweek FROM `t0`.`timestamp_col`) + 5, 7) AS INT64) + 1 AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_week/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_week/out.sql index f22e963bc3..cd6fc0e998 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_week/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_week/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(ISOWEEK FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(isoweek FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_year/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_year/out.sql index 13b56f709c..3196f965db 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_year/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_iso_year/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(ISOYEAR FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + EXTRACT(isoyear FROM `t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isspace/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isspace/out.sql index aff12102be..df716e52a7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isspace/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isspace/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, '^\\s+$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '^\\s+$') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isupper/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isupper/out.sql index 03fe005910..aefa51ed9f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isupper/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_isupper/out.sql @@ -1,13 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UPPER(`bfcol_0`) = `bfcol_0` AND LOWER(`bfcol_0`) <> `bfcol_0` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, '\\p{Lu}') + AND NOT ( + regexp_contains(`t0`.`string_col`, '\\p{Ll}|\\p{Lt}') + ) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract/out.sql index 3d23bd1e3e..041b422ce0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract_array/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract_array/out.sql index 1ddb3999b3..642234e6f8 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract_array/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract_array/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT_ARRAY(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + JSON_EXTRACT_ARRAY(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract_string_array/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract_string_array/out.sql index cbc3df74c0..399845d647 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract_string_array/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_extract_string_array/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_EXTRACT_STRING_ARRAY(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_extract_string_array(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_query/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_query/out.sql index b5d98b80d2..fb27a4331e 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_query/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_query/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_QUERY(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_query(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_query_array/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_query_array/out.sql index 1b7a5908eb..71a2bfa148 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_query_array/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_query_array/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_QUERY_ARRAY(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_query_array(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_value/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_value/out.sql index 3a84a1a92a..519fd49755 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_value/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_json_value/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_VALUE(`bfcol_0`, '$') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + json_value(`t0`.`json_col`, '$') AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_len/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_len/out.sql index 35fd087bc7..2436e6d6a5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_len/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_len/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LENGTH(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + CAST(LENGTH(`t0`.`string_col`) AS INT64) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_ln/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_ln/out.sql index 1372c088d9..d2b75c0df1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_ln/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_ln/out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < 0 THEN CAST('NaN' AS FLOAT64) ELSE LN(`bfcol_0`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` > 0 + ), + IF(`t0`.`float64_col` = 0, CAST('-Infinity' AS FLOAT64), CAST('NaN' AS FLOAT64)), + LN(`t0`.`float64_col`) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_log10/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_log10/out.sql index b4cced439b..25566c269f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_log10/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_log10/out.sql @@ -1,13 +1,13 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < 0 THEN CAST('NaN' AS FLOAT64) ELSE LOG(10, `bfcol_0`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + `t0`.`float64_col` > 0 + ), + IF(`t0`.`float64_col` = 0, CAST('-Infinity' AS FLOAT64), CAST('NaN' AS FLOAT64)), + LOG(`t0`.`float64_col`, 10) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_log1p/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_log1p/out.sql index c3902ec174..3f761e7dbb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_log1p/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_log1p/out.sql @@ -1,13 +1,21 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < -1 THEN CAST('NaN' AS FLOAT64) ELSE LN(1 + `bfcol_0`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ( + 1 + `t0`.`float64_col` + ) > 0 + ), + IF( + ( + 1 + `t0`.`float64_col` + ) = 0, + CAST('-Infinity' AS FLOAT64), + CAST('NaN' AS FLOAT64) + ), + LN(1 + `t0`.`float64_col`) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_lower/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_lower/out.sql index e730cdee15..fefab3ffac 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_lower/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_lower/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - LOWER(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LOWER(`t0`.`string_col`) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_lstrip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_lstrip/out.sql index 49ed89b40b..4ae73b7a03 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_lstrip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_lstrip/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(`bfcol_0`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + LTRIM(`t0`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_minute/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_minute/out.sql index 4ef9b8142f..9959f5a8b1 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_minute/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_minute/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(MINUTE FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(minute FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_month/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_month/out.sql index 4912622898..303b9533f2 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_month/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_month/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(MONTH FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(month FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_neg/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_neg/out.sql index 46c58f766d..1c26f1325f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_neg/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_neg/out.sql @@ -1,13 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - -`bfcol_0` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + -( + `t0`.`float64_col` + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_normalize/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_normalize/out.sql index 3c7efd3098..8ba57a2771 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_normalize/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_normalize/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_TRUNC(`bfcol_0`, DAY) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(TIMESTAMP_TRUNC(`t0`.`timestamp_col`, DAY) AS TIMESTAMP) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_notnull/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_notnull/out.sql index c1961f9d62..67921f8516 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_notnull/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_notnull/out.sql @@ -1,13 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - NOT `bfcol_0` IS NULL AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + ( + `t0`.`float64_col` + ) IS NOT NULL AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_obj_fetch_metadata/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_obj_fetch_metadata/out.sql index 134fdc363b..6ae4d19c3f 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_obj_fetch_metadata/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_obj_fetch_metadata/out.sql @@ -1,25 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`bfcol_1`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - OBJ.FETCH_METADATA(`bfcol_4`) AS `bfcol_7` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - `bfcol_7`.`version` AS `bfcol_10` - FROM `bfcte_2` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_10` AS `version` -FROM `bfcte_3` \ No newline at end of file + `t0`.`rowindex`, + `OBJ.FETCH_METADATA`( + `OBJ.MAKE_REF`(`t0`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection') + ).`version` AS `version` +FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_obj_get_access_url/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_obj_get_access_url/out.sql index 4a963b4972..de65296b53 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_obj_get_access_url/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_obj_get_access_url/out.sql @@ -1,25 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - OBJ.MAKE_REF(`bfcol_1`, 'bigframes-dev.test-region.bigframes-default-connection') AS `bfcol_4` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - OBJ.GET_ACCESS_URL(`bfcol_4`) AS `bfcol_7` - FROM `bfcte_1` -), `bfcte_3` AS ( - SELECT - *, - JSON_VALUE(`bfcol_7`, '$.access_urls.read_url') AS `bfcol_10` - FROM `bfcte_2` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_10` AS `string_col` -FROM `bfcte_3` \ No newline at end of file + `t0`.`rowindex`, + json_value( + `OBJ.GET_ACCESS_URL`( + `OBJ.MAKE_REF`(`t0`.`string_col`, 'bigframes-dev.test-region.bigframes-default-connection'), + 'R' + ), + '$.access_urls.read_url' + ) AS `string_col` +FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_parse_json/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_parse_json/out.sql index cdb091ae39..15b9e1273a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_parse_json/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_parse_json/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - PARSE_JSON(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + PARSE_JSON(`t0`.`string_col`) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_pos/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_pos/out.sql index 2d6322a182..dcf5365f29 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_pos/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_pos/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_quarter/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_quarter/out.sql index 2be2866661..005c01120b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_quarter/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_quarter/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(QUARTER FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(quarter FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_reverse/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_reverse/out.sql index 1ef1074149..8917b27122 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_reverse/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_reverse/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REVERSE(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + reverse(`t0`.`string_col`) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_rstrip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_rstrip/out.sql index 49ed89b40b..21e7ed7cdb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_rstrip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_rstrip/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(`bfcol_0`, ' ') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + RTRIM(`t0`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_second/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_second/out.sql index 144b704788..6c0085b3df 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_second/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_second/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(SECOND FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(second FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sin/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sin/out.sql index 62a5cff0b5..1f8a1066e8 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sin/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sin/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SIN(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + sin(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sinh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sinh/out.sql index 711dba94a9..85579150c9 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sinh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sinh/out.sql @@ -1,17 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN ABS(`bfcol_0`) > 709.78 - THEN SIGN(`bfcol_0`) * CAST('Infinity' AS FLOAT64) - ELSE SINH(`bfcol_0`) - END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) < 709.78 + ), + CAST('Infinity' AS FLOAT64) * SIGN(`t0`.`float64_col`), + ieee_divide(EXP(`t0`.`float64_col`) - EXP(-( + `t0`.`float64_col` + )), 2) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sqrt/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sqrt/out.sql index e6a93e5e6c..c742123beb 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sqrt/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_sqrt/out.sql @@ -1,13 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE WHEN `bfcol_0` < 0 THEN CAST('NaN' AS FLOAT64) ELSE SQRT(`bfcol_0`) END AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF(NOT ( + `t0`.`float64_col` >= 0 + ), CAST('NaN' AS FLOAT64), SQRT(`t0`.`float64_col`)) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_contains/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_contains/out.sql index a1aa0539ee..614ee98517 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_contains/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_contains/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0` LIKE '%e%' AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + INSTR(`t0`.`string_col`, 'e') > 0 AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_contains_regex/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_contains_regex/out.sql index d0383172cb..8dcba9682a 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_contains_regex/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_contains_regex/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - REGEXP_CONTAINS(`bfcol_0`, 'e') AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + regexp_contains(`t0`.`string_col`, 'e') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_get/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_get/out.sql index 1278c3435d..93819bc1d8 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_get/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_get/out.sql @@ -1,13 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SUBSTRING(`bfcol_0`, 2, 1) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + NULLIF( + SUBSTRING(`t0`.`string_col`, IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(`t0`.`string_col`)), 1), + '' + ) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_slice/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_slice/out.sql index 4f97ab3ac6..ab438d41d3 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_slice/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_str_slice/out.sql @@ -1,13 +1,9 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - SUBSTRING(`bfcol_0`, 2, 2) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + SUBSTRING(`t0`.`string_col`, IF(( + 1 + 1 + ) >= 1, 1 + 1, 1 + 1 + LENGTH(`t0`.`string_col`)), 2) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_strftime/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_strftime/out.sql index 077c30e7cb..256baf4d99 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_strftime/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_strftime/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FORMAT_TIMESTAMP('%Y-%m-%d', `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + format_timestamp('%Y-%m-%d', `t0`.`timestamp_col`, 'UTC') AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_strip/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_strip/out.sql index 311f2c1727..44c2ed4b45 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_strip/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_strip/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TRIM(' ', `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + TRIM(`t0`.`string_col`, ' ') AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_struct_field/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_struct_field/out.sql index b3e8fde0b2..36a188f87d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_struct_field/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_struct_field/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `people` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_0`.`name` AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `people` -FROM `bfcte_1` \ No newline at end of file + `t0`.`people`.`name` AS `people` +FROM ( + SELECT + `people` + FROM `bigframes-dev.sqlglot_test.nested_structs_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.907430') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_tan/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_tan/out.sql index 5fac274b6b..73c3d7d1f5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_tan/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_tan/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TAN(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + tan(`t0`.`float64_col`) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_tanh/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_tanh/out.sql index 5d1a5a5320..6b177497e7 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_tanh/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_tanh/out.sql @@ -1,13 +1,20 @@ -WITH `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TANH(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `float64_col` -FROM `bfcte_1` \ No newline at end of file + IF( + NOT ( + ABS(`t0`.`float64_col`) < 20 + ), + SIGN(`t0`.`float64_col`), + ieee_divide( + EXP(`t0`.`float64_col`) - EXP(-( + `t0`.`float64_col` + )), + EXP(`t0`.`float64_col`) + EXP(-( + `t0`.`float64_col` + )) + ) + ) AS `float64_col` +FROM ( + SELECT + `float64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_time/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_time/out.sql index 6b74efafd5..2ec06db03b 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_time/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_time/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIME(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + TIME(`t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_timedelta_floor/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_timedelta_floor/out.sql index 1a8b9f4e39..3f372008d5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_timedelta_floor/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_timedelta_floor/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - FLOOR(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CAST(FLOOR(`t0`.`int64_col`) AS INT64) AS `int64_col` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_datetime/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_datetime/out.sql index 096f14cc85..2593ebdcb5 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_datetime/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_datetime/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CAST(TIMESTAMP_SECONDS(`bfcol_0`) AS DATETIME) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CAST(CAST(timestamp_micros(CAST(trunc(`t0`.`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS DATETIME) AS `int64_col` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_json_string/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_json_string/out.sql index 2786973933..8b9f5648a8 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_json_string/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_json_string/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `json_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - TO_JSON_STRING(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `json_col` -FROM `bfcte_1` \ No newline at end of file + to_json_string(`t0`.`json_col`) AS `json_col` +FROM ( + SELECT + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_timedelta/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_timedelta/out.sql index b89056d65f..f047151d05 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_timedelta/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_timedelta/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - INTERVAL `bfcol_0` SECOND AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CAST(FLOOR(`t0`.`int64_col` * 1000000) AS INT64) AS `int64_col` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_timestamp/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_timestamp/out.sql index b1e66ce3e7..d1feb0c0be 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_timestamp/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_to_timestamp/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - TIMESTAMP_SECONDS(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + CAST(timestamp_micros(CAST(trunc(`t0`.`int64_col` * 0.001) AS INT64)) AS TIMESTAMP) AS `int64_col` +FROM ( + SELECT + `int64_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_micros/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_micros/out.sql index dcbf0be5c2..213576fab0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_micros/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_micros/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MICROS(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + unix_micros(`t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_millis/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_millis/out.sql index ca58fbc97c..f5a89c91f0 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_millis/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_millis/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_MILLIS(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + unix_millis(`t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_seconds/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_seconds/out.sql index 21f0b7b8c8..7f6649636d 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_seconds/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_unix_seconds/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UNIX_SECONDS(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + UNIX_SECONDS(`t0`.`timestamp_col`) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_upper/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_upper/out.sql index d22c8cff5a..c0bab374dc 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_upper/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_upper/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `string_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - UPPER(`bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + UPPER(`t0`.`string_col`) AS `string_col` +FROM ( + SELECT + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_year/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_year/out.sql index 8352a65e9e..0a8ad9ec47 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_year/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_unary_compiler/test_year/out.sql @@ -1,13 +1,7 @@ -WITH `bfcte_0` AS ( - SELECT - `timestamp_col` AS `bfcol_0` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - EXTRACT(YEAR FROM `bfcol_0`) AS `bfcol_1` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `timestamp_col` -FROM `bfcte_1` \ No newline at end of file + CAST(EXTRACT(year FROM `t0`.`timestamp_col`) AS INT64) AS `timestamp_col` +FROM ( + SELECT + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate/out.sql index 02bba41a22..d4deeaccfe 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate/out.sql @@ -1,27 +1,30 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_too` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_0` -), `bfcte_2` AS ( +SELECT +`bool_col` AS `bool_col`, +`int64_too` AS `int64_too` +FROM +(SELECT + `t2`.`bfuid_col_330` AS `bool_col`, + `t2`.`bfuid_col_331` AS `int64_too` +FROM ( SELECT - `bfcol_3`, - COALESCE(SUM(`bfcol_2`), 0) AS `bfcol_6` - FROM `bfcte_1` - WHERE - NOT `bfcol_3` IS NULL + `t1`.`bfuid_col_330`, + COALESCE(SUM(`t1`.`bfuid_col_329`), 0) AS `bfuid_col_331` + FROM ( + SELECT + `t0`.`int64_too` AS `bfuid_col_329`, + `t0`.`bool_col` AS `bfuid_col_330` + FROM ( + SELECT + `bool_col`, + `int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` + ) AS `t1` GROUP BY - `bfcol_3` -) -SELECT - `bfcol_3` AS `bool_col`, - `bfcol_6` AS `int64_too` -FROM `bfcte_2` -ORDER BY - `bfcol_3` ASC NULLS LAST \ No newline at end of file + 1 +) AS `t2` +WHERE + ( + `t2`.`bfuid_col_330` + ) IS NOT NULL) +ORDER BY `bool_col` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql index b8e127eb77..433a824ce3 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_aggregate/test_compile_aggregate_wo_dropna/out.sql @@ -1,25 +1,26 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_too` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_0` -), `bfcte_2` AS ( +SELECT +`bool_col` AS `bool_col`, +`int64_too` AS `int64_too` +FROM +(SELECT + `t2`.`bfuid_col_334` AS `bool_col`, + `t2`.`bfuid_col_335` AS `int64_too` +FROM ( SELECT - `bfcol_3`, - COALESCE(SUM(`bfcol_2`), 0) AS `bfcol_6` - FROM `bfcte_1` + `t1`.`bfuid_col_334`, + COALESCE(SUM(`t1`.`bfuid_col_333`), 0) AS `bfuid_col_335` + FROM ( + SELECT + `t0`.`int64_too` AS `bfuid_col_333`, + `t0`.`bool_col` AS `bfuid_col_334` + FROM ( + SELECT + `bool_col`, + `int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` + ) AS `t1` GROUP BY - `bfcol_3` -) -SELECT - `bfcol_3` AS `bool_col`, - `bfcol_6` AS `int64_too` -FROM `bfcte_2` -ORDER BY - `bfcol_3` ASC NULLS LAST \ No newline at end of file + 1 +) AS `t2`) +ORDER BY `bool_col` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat/out.sql index 62e22a6a19..6683b59ca8 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_concat/test_compile_concat/out.sql @@ -1,78 +1,44 @@ -WITH `bfcte_1` AS ( - SELECT - * - FROM UNNEST(ARRAY>[STRUCT(0, 123456789, 0, 'Hello, World!', 0), STRUCT(1, -987654321, 1, 'こんにちは', 1), STRUCT(2, 314159, 2, ' ¡Hola Mundo! ', 2), STRUCT(3, CAST(NULL AS INT64), 3, CAST(NULL AS STRING), 3), STRUCT(4, -234892, 4, 'Hello, World!', 4), STRUCT(5, 55555, 5, 'Güten Tag!', 5), STRUCT(6, 101202303, 6, 'capitalize, This ', 6), STRUCT(7, -214748367, 7, ' سلام', 7), STRUCT(8, 2, 8, 'T', 8)]) -), `bfcte_3` AS ( - SELECT - *, - `bfcol_4` AS `bfcol_10` - FROM `bfcte_1` -), `bfcte_5` AS ( - SELECT - *, - 0 AS `bfcol_16` - FROM `bfcte_3` -), `bfcte_6` AS ( - SELECT - `bfcol_0` AS `bfcol_17`, - `bfcol_2` AS `bfcol_18`, - `bfcol_1` AS `bfcol_19`, - `bfcol_3` AS `bfcol_20`, - `bfcol_16` AS `bfcol_21`, - `bfcol_10` AS `bfcol_22` - FROM `bfcte_5` -), `bfcte_0` AS ( +SELECT +`rowindex` AS `rowindex`, +`rowindex_1` AS `rowindex_1`, +`int64_col` AS `int64_col`, +`string_col` AS `string_col` +FROM +(SELECT + * +FROM ( SELECT * - FROM UNNEST(ARRAY>[STRUCT(0, 123456789, 0, 'Hello, World!', 0), STRUCT(1, -987654321, 1, 'こんにちは', 1), STRUCT(2, 314159, 2, ' ¡Hola Mundo! ', 2), STRUCT(3, CAST(NULL AS INT64), 3, CAST(NULL AS STRING), 3), STRUCT(4, -234892, 4, 'Hello, World!', 4), STRUCT(5, 55555, 5, 'Güten Tag!', 5), STRUCT(6, 101202303, 6, 'capitalize, This ', 6), STRUCT(7, -214748367, 7, ' سلام', 7), STRUCT(8, 2, 8, 'T', 8)]) -), `bfcte_2` AS ( - SELECT - *, - `bfcol_27` AS `bfcol_33` - FROM `bfcte_0` -), `bfcte_4` AS ( - SELECT - *, - 1 AS `bfcol_39` - FROM `bfcte_2` -), `bfcte_7` AS ( - SELECT - `bfcol_23` AS `bfcol_40`, - `bfcol_25` AS `bfcol_41`, - `bfcol_24` AS `bfcol_42`, - `bfcol_26` AS `bfcol_43`, - `bfcol_39` AS `bfcol_44`, - `bfcol_33` AS `bfcol_45` - FROM `bfcte_4` -), `bfcte_8` AS ( + FROM ( + SELECT + `t0`.`level_0` AS `rowindex`, + `t0`.`column_9` AS `rowindex_1`, + `t0`.`column_5` AS `int64_col`, + `t0`.`column_11` AS `string_col`, + 0 AS `bfuid_col_347`, + `t0`.`bfuid_col_340` AS `bfuid_col_346` + FROM ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(0, 123456789, 0, 'Hello, World!', 0), STRUCT(1, -987654321, 1, 'こんにちは', 1), STRUCT(2, 314159, 2, ' ¡Hola Mundo! ', 2), STRUCT(3, CAST(NULL AS INT64), 3, CAST(NULL AS STRING), 3), STRUCT(4, -234892, 4, 'Hello, World!', 4), STRUCT(5, 55555, 5, 'Güten Tag!', 5), STRUCT(6, 101202303, 6, 'capitalize, This ', 6), STRUCT(7, -214748367, 7, ' سلام', 7), STRUCT(8, 2, 8, 'T', 8)]) AS `level_0` + ) AS `t0` + ) AS `t1` + UNION ALL SELECT * FROM ( SELECT - `bfcol_17` AS `bfcol_46`, - `bfcol_18` AS `bfcol_47`, - `bfcol_19` AS `bfcol_48`, - `bfcol_20` AS `bfcol_49`, - `bfcol_21` AS `bfcol_50`, - `bfcol_22` AS `bfcol_51` - FROM `bfcte_6` - UNION ALL - SELECT - `bfcol_40` AS `bfcol_46`, - `bfcol_41` AS `bfcol_47`, - `bfcol_42` AS `bfcol_48`, - `bfcol_43` AS `bfcol_49`, - `bfcol_44` AS `bfcol_50`, - `bfcol_45` AS `bfcol_51` - FROM `bfcte_7` - ) -) -SELECT - `bfcol_46` AS `rowindex`, - `bfcol_47` AS `rowindex_1`, - `bfcol_48` AS `int64_col`, - `bfcol_49` AS `string_col` -FROM `bfcte_8` -ORDER BY - `bfcol_50` ASC NULLS LAST, - `bfcol_51` ASC NULLS LAST \ No newline at end of file + `t0`.`level_0` AS `rowindex`, + `t0`.`column_9` AS `rowindex_1`, + `t0`.`column_5` AS `int64_col`, + `t0`.`column_11` AS `string_col`, + 1 AS `bfuid_col_347`, + `t0`.`bfuid_col_340` AS `bfuid_col_346` + FROM ( + SELECT + * + FROM UNNEST(ARRAY>[STRUCT(0, 123456789, 0, 'Hello, World!', 0), STRUCT(1, -987654321, 1, 'こんにちは', 1), STRUCT(2, 314159, 2, ' ¡Hola Mundo! ', 2), STRUCT(3, CAST(NULL AS INT64), 3, CAST(NULL AS STRING), 3), STRUCT(4, -234892, 4, 'Hello, World!', 4), STRUCT(5, 55555, 5, 'Güten Tag!', 5), STRUCT(6, 101202303, 6, 'capitalize, This ', 6), STRUCT(7, -214748367, 7, ' سلام', 7), STRUCT(8, 2, 8, 'T', 8)]) AS `level_0` + ) AS `t0` + ) AS `t2` +) AS `t3`) +ORDER BY `bfuid_col_347` ASC NULLS LAST ,`bfuid_col_346` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql index 679da58f44..f6f22c065d 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_dataframe/out.sql @@ -1,21 +1,65 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `int_list_col` AS `bfcol_1`, - `string_list_col` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - * - REPLACE (`bfcol_1`[SAFE_OFFSET(`bfcol_13`)] AS `bfcol_1`, `bfcol_2`[SAFE_OFFSET(`bfcol_13`)] AS `bfcol_2`) - FROM `bfcte_0` - CROSS JOIN UNNEST(GENERATE_ARRAY(0, LEAST(ARRAY_LENGTH(`bfcol_1`) - 1, ARRAY_LENGTH(`bfcol_2`) - 1))) AS `bfcol_13` WITH OFFSET AS `bfcol_7` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_0` AS `rowindex_1`, - `bfcol_1` AS `int_list_col`, - `bfcol_2` AS `string_list_col` -FROM `bfcte_1` -ORDER BY - `bfcol_7` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`rowindex_1` AS `rowindex_1`, +`int_list_col` AS `int_list_col`, +`string_list_col` AS `string_list_col` +FROM +(SELECT + `t2`.`bfuid_col_251` AS `rowindex`, + `t2`.`rowindex` AS `rowindex_1`, + `t2`.`int_list_col`[safe_offset(`t2`.`bfuid_col_351`)] AS `int_list_col`, + `t2`.`string_list_col`[safe_offset(`t2`.`bfuid_col_351`)] AS `string_list_col`, + `t2`.`bfuid_col_351` AS `bfuid_col_352` +FROM ( + SELECT + IF(pos = pos_2, `bfuid_col_351`, NULL) AS `bfuid_col_351`, + `t1`.`bfuid_col_251`, + `t1`.`rowindex`, + `t1`.`int_list_col`, + `t1`.`string_list_col` + FROM ( + SELECT + IF( + NOT NULLIF(1, 0) IS NULL + AND SIGN(1) = SIGN( + GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`), ARRAY_LENGTH(`t0`.`string_list_col`))) - 0 + ), + ARRAY( + SELECT + ibis_bq_arr_range_wexsb7vmnrdu3deb7fbv2elode + FROM UNNEST(generate_array( + 0, + GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`), ARRAY_LENGTH(`t0`.`string_list_col`))), + 1 + )) AS ibis_bq_arr_range_wexsb7vmnrdu3deb7fbv2elode + WHERE + ibis_bq_arr_range_wexsb7vmnrdu3deb7fbv2elode <> GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`), ARRAY_LENGTH(`t0`.`string_list_col`))) + ), + [] + ) AS `bfuid_offset_array_353`, + `t0`.`rowindex` AS `bfuid_col_251`, + `t0`.`rowindex`, + `t0`.`int_list_col`, + `t0`.`string_list_col` + FROM ( + SELECT + `rowindex`, + `int_list_col`, + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.046629') + ) AS `t0` + ) AS `t1` + CROSS JOIN UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(`t1`.`bfuid_offset_array_353`)) - 1)) AS pos + CROSS JOIN UNNEST(`t1`.`bfuid_offset_array_353`) AS `bfuid_col_351` WITH OFFSET AS pos_2 + WHERE + pos = pos_2 + OR ( + pos > ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_353`) - 1 + ) + AND pos_2 = ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_353`) - 1 + ) + ) +) AS `t2`) +ORDER BY `bfuid_col_352` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql index 8bfd1eb005..6eb391a6dc 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_explode/test_compile_explode_series/out.sql @@ -1,18 +1,50 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `int_list_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - * - REPLACE (`bfcol_8` AS `bfcol_1`) - FROM `bfcte_0` - CROSS JOIN UNNEST(`bfcol_1`) AS `bfcol_8` WITH OFFSET AS `bfcol_4` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `int_list_col` -FROM `bfcte_1` -ORDER BY - `bfcol_4` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int_list_col` AS `int_list_col` +FROM +(SELECT + `t2`.`bfuid_col_251` AS `rowindex`, + `t2`.`int_list_col`[safe_offset(`t2`.`bfuid_col_348`)] AS `int_list_col`, + `t2`.`bfuid_col_348` AS `bfuid_col_349` +FROM ( + SELECT + IF(pos = pos_2, `bfuid_col_348`, NULL) AS `bfuid_col_348`, + `t1`.`bfuid_col_251`, + `t1`.`int_list_col` + FROM ( + SELECT + IF( + NOT NULLIF(1, 0) IS NULL + AND SIGN(1) = SIGN(GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))) - 0), + ARRAY( + SELECT + ibis_bq_arr_range_4j5uth7kzfg4vidh5cp4lbqv2e + FROM UNNEST(generate_array(0, GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))), 1)) AS ibis_bq_arr_range_4j5uth7kzfg4vidh5cp4lbqv2e + WHERE + ibis_bq_arr_range_4j5uth7kzfg4vidh5cp4lbqv2e <> GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))) + ), + [] + ) AS `bfuid_offset_array_350`, + `t0`.`rowindex` AS `bfuid_col_251`, + `t0`.`int_list_col` + FROM ( + SELECT + `rowindex`, + `int_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.046629') + ) AS `t0` + ) AS `t1` + CROSS JOIN UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(`t1`.`bfuid_offset_array_350`)) - 1)) AS pos + CROSS JOIN UNNEST(`t1`.`bfuid_offset_array_350`) AS `bfuid_col_348` WITH OFFSET AS pos_2 + WHERE + pos = pos_2 + OR ( + pos > ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_350`) - 1 + ) + AND pos_2 = ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_350`) - 1 + ) + ) +) AS `t2`) +ORDER BY `bfuid_col_349` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql index 9ca7fb6a74..3e4721e497 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_filter/test_compile_filter/out.sql @@ -1,25 +1,12 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1` AS `bfcol_5`, - `bfcol_1` AS `bfcol_6`, - `bfcol_0` AS `bfcol_7`, - `bfcol_1` >= 1 AS `bfcol_8` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - * - FROM `bfcte_1` - WHERE - `bfcol_8` -) SELECT - `bfcol_5` AS `rowindex`, - `bfcol_6` AS `rowindex_1`, - `bfcol_7` AS `int64_col` -FROM `bfcte_2` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`rowindex` AS `rowindex_1`, + `t0`.`int64_col` +FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` +WHERE + `t0`.`rowindex` >= 1 \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join/out.sql index 04ee767f8a..d38ea34944 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join/out.sql @@ -1,32 +1,27 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_4`, - `int64_too` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t4`.`int64_col`, + `t5`.`int64_too` +FROM ( SELECT - `bfcol_4` AS `bfcol_6`, - `bfcol_5` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex` AS `bfuid_col_1`, + `t0`.`int64_col` + FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t4` +LEFT OUTER JOIN ( SELECT - * - FROM `bfcte_2` - LEFT JOIN `bfcte_3` - ON COALESCE(`bfcol_2`, 0) = COALESCE(`bfcol_6`, 0) - AND COALESCE(`bfcol_2`, 1) = COALESCE(`bfcol_6`, 1) -) -SELECT - `bfcol_3` AS `int64_col`, - `bfcol_7` AS `int64_too` -FROM `bfcte_4` \ No newline at end of file + `t1`.`int64_col` AS `bfuid_col_359`, + `t1`.`int64_too` + FROM ( + SELECT + `int64_col`, + `int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t1` +) AS `t5` + ON COALESCE(`t4`.`bfuid_col_1`, 0) = COALESCE(`t5`.`bfuid_col_359`, 0) + AND COALESCE(`t4`.`bfuid_col_1`, 1) = COALESCE(`t5`.`bfuid_col_359`, 1) \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/bool_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/bool_col/out.sql index 05d5fd0695..aa8f8fea14 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/bool_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/bool_col/out.sql @@ -1,33 +1,28 @@ -WITH `bfcte_1` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_4`, - `rowindex` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`bool_col`, + `t4`.`bfuid_col_362` AS `rowindex_y` +FROM ( SELECT - `bfcol_5` AS `bfcol_6`, - `bfcol_4` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`bool_col` + FROM ( + SELECT + `bool_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON COALESCE(CAST(`bfcol_3` AS STRING), '0') = COALESCE(CAST(`bfcol_7` AS STRING), '0') - AND COALESCE(CAST(`bfcol_3` AS STRING), '1') = COALESCE(CAST(`bfcol_7` AS STRING), '1') -) -SELECT - `bfcol_2` AS `rowindex_x`, - `bfcol_3` AS `bool_col`, - `bfcol_6` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_362`, + `t0`.`bool_col` AS `bfuid_col_363` + FROM ( + SELECT + `bool_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t4` + ON COALESCE(CAST(`t3`.`bool_col` AS STRING), '0') = COALESCE(CAST(`t4`.`bfuid_col_363` AS STRING), '0') + AND COALESCE(CAST(`t3`.`bool_col` AS STRING), '1') = COALESCE(CAST(`t4`.`bfuid_col_363` AS STRING), '1') \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/float64_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/float64_col/out.sql index 9e6a4094b2..c69daabf40 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/float64_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/float64_col/out.sql @@ -1,33 +1,28 @@ -WITH `bfcte_1` AS ( - SELECT - `float64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `float64_col` AS `bfcol_4`, - `rowindex` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`float64_col`, + `t4`.`bfuid_col_368` AS `rowindex_y` +FROM ( SELECT - `bfcol_5` AS `bfcol_6`, - `bfcol_4` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`float64_col` + FROM ( + SELECT + `float64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON IF(IS_NAN(`bfcol_3`), 2, COALESCE(`bfcol_3`, 0)) = IF(IS_NAN(`bfcol_7`), 2, COALESCE(`bfcol_7`, 0)) - AND IF(IS_NAN(`bfcol_3`), 3, COALESCE(`bfcol_3`, 1)) = IF(IS_NAN(`bfcol_7`), 3, COALESCE(`bfcol_7`, 1)) -) -SELECT - `bfcol_2` AS `rowindex_x`, - `bfcol_3` AS `float64_col`, - `bfcol_6` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_368`, + `t0`.`float64_col` AS `bfuid_col_369` + FROM ( + SELECT + `float64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t4` + ON IF(IS_NAN(`t3`.`float64_col`), 2, COALESCE(`t3`.`float64_col`, 0)) = IF(IS_NAN(`t4`.`bfuid_col_369`), 2, COALESCE(`t4`.`bfuid_col_369`, 0)) + AND IF(IS_NAN(`t3`.`float64_col`), 3, COALESCE(`t3`.`float64_col`, 1)) = IF(IS_NAN(`t4`.`bfuid_col_369`), 3, COALESCE(`t4`.`bfuid_col_369`, 1)) \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/int64_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/int64_col/out.sql index bd03e05cba..9f725bf0d0 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/int64_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/int64_col/out.sql @@ -1,33 +1,28 @@ -WITH `bfcte_1` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_4`, - `rowindex` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`int64_col`, + `t4`.`bfuid_col_365` AS `rowindex_y` +FROM ( SELECT - `bfcol_5` AS `bfcol_6`, - `bfcol_4` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`int64_col` + FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON COALESCE(`bfcol_3`, 0) = COALESCE(`bfcol_7`, 0) - AND COALESCE(`bfcol_3`, 1) = COALESCE(`bfcol_7`, 1) -) -SELECT - `bfcol_2` AS `rowindex_x`, - `bfcol_3` AS `int64_col`, - `bfcol_6` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_365`, + `t0`.`int64_col` AS `bfuid_col_366` + FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t4` + ON COALESCE(`t3`.`int64_col`, 0) = COALESCE(`t4`.`bfuid_col_366`, 0) + AND COALESCE(`t3`.`int64_col`, 1) = COALESCE(`t4`.`bfuid_col_366`, 1) \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/numeric_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/numeric_col/out.sql index 6b77ead97c..b56d0682c6 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/numeric_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/numeric_col/out.sql @@ -1,33 +1,28 @@ -WITH `bfcte_1` AS ( - SELECT - `numeric_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( - SELECT - `bfcol_1` AS `bfcol_2`, - `bfcol_0` AS `bfcol_3` - FROM `bfcte_1` -), `bfcte_0` AS ( - SELECT - `numeric_col` AS `bfcol_4`, - `rowindex` AS `bfcol_5` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_3` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`numeric_col`, + `t4`.`bfuid_col_377` AS `rowindex_y` +FROM ( SELECT - `bfcol_5` AS `bfcol_6`, - `bfcol_4` AS `bfcol_7` - FROM `bfcte_0` -), `bfcte_4` AS ( + `t0`.`rowindex`, + `t0`.`numeric_col` + FROM ( + SELECT + `numeric_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_2` - INNER JOIN `bfcte_3` - ON COALESCE(`bfcol_3`, CAST(0 AS NUMERIC)) = COALESCE(`bfcol_7`, CAST(0 AS NUMERIC)) - AND COALESCE(`bfcol_3`, CAST(1 AS NUMERIC)) = COALESCE(`bfcol_7`, CAST(1 AS NUMERIC)) -) -SELECT - `bfcol_2` AS `rowindex_x`, - `bfcol_3` AS `numeric_col`, - `bfcol_6` AS `rowindex_y` -FROM `bfcte_4` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_377`, + `t0`.`numeric_col` AS `bfuid_col_378` + FROM ( + SELECT + `numeric_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t4` + ON COALESCE(`t3`.`numeric_col`, 0) = COALESCE(`t4`.`bfuid_col_378`, 0) + AND COALESCE(`t3`.`numeric_col`, 1) = COALESCE(`t4`.`bfuid_col_378`, 1) \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/string_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/string_col/out.sql index 1903d5fc22..ced9c53c7f 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/string_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/string_col/out.sql @@ -1,28 +1,28 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `string_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`string_col`, + `t4`.`bfuid_col_371` AS `rowindex_y` +FROM ( SELECT - `bfcol_2` AS `bfcol_4`, - `bfcol_3` AS `bfcol_5` - FROM `bfcte_0` -), `bfcte_3` AS ( + `t0`.`rowindex`, + `t0`.`string_col` + FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_1` - INNER JOIN `bfcte_2` - ON COALESCE(CAST(`bfcol_1` AS STRING), '0') = COALESCE(CAST(`bfcol_5` AS STRING), '0') - AND COALESCE(CAST(`bfcol_1` AS STRING), '1') = COALESCE(CAST(`bfcol_5` AS STRING), '1') -) -SELECT - `bfcol_0` AS `rowindex_x`, - `bfcol_1` AS `string_col`, - `bfcol_4` AS `rowindex_y` -FROM `bfcte_3` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_371`, + `t0`.`string_col` AS `bfuid_col_372` + FROM ( + SELECT + `rowindex`, + `string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t4` + ON COALESCE(`t3`.`string_col`, '0') = COALESCE(`t4`.`bfuid_col_372`, '0') + AND COALESCE(`t3`.`string_col`, '1') = COALESCE(`t4`.`bfuid_col_372`, '1') \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/time_col/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/time_col/out.sql index 9e3477d4a9..35b51e7f7d 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/time_col/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_join/test_compile_join_w_on/time_col/out.sql @@ -1,28 +1,28 @@ -WITH `bfcte_1` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `time_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_2`, - `time_col` AS `bfcol_3` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_2` AS ( +SELECT + `t3`.`rowindex` AS `rowindex_x`, + `t3`.`time_col`, + `t4`.`bfuid_col_374` AS `rowindex_y` +FROM ( SELECT - `bfcol_2` AS `bfcol_4`, - `bfcol_3` AS `bfcol_5` - FROM `bfcte_0` -), `bfcte_3` AS ( + `t0`.`rowindex`, + `t0`.`time_col` + FROM ( + SELECT + `rowindex`, + `time_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t3` +INNER JOIN ( SELECT - * - FROM `bfcte_1` - INNER JOIN `bfcte_2` - ON COALESCE(CAST(`bfcol_1` AS STRING), '0') = COALESCE(CAST(`bfcol_5` AS STRING), '0') - AND COALESCE(CAST(`bfcol_1` AS STRING), '1') = COALESCE(CAST(`bfcol_5` AS STRING), '1') -) -SELECT - `bfcol_0` AS `rowindex_x`, - `bfcol_1` AS `time_col`, - `bfcol_4` AS `rowindex_y` -FROM `bfcte_3` \ No newline at end of file + `t0`.`rowindex` AS `bfuid_col_374`, + `t0`.`time_col` AS `bfuid_col_375` + FROM ( + SELECT + `rowindex`, + `time_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` +) AS `t4` + ON COALESCE(CAST(`t3`.`time_col` AS STRING), '0') = COALESCE(CAST(`t4`.`bfuid_col_375` AS STRING), '0') + AND COALESCE(CAST(`t3`.`time_col` AS STRING), '1') = COALESCE(CAST(`t4`.`bfuid_col_375` AS STRING), '1') \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal/out.sql index 2b080b0b7c..4c5f930117 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal/out.sql @@ -1,63 +1,99 @@ -WITH `bfcte_0` AS ( +SELECT +`rowindex` AS `rowindex`, +`bool_col` AS `bool_col`, +`bytes_col` AS `bytes_col`, +`date_col` AS `date_col`, +`datetime_col` AS `datetime_col`, +`geography_col` AS `geography_col`, +`int64_col` AS `int64_col`, +`int64_too` AS `int64_too`, +`numeric_col` AS `numeric_col`, +`float64_col` AS `float64_col`, +`rowindex_1` AS `rowindex_1`, +`rowindex_2` AS `rowindex_2`, +`string_col` AS `string_col`, +`time_col` AS `time_col`, +`timestamp_col` AS `timestamp_col`, +`duration_col` AS `duration_col` +FROM +(SELECT + `t0`.`level_0` AS `rowindex`, + `t0`.`column_0` AS `bool_col`, + `t0`.`column_1` AS `bytes_col`, + `t0`.`column_2` AS `date_col`, + `t0`.`column_3` AS `datetime_col`, + `t0`.`column_4` AS `geography_col`, + `t0`.`column_5` AS `int64_col`, + `t0`.`column_6` AS `int64_too`, + `t0`.`column_7` AS `numeric_col`, + `t0`.`column_8` AS `float64_col`, + `t0`.`column_9` AS `rowindex_1`, + `t0`.`column_10` AS `rowindex_2`, + `t0`.`column_11` AS `string_col`, + `t0`.`column_12` AS `time_col`, + `t0`.`column_13` AS `timestamp_col`, + `t0`.`column_14` AS `duration_col`, + `t0`.`bfuid_col_380` AS `bfuid_col_381` +FROM ( SELECT * - FROM UNNEST(ARRAY>[STRUCT( + FROM UNNEST(ARRAY>[STRUCT( 0, TRUE, - CAST(b'Hello, World!' AS BYTES), - CAST('2021-07-21' AS DATE), - CAST('2021-07-21T11:39:45' AS DATETIME), - ST_GEOGFROMTEXT('POINT(-122.0838511 37.3860517)'), + CAST('48656c6c6f2c20576f726c6421' AS BYTES FORMAT 'HEX'), + DATE(2021, 7, 21), + DATETIME('2021-07-21T11:39:45'), + st_geogfromtext('POINT(-122.0838511 37.3860517)'), 123456789, 0, - CAST(1.234567890 AS NUMERIC), + CAST('1.234567890' AS NUMERIC), 1.25, 0, 0, 'Hello, World!', - CAST('11:41:43.076160' AS TIME), - CAST('2021-07-21T17:43:43.945289+00:00' AS TIMESTAMP), + TIME_ADD(TIME(11, 41, 43), INTERVAL 76160 MICROSECOND), + TIMESTAMP('2021-07-21T17:43:43.945289+00:00'), 4, 0 ), STRUCT( 1, FALSE, - CAST(b'\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf' AS BYTES), - CAST('1991-02-03' AS DATE), - CAST('1991-01-02T03:45:06' AS DATETIME), - ST_GEOGFROMTEXT('POINT(-71.104 42.315)'), + CAST('e38193e38293e381abe381a1e381af' AS BYTES FORMAT 'HEX'), + DATE(1991, 2, 3), + DATETIME('1991-01-02T03:45:06'), + st_geogfromtext('POINT(-71.104 42.315)'), -987654321, 1, - CAST(1.234567890 AS NUMERIC), + CAST('1.234567890' AS NUMERIC), 2.51, 1, 1, 'こんにちは', - CAST('11:14:34.701606' AS TIME), - CAST('2021-07-21T17:43:43.945289+00:00' AS TIMESTAMP), + TIME_ADD(TIME(11, 14, 34), INTERVAL 701606 MICROSECOND), + TIMESTAMP('2021-07-21T17:43:43.945289+00:00'), -1000000, 1 ), STRUCT( 2, TRUE, - CAST(b'\xc2\xa1Hola Mundo!' AS BYTES), - CAST('2023-03-01' AS DATE), - CAST('2023-03-01T10:55:13' AS DATETIME), - ST_GEOGFROMTEXT('POINT(-0.124474760143016 51.5007826749545)'), + CAST('c2a1486f6c61204d756e646f21' AS BYTES FORMAT 'HEX'), + DATE(2023, 3, 1), + DATETIME('2023-03-01T10:55:13'), + st_geogfromtext('POINT(-0.124474760143016 51.5007826749545)'), 314159, 0, - CAST(101.101010100 AS NUMERIC), + CAST('101.101010100' AS NUMERIC), 25000000000.0, 2, 2, ' ¡Hola Mundo! ', - CAST('23:59:59.999999' AS TIME), - CAST('2023-03-01T10:55:13.250125+00:00' AS TIMESTAMP), + TIME_ADD(TIME(23, 59, 59), INTERVAL 999999 MICROSECOND), + TIMESTAMP('2023-03-01T10:55:13.250125+00:00'), 0, 2 ), STRUCT( 3, - CAST(NULL AS BOOLEAN), + CAST(NULL AS BOOL), CAST(NULL AS BYTES), CAST(NULL AS DATE), CAST(NULL AS DATETIME), @@ -76,8 +112,8 @@ WITH `bfcte_0` AS ( ), STRUCT( 4, FALSE, - CAST(b'\xe3\x81\x93\xe3\x82\x93\xe3\x81\xab\xe3\x81\xa1\xe3\x81\xaf' AS BYTES), - CAST('2021-07-21' AS DATE), + CAST('e38193e38293e381abe381a1e381af' AS BYTES FORMAT 'HEX'), + DATE(2021, 7, 21), CAST(NULL AS DATETIME), CAST(NULL AS GEOGRAPHY), -234892, @@ -94,55 +130,55 @@ WITH `bfcte_0` AS ( ), STRUCT( 5, FALSE, - CAST(b'G\xc3\xbcten Tag' AS BYTES), - CAST('1980-03-14' AS DATE), - CAST('1980-03-14T15:16:17' AS DATETIME), + CAST('47c3bc74656e20546167' AS BYTES FORMAT 'HEX'), + DATE(1980, 3, 14), + DATETIME('1980-03-14T15:16:17'), CAST(NULL AS GEOGRAPHY), 55555, 0, - CAST(5.555555000 AS NUMERIC), + CAST('5.555555000' AS NUMERIC), 555.555, 5, 5, 'Güten Tag!', - CAST('15:16:17.181921' AS TIME), - CAST('1980-03-14T15:16:17.181921+00:00' AS TIMESTAMP), + TIME_ADD(TIME(15, 16, 17), INTERVAL 181921 MICROSECOND), + TIMESTAMP('1980-03-14T15:16:17.181921+00:00'), 4, 5 ), STRUCT( 6, TRUE, - CAST(b'Hello\tBigFrames!\x07' AS BYTES), - CAST('2023-05-23' AS DATE), - CAST('2023-05-23T11:37:01' AS DATETIME), - ST_GEOGFROMTEXT('LINESTRING(-0.127959 51.507728, -0.127026 51.507473)'), + CAST('48656c6c6f094269674672616d65732107' AS BYTES FORMAT 'HEX'), + DATE(2023, 5, 23), + DATETIME('2023-05-23T11:37:01'), + st_geogfromtext('LINESTRING(-0.127959 51.507728, -0.127026 51.507473)'), 101202303, 2, - CAST(-10.090807000 AS NUMERIC), + CAST('-10.090807000' AS NUMERIC), -123.456, 6, 6, 'capitalize, This ', - CAST('01:02:03.456789' AS TIME), - CAST('2023-05-23T11:42:55.000001+00:00' AS TIMESTAMP), + TIME_ADD(TIME(1, 2, 3), INTERVAL 456789 MICROSECOND), + TIMESTAMP('2023-05-23T11:42:55.000001+00:00'), CAST(NULL AS INT64), 6 ), STRUCT( 7, TRUE, CAST(NULL AS BYTES), - CAST('2038-01-20' AS DATE), - CAST('2038-01-19T03:14:08' AS DATETIME), + DATE(2038, 1, 20), + DATETIME('2038-01-19T03:14:08'), CAST(NULL AS GEOGRAPHY), -214748367, 2, - CAST(11111111.100000000 AS NUMERIC), + CAST('11111111.100000000' AS NUMERIC), 42.42, 7, 7, ' سلام', - CAST('12:00:00.000001' AS TIME), - CAST('2038-01-19T03:14:17.999999+00:00' AS TIMESTAMP), + TIME_ADD(TIME(12, 0, 0), INTERVAL 1 MICROSECOND), + TIMESTAMP('2038-01-19T03:14:17.999999+00:00'), 4, 7 ), STRUCT( @@ -163,25 +199,6 @@ WITH `bfcte_0` AS ( CAST(NULL AS TIMESTAMP), 432000000000, 8 - )]) -) -SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `bool_col`, - `bfcol_2` AS `bytes_col`, - `bfcol_3` AS `date_col`, - `bfcol_4` AS `datetime_col`, - `bfcol_5` AS `geography_col`, - `bfcol_6` AS `int64_col`, - `bfcol_7` AS `int64_too`, - `bfcol_8` AS `numeric_col`, - `bfcol_9` AS `float64_col`, - `bfcol_10` AS `rowindex_1`, - `bfcol_11` AS `rowindex_2`, - `bfcol_12` AS `string_col`, - `bfcol_13` AS `time_col`, - `bfcol_14` AS `timestamp_col`, - `bfcol_15` AS `duration_col` -FROM `bfcte_0` -ORDER BY - `bfcol_16` ASC NULLS LAST \ No newline at end of file + )]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_381` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_json_df/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_json_df/out.sql index 4e21266b87..ffec7f95df 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_json_df/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_json_df/out.sql @@ -1,11 +1,14 @@ -WITH `bfcte_0` AS ( +SELECT +`rowindex` AS `rowindex`, +`json_col` AS `json_col` +FROM +(SELECT + `t0`.`level_0` AS `rowindex`, + `t0`.`column_0` AS `json_col`, + `t0`.`bfuid_col_386` AS `bfuid_col_387` +FROM ( SELECT * - FROM UNNEST(ARRAY>[STRUCT(0, PARSE_JSON('null'), 0), STRUCT(1, PARSE_JSON('true'), 1), STRUCT(2, PARSE_JSON('100'), 2), STRUCT(3, PARSE_JSON('0.98'), 3), STRUCT(4, PARSE_JSON('"a string"'), 4), STRUCT(5, PARSE_JSON('[]'), 5), STRUCT(6, PARSE_JSON('[1,2,3]'), 6), STRUCT(7, PARSE_JSON('[{"a":1},{"a":2},{"a":null},{}]'), 7), STRUCT(8, PARSE_JSON('"100"'), 8), STRUCT(9, PARSE_JSON('{"date":"2024-07-16"}'), 9), STRUCT(10, PARSE_JSON('{"int_value":2,"null_filed":null}'), 10), STRUCT(11, PARSE_JSON('{"list_data":[10,20,30]}'), 11)]) -) -SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `json_col` -FROM `bfcte_0` -ORDER BY - `bfcol_2` ASC NULLS LAST \ No newline at end of file + FROM UNNEST(ARRAY>[STRUCT(0, PARSE_JSON('null'), 0), STRUCT(1, PARSE_JSON('true'), 1), STRUCT(2, PARSE_JSON('100'), 2), STRUCT(3, PARSE_JSON('0.98'), 3), STRUCT(4, PARSE_JSON('"a string"'), 4), STRUCT(5, PARSE_JSON('[]'), 5), STRUCT(6, PARSE_JSON('[1,2,3]'), 6), STRUCT(7, PARSE_JSON('[{"a":1},{"a":2},{"a":null},{}]'), 7), STRUCT(8, PARSE_JSON('"100"'), 8), STRUCT(9, PARSE_JSON('{"date":"2024-07-16"}'), 9), STRUCT(10, PARSE_JSON('{"int_value":2,"null_filed":null}'), 10), STRUCT(11, PARSE_JSON('{"list_data":[10,20,30]}'), 11)]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_387` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_lists_df/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_lists_df/out.sql index 923476aafd..751ba83a24 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_lists_df/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_lists_df/out.sql @@ -1,7 +1,27 @@ -WITH `bfcte_0` AS ( +SELECT +`rowindex` AS `rowindex`, +`int_list_col` AS `int_list_col`, +`bool_list_col` AS `bool_list_col`, +`float_list_col` AS `float_list_col`, +`date_list_col` AS `date_list_col`, +`date_time_list_col` AS `date_time_list_col`, +`numeric_list_col` AS `numeric_list_col`, +`string_list_col` AS `string_list_col` +FROM +(SELECT + `t0`.`level_0` AS `rowindex`, + `t0`.`column_0` AS `int_list_col`, + `t0`.`column_1` AS `bool_list_col`, + `t0`.`column_2` AS `float_list_col`, + `t0`.`column_3` AS `date_list_col`, + `t0`.`column_4` AS `date_time_list_col`, + `t0`.`column_5` AS `numeric_list_col`, + `t0`.`column_6` AS `string_list_col`, + `t0`.`bfuid_col_384` AS `bfuid_col_385` +FROM ( SELECT * - FROM UNNEST(ARRAY, `bfcol_2` ARRAY, `bfcol_3` ARRAY, `bfcol_4` ARRAY, `bfcol_5` ARRAY, `bfcol_6` ARRAY, `bfcol_7` ARRAY, `bfcol_8` INT64>>[STRUCT( + FROM UNNEST(ARRAY, `column_1` ARRAY, `column_2` ARRAY, `column_3` ARRAY, `column_4` ARRAY, `column_5` ARRAY, `column_6` ARRAY, `bfuid_col_384` INT64>>[STRUCT( 0, [1], [TRUE], @@ -31,17 +51,6 @@ WITH `bfcte_0` AS ( [1.7000000000000002], ['', 'a'], 2 - )]) -) -SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `int_list_col`, - `bfcol_2` AS `bool_list_col`, - `bfcol_3` AS `float_list_col`, - `bfcol_4` AS `date_list_col`, - `bfcol_5` AS `date_time_list_col`, - `bfcol_6` AS `numeric_list_col`, - `bfcol_7` AS `string_list_col` -FROM `bfcte_0` -ORDER BY - `bfcol_8` ASC NULLS LAST \ No newline at end of file + )]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_385` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_structs_df/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_structs_df/out.sql index 7ded9cf5ff..79ee35a2fb 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_structs_df/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readlocal/test_compile_readlocal_w_structs_df/out.sql @@ -1,7 +1,15 @@ -WITH `bfcte_0` AS ( +SELECT +`id` AS `id`, +`person` AS `person` +FROM +(SELECT + `t0`.`level_0` AS `id`, + `t0`.`column_0` AS `person`, + `t0`.`bfuid_col_382` AS `bfuid_col_383` +FROM ( SELECT * - FROM UNNEST(ARRAY>, `bfcol_2` INT64>>[STRUCT( + FROM UNNEST(ARRAY>, `bfuid_col_382` INT64>>[STRUCT( 1, STRUCT( 'Alice' AS `name`, @@ -17,11 +25,6 @@ WITH `bfcte_0` AS ( STRUCT('London' AS `city`, 'UK' AS `country`) AS `address` ), 1 - )]) -) -SELECT - `bfcol_0` AS `id`, - `bfcol_1` AS `person` -FROM `bfcte_0` -ORDER BY - `bfcol_2` ASC NULLS LAST \ No newline at end of file + )]) AS `level_0` +) AS `t0`) +ORDER BY `bfuid_col_383` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable/out.sql index 34fc8e3c49..6509f15adc 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable/out.sql @@ -1,35 +1,34 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `bytes_col` AS `bfcol_1`, - `date_col` AS `bfcol_2`, - `datetime_col` AS `bfcol_3`, - `geography_col` AS `bfcol_4`, - `int64_col` AS `bfcol_5`, - `int64_too` AS `bfcol_6`, - `numeric_col` AS `bfcol_7`, - `float64_col` AS `bfcol_8`, - `rowindex` AS `bfcol_9`, - `rowindex_2` AS `bfcol_10`, - `string_col` AS `bfcol_11`, - `time_col` AS `bfcol_12`, - `timestamp_col` AS `bfcol_13` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `bfcol_9` AS `rowindex`, - `bfcol_0` AS `bool_col`, - `bfcol_1` AS `bytes_col`, - `bfcol_2` AS `date_col`, - `bfcol_3` AS `datetime_col`, - `bfcol_4` AS `geography_col`, - `bfcol_5` AS `int64_col`, - `bfcol_6` AS `int64_too`, - `bfcol_7` AS `numeric_col`, - `bfcol_8` AS `float64_col`, - `bfcol_9` AS `rowindex_1`, - `bfcol_10` AS `rowindex_2`, - `bfcol_11` AS `string_col`, - `bfcol_12` AS `time_col`, - `bfcol_13` AS `timestamp_col` -FROM `bfcte_0` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`bool_col`, + `t0`.`bytes_col`, + `t0`.`date_col`, + `t0`.`datetime_col`, + `t0`.`geography_col`, + `t0`.`int64_col`, + `t0`.`int64_too`, + `t0`.`numeric_col`, + `t0`.`float64_col`, + `t0`.`rowindex` AS `rowindex_1`, + `t0`.`rowindex_2`, + `t0`.`string_col`, + `t0`.`time_col`, + `t0`.`timestamp_col` +FROM ( + SELECT + `bool_col`, + `bytes_col`, + `date_col`, + `datetime_col`, + `geography_col`, + `int64_col`, + `int64_too`, + `numeric_col`, + `float64_col`, + `rowindex`, + `rowindex_2`, + `string_col`, + `time_col`, + `timestamp_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_json_types/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_json_types/out.sql index 4e8f61d75d..69fd6191e5 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_json_types/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_json_types/out.sql @@ -1,10 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `json_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_1` AS `json_col` -FROM `bfcte_0` \ No newline at end of file + * +FROM ( + SELECT + `rowindex`, + `json_col` + FROM `bigframes-dev.sqlglot_test.json_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.661510') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_limit/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_limit/out.sql index f97eb7bf06..74283c74b2 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_limit/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_limit/out.sql @@ -1,13 +1,15 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_0` AS `int64_col` -FROM `bfcte_0` -ORDER BY - `bfcol_1` ASC NULLS LAST +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + `t0`.`int64_col` +FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0`) +ORDER BY `rowindex` ASC NULLS LAST LIMIT 10 \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql index 75c4a86e18..d1bb50cebd 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_nested_structs_types/out.sql @@ -1,11 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `id` AS `bfcol_0`, - `people` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`nested_structs_types` -) SELECT - `bfcol_0` AS `id`, - `bfcol_0` AS `id_1`, - `bfcol_1` AS `people` -FROM `bfcte_0` \ No newline at end of file + `t0`.`id`, + `t0`.`id` AS `id_1`, + `t0`.`people` +FROM ( + SELECT + `id`, + `people` + FROM `bigframes-dev.sqlglot_test.nested_structs_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.907430') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_ordering/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_ordering/out.sql index 6a16b98baa..ee023a4bfa 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_ordering/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_ordering/out.sql @@ -1,12 +1,14 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_0` AS `int64_col` -FROM `bfcte_0` -ORDER BY - `bfcol_0` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + `t0`.`int64_col` +FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0`) +ORDER BY `int64_col` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_repeated_types/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_repeated_types/out.sql index 2436c01a44..37ec8aa715 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_repeated_types/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_readtable/test_compile_readtable_w_repeated_types/out.sql @@ -1,23 +1,22 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `int_list_col` AS `bfcol_1`, - `bool_list_col` AS `bfcol_2`, - `float_list_col` AS `bfcol_3`, - `date_list_col` AS `bfcol_4`, - `date_time_list_col` AS `bfcol_5`, - `numeric_list_col` AS `bfcol_6`, - `string_list_col` AS `bfcol_7` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_0` AS `rowindex_1`, - `bfcol_1` AS `int_list_col`, - `bfcol_2` AS `bool_list_col`, - `bfcol_3` AS `float_list_col`, - `bfcol_4` AS `date_list_col`, - `bfcol_5` AS `date_time_list_col`, - `bfcol_6` AS `numeric_list_col`, - `bfcol_7` AS `string_list_col` -FROM `bfcte_0` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`rowindex` AS `rowindex_1`, + `t0`.`int_list_col`, + `t0`.`bool_list_col`, + `t0`.`float_list_col`, + `t0`.`date_list_col`, + `t0`.`date_time_list_col`, + `t0`.`numeric_list_col`, + `t0`.`string_list_col` +FROM ( + SELECT + `rowindex`, + `int_list_col`, + `bool_list_col`, + `float_list_col`, + `date_list_col`, + `date_time_list_col`, + `numeric_list_col`, + `string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:37.046629') +) AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql index beb3caa073..08b135bdb7 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_groupby_rolling/out.sql @@ -1,76 +1,88 @@ -WITH `bfcte_0` AS ( - SELECT - `bool_col` AS `bfcol_0`, - `int64_col` AS `bfcol_1`, - `rowindex` AS `bfcol_2` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_2` AS `bfcol_6`, - `bfcol_0` AS `bfcol_7`, - `bfcol_1` AS `bfcol_8`, - `bfcol_0` AS `bfcol_9` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - * - FROM `bfcte_1` - WHERE - NOT `bfcol_9` IS NULL -), `bfcte_3` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_7` IS NULL AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` IS NULL ASC NULLS LAST, `bfcol_9` ASC NULLS LAST, `bfcol_2` IS NULL ASC NULLS LAST, `bfcol_2` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(CAST(`bfcol_7` AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` IS NULL ASC NULLS LAST, `bfcol_9` ASC NULLS LAST, `bfcol_2` IS NULL ASC NULLS LAST, `bfcol_2` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_15` - FROM `bfcte_2` -), `bfcte_4` AS ( +SELECT +`bool_col` AS `bool_col`, +`rowindex` AS `rowindex`, +`bool_col_1` AS `bool_col_1`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t3`.`bfuid_col_392` AS `bool_col`, + `t3`.`bfuid_col_389` AS `rowindex`, + `t3`.`bfuid_col_393` AS `bool_col_1`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t3`.`bfuid_col_391` + ) IS NOT NULL AS INT64)) OVER ( + PARTITION BY `t3`.`bfuid_col_392` + ORDER BY `t3`.`bfuid_col_392` IS NULL ASC, `t3`.`bfuid_col_392` ASC, `t3`.`bfuid_col_398` IS NULL ASC, `t3`.`bfuid_col_398` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + ELSE COALESCE( + SUM(`t3`.`bfuid_col_391`) OVER ( + PARTITION BY `t3`.`bfuid_col_392` + ORDER BY `t3`.`bfuid_col_392` IS NULL ASC, `t3`.`bfuid_col_392` ASC, `t3`.`bfuid_col_398` IS NULL ASC, `t3`.`bfuid_col_398` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) + END AS `int64_col`, + `t3`.`bfuid_col_398` AS `bfuid_col_399` +FROM ( SELECT * - FROM `bfcte_3` + FROM ( + SELECT + `t1`.`bfuid_col_389`, + `t1`.`bfuid_col_391`, + `t1`.`bfuid_col_392`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t1`.`bfuid_col_390` + ) IS NOT NULL AS INT64)) OVER ( + PARTITION BY `t1`.`bfuid_col_392` + ORDER BY `t1`.`bfuid_col_392` IS NULL ASC, `t1`.`bfuid_col_392` ASC, `t1`.`bfuid_col_397` IS NULL ASC, `t1`.`bfuid_col_397` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + ELSE COALESCE( + SUM(CAST(`t1`.`bfuid_col_390` AS INT64)) OVER ( + PARTITION BY `t1`.`bfuid_col_392` + ORDER BY `t1`.`bfuid_col_392` IS NULL ASC, `t1`.`bfuid_col_392` ASC, `t1`.`bfuid_col_397` IS NULL ASC, `t1`.`bfuid_col_397` ASC + ROWS BETWEEN 3 preceding AND CURRENT ROW + ), + 0 + ) + END AS `bfuid_col_393`, + `t1`.`bfuid_col_397` AS `bfuid_col_398` + FROM ( + SELECT + `t0`.`rowindex` AS `bfuid_col_389`, + `t0`.`bool_col` AS `bfuid_col_390`, + `t0`.`int64_col` AS `bfuid_col_391`, + `t0`.`bool_col` AS `bfuid_col_392`, + `t0`.`rowindex` AS `bfuid_col_397` + FROM ( + SELECT + `bool_col`, + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') + ) AS `t0` + WHERE + ( + `t0`.`bool_col` + ) IS NOT NULL + ) AS `t1` + ) AS `t2` WHERE - NOT `bfcol_9` IS NULL -), `bfcte_5` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_8` IS NULL AS INT64)) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` IS NULL ASC NULLS LAST, `bfcol_9` ASC NULLS LAST, `bfcol_2` IS NULL ASC NULLS LAST, `bfcol_2` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_8`) OVER ( - PARTITION BY `bfcol_9` - ORDER BY `bfcol_9` IS NULL ASC NULLS LAST, `bfcol_9` ASC NULLS LAST, `bfcol_2` IS NULL ASC NULLS LAST, `bfcol_2` ASC NULLS LAST - ROWS BETWEEN 3 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_21` - FROM `bfcte_4` -) -SELECT - `bfcol_9` AS `bool_col`, - `bfcol_6` AS `rowindex`, - `bfcol_15` AS `bool_col_1`, - `bfcol_21` AS `int64_col` -FROM `bfcte_5` -ORDER BY - `bfcol_9` ASC NULLS LAST, - `bfcol_2` ASC NULLS LAST \ No newline at end of file + ( + `t2`.`bfuid_col_392` + ) IS NOT NULL +) AS `t3`) +ORDER BY `bool_col` ASC NULLS LAST ,`bfuid_col_399` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_min_periods/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_min_periods/out.sql index 5885f5ab3c..64af731dea 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_min_periods/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_min_periods/out.sql @@ -1,30 +1,32 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_0` IS NULL AS INT64)) OVER ( - ORDER BY `bfcol_1` IS NULL ASC NULLS LAST, `bfcol_1` ASC NULLS LAST - ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_0`) OVER ( - ORDER BY `bfcol_1` IS NULL ASC NULLS LAST, `bfcol_1` ASC NULLS LAST - ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_4` AS `int64_col` -FROM `bfcte_1` -ORDER BY - `bfcol_1` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t0`.`int64_col` + ) IS NOT NULL AS INT64)) OVER ( + ORDER BY `t0`.`rowindex` IS NULL ASC, `t0`.`rowindex` ASC + ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + ELSE COALESCE( + SUM(`t0`.`int64_col`) OVER ( + ORDER BY `t0`.`rowindex` IS NULL ASC, `t0`.`rowindex` ASC + ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW + ), + 0 + ) + END AS `int64_col` +FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0`) +ORDER BY `rowindex` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql index 581c81c6b4..cbd61f4701 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_range_rolling/out.sql @@ -1,30 +1,32 @@ -WITH `bfcte_0` AS ( +SELECT +`ts_col` AS `ts_col`, +`int_col` AS `int_col` +FROM +(SELECT + `t0`.`column_0` AS `ts_col`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t0`.`column_1` + ) IS NOT NULL AS INT64)) OVER ( + ORDER BY unix_micros(`t0`.`column_0`) ASC + RANGE BETWEEN 2999999 preceding AND CURRENT ROW + ), + 0 + ) < 1 + THEN NULL + ELSE COALESCE( + SUM(`t0`.`column_1`) OVER ( + ORDER BY unix_micros(`t0`.`column_0`) ASC + RANGE BETWEEN 2999999 preceding AND CURRENT ROW + ), + 0 + ) + END AS `int_col`, + `t0`.`bfuid_col_403` AS `bfuid_col_405` +FROM ( SELECT * - FROM UNNEST(ARRAY>[STRUCT(CAST('2025-01-01T00:00:00+00:00' AS TIMESTAMP), 0, 0), STRUCT(CAST('2025-01-01T00:00:01+00:00' AS TIMESTAMP), 1, 1), STRUCT(CAST('2025-01-01T00:00:02+00:00' AS TIMESTAMP), 2, 2), STRUCT(CAST('2025-01-01T00:00:03+00:00' AS TIMESTAMP), 3, 3), STRUCT(CAST('2025-01-01T00:00:04+00:00' AS TIMESTAMP), 0, 4), STRUCT(CAST('2025-01-01T00:00:05+00:00' AS TIMESTAMP), 1, 5), STRUCT(CAST('2025-01-01T00:00:06+00:00' AS TIMESTAMP), 2, 6), STRUCT(CAST('2025-01-01T00:00:07+00:00' AS TIMESTAMP), 3, 7), STRUCT(CAST('2025-01-01T00:00:08+00:00' AS TIMESTAMP), 0, 8), STRUCT(CAST('2025-01-01T00:00:09+00:00' AS TIMESTAMP), 1, 9), STRUCT(CAST('2025-01-01T00:00:10+00:00' AS TIMESTAMP), 2, 10), STRUCT(CAST('2025-01-01T00:00:11+00:00' AS TIMESTAMP), 3, 11), STRUCT(CAST('2025-01-01T00:00:12+00:00' AS TIMESTAMP), 0, 12), STRUCT(CAST('2025-01-01T00:00:13+00:00' AS TIMESTAMP), 1, 13), STRUCT(CAST('2025-01-01T00:00:14+00:00' AS TIMESTAMP), 2, 14), STRUCT(CAST('2025-01-01T00:00:15+00:00' AS TIMESTAMP), 3, 15), STRUCT(CAST('2025-01-01T00:00:16+00:00' AS TIMESTAMP), 0, 16), STRUCT(CAST('2025-01-01T00:00:17+00:00' AS TIMESTAMP), 1, 17), STRUCT(CAST('2025-01-01T00:00:18+00:00' AS TIMESTAMP), 2, 18), STRUCT(CAST('2025-01-01T00:00:19+00:00' AS TIMESTAMP), 3, 19)]) -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_1` IS NULL AS INT64)) OVER ( - ORDER BY UNIX_MICROS(`bfcol_0`) ASC NULLS LAST - RANGE BETWEEN 2999999 PRECEDING AND CURRENT ROW - ) < 1 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_1`) OVER ( - ORDER BY UNIX_MICROS(`bfcol_0`) ASC NULLS LAST - RANGE BETWEEN 2999999 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_6` - FROM `bfcte_0` -) -SELECT - `bfcol_0` AS `ts_col`, - `bfcol_6` AS `int_col` -FROM `bfcte_1` -ORDER BY - `bfcol_0` ASC NULLS LAST, - `bfcol_2` ASC NULLS LAST \ No newline at end of file + FROM UNNEST(ARRAY>[STRUCT(TIMESTAMP('2025-01-01T00:00:00+00:00'), 0, 0), STRUCT(TIMESTAMP('2025-01-01T00:00:01+00:00'), 1, 1), STRUCT(TIMESTAMP('2025-01-01T00:00:02+00:00'), 2, 2), STRUCT(TIMESTAMP('2025-01-01T00:00:03+00:00'), 3, 3), STRUCT(TIMESTAMP('2025-01-01T00:00:04+00:00'), 0, 4), STRUCT(TIMESTAMP('2025-01-01T00:00:05+00:00'), 1, 5), STRUCT(TIMESTAMP('2025-01-01T00:00:06+00:00'), 2, 6), STRUCT(TIMESTAMP('2025-01-01T00:00:07+00:00'), 3, 7), STRUCT(TIMESTAMP('2025-01-01T00:00:08+00:00'), 0, 8), STRUCT(TIMESTAMP('2025-01-01T00:00:09+00:00'), 1, 9), STRUCT(TIMESTAMP('2025-01-01T00:00:10+00:00'), 2, 10), STRUCT(TIMESTAMP('2025-01-01T00:00:11+00:00'), 3, 11), STRUCT(TIMESTAMP('2025-01-01T00:00:12+00:00'), 0, 12), STRUCT(TIMESTAMP('2025-01-01T00:00:13+00:00'), 1, 13), STRUCT(TIMESTAMP('2025-01-01T00:00:14+00:00'), 2, 14), STRUCT(TIMESTAMP('2025-01-01T00:00:15+00:00'), 3, 15), STRUCT(TIMESTAMP('2025-01-01T00:00:16+00:00'), 0, 16), STRUCT(TIMESTAMP('2025-01-01T00:00:17+00:00'), 1, 17), STRUCT(TIMESTAMP('2025-01-01T00:00:18+00:00'), 2, 18), STRUCT(TIMESTAMP('2025-01-01T00:00:19+00:00'), 3, 19)]) AS `column_0` +) AS `t0`) +ORDER BY `ts_col` ASC NULLS LAST ,`bfuid_col_405` ASC NULLS LAST \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_rolling/out.sql b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_rolling/out.sql index 6d779a40ac..57e8a833b6 100644 --- a/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_rolling/out.sql +++ b/tests/unit/core/compile/sqlglot/snapshots/test_compile_window/test_compile_window_w_rolling/out.sql @@ -1,30 +1,32 @@ -WITH `bfcte_0` AS ( - SELECT - `int64_col` AS `bfcol_0`, - `rowindex` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`scalar_types` -), `bfcte_1` AS ( - SELECT - *, - CASE - WHEN SUM(CAST(NOT `bfcol_0` IS NULL AS INT64)) OVER ( - ORDER BY `bfcol_1` IS NULL ASC NULLS LAST, `bfcol_1` ASC NULLS LAST - ROWS BETWEEN 2 PRECEDING AND CURRENT ROW - ) < 3 - THEN NULL - ELSE COALESCE( - SUM(`bfcol_0`) OVER ( - ORDER BY `bfcol_1` IS NULL ASC NULLS LAST, `bfcol_1` ASC NULLS LAST - ROWS BETWEEN 2 PRECEDING AND CURRENT ROW - ), - 0 - ) - END AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_1` AS `rowindex`, - `bfcol_4` AS `int64_col` -FROM `bfcte_1` -ORDER BY - `bfcol_1` ASC NULLS LAST \ No newline at end of file +`rowindex` AS `rowindex`, +`int64_col` AS `int64_col` +FROM +(SELECT + `t0`.`rowindex`, + CASE + WHEN COALESCE( + SUM(CAST(( + `t0`.`int64_col` + ) IS NOT NULL AS INT64)) OVER ( + ORDER BY `t0`.`rowindex` IS NULL ASC, `t0`.`rowindex` ASC + ROWS BETWEEN 2 preceding AND CURRENT ROW + ), + 0 + ) < 3 + THEN NULL + ELSE COALESCE( + SUM(`t0`.`int64_col`) OVER ( + ORDER BY `t0`.`rowindex` IS NULL ASC, `t0`.`rowindex` ASC + ROWS BETWEEN 2 preceding AND CURRENT ROW + ), + 0 + ) + END AS `int64_col` +FROM ( + SELECT + `int64_col`, + `rowindex` + FROM `bigframes-dev.sqlglot_test.scalar_types` FOR SYSTEM_TIME AS OF DATETIME('2025-08-15T22:12:35.305875') +) AS `t0`) +ORDER BY `rowindex` ASC NULLS LAST \ No newline at end of file