diff --git a/bigframes/testing/compiler_session.py b/bigframes/testing/compiler_session.py index 35114d95d0..23a699df0c 100644 --- a/bigframes/testing/compiler_session.py +++ b/bigframes/testing/compiler_session.py @@ -16,7 +16,8 @@ import typing import bigframes.core -import bigframes.core.compile.sqlglot as sqlglot +from bigframes.core.compile import configs +import bigframes.core.compile.compiler as compiler import bigframes.session.executor @@ -24,8 +25,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 +37,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 = compiler.compile_sql(request) + return compiled.sql 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 1496f89f28..766cf5f932 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,16 +1,4 @@ -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_4`, - `bfcol_0` + `bfcol_0` AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `rowindex`, - `bfcol_5` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col` + `t0`.`int64_col` AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` \ No newline at end of file diff --git a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric_w_scalar/out.sql b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric_w_scalar/out.sql index 9c4b01a6df..bd3f57e66c 100644 --- a/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric_w_scalar/out.sql +++ b/tests/unit/core/compile/sqlglot/expressions/snapshots/test_binary_compiler/test_add_numeric_w_scalar/out.sql @@ -1,16 +1,4 @@ -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_4`, - `bfcol_0` + 1 AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `rowindex`, - `bfcol_5` AS `int64_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`int64_col` + 1 AS `int64_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` 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 7a8ab83df1..f78210d2ab 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,16 +1,4 @@ -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 - *, - `bfcol_0` AS `bfcol_4`, - CONCAT(`bfcol_1`, 'a') AS `bfcol_5` - FROM `bfcte_0` -) SELECT - `bfcol_4` AS `rowindex`, - `bfcol_5` AS `string_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + CONCAT(`t0`.`string_col`, 'a') AS `string_col` +FROM `bigframes-dev.sqlglot_test.scalar_types` 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 f501dd3b86..a41139e452 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,20 +1,8 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `json_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`json_types` -), `bfcte_1` AS ( - SELECT - *, - JSON_SET(`bfcol_1`, '$.a', 100) AS `bfcol_4` - FROM `bfcte_0` -), `bfcte_2` AS ( - SELECT - *, - JSON_SET(`bfcol_4`, '$.b', 'hi') AS `bfcol_7` - FROM `bfcte_1` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_7` AS `json_col` -FROM `bfcte_2` \ No newline at end of file + `t1`.`rowindex`, + json_set(json_set(`t1`.`json_col`, '$.a', 100), '$.b', 'hi') AS `json_col` +FROM ( + SELECT + * + FROM `bigframes-dev.sqlglot_test.json_types` AS `t0` +) AS `t1` \ 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 33a8bded13..2afd0496fd 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,15 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_list_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - `bfcol_1`[SAFE_OFFSET(1)] AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_4` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + `t0`.`string_list_col`[safe_offset(1)] AS `string_list_col` +FROM `bigframes-dev.sqlglot_test.repeated_types` 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 34d2225931..9296991ecc 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,21 +1,10 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_list_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`bfcol_1`) AS el WITH OFFSET AS slice_idx - WHERE - slice_idx >= 1 - ) AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_4` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + 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 `bigframes-dev.sqlglot_test.repeated_types` 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 d46803ce7c..2f29e08f4d 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,21 +1,11 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_list_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY( - SELECT - el - FROM UNNEST(`bfcol_1`) AS el WITH OFFSET AS slice_idx - WHERE - slice_idx >= 1 AND slice_idx < 5 - ) AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_4` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + 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 `bigframes-dev.sqlglot_test.repeated_types` 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 e0db21f972..9573de9880 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,15 +1,4 @@ -WITH `bfcte_0` AS ( - SELECT - `rowindex` AS `bfcol_0`, - `string_list_col` AS `bfcol_1` - FROM `bigframes-dev`.`sqlglot_test`.`repeated_types` -), `bfcte_1` AS ( - SELECT - *, - ARRAY_TO_STRING(`bfcol_1`, '.') AS `bfcol_4` - FROM `bfcte_0` -) SELECT - `bfcol_0` AS `rowindex`, - `bfcol_4` AS `string_list_col` -FROM `bfcte_1` \ No newline at end of file + `t0`.`rowindex`, + ARRAY_TO_STRING(`t0`.`string_list_col`, '.') AS `string_list_col` +FROM `bigframes-dev.sqlglot_test.repeated_types` 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 d965ea8f1b..57f06b6d9b 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,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 - *, - JSON_VALUE(`bfcol_1`, '$') 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 + `t1`.`rowindex`, + json_value(`t1`.`string_col`, '$') AS `string_col` +FROM ( + SELECT + `t0`.`rowindex`, + `t0`.`string_col` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t1` \ 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..3aabfee4ce 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,25 @@ -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_34` AS `bool_col`, + `t2`.`bfuid_col_35` 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_34`, + COALESCE(SUM(`t1`.`bfuid_col_33`), 0) AS `bfuid_col_35` + FROM ( + SELECT + `t0`.`int64_too` AS `bfuid_col_33`, + `t0`.`bool_col` AS `bfuid_col_34` + FROM `bigframes-dev.sqlglot_test.scalar_types` 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_34` + ) 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..d10548b878 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,21 @@ -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_38` AS `bool_col`, + `t2`.`bfuid_col_39` AS `int64_too` +FROM ( SELECT - `bfcol_3`, - COALESCE(SUM(`bfcol_2`), 0) AS `bfcol_6` - FROM `bfcte_1` + `t1`.`bfuid_col_38`, + COALESCE(SUM(`t1`.`bfuid_col_37`), 0) AS `bfuid_col_39` + FROM ( + SELECT + `t0`.`int64_too` AS `bfuid_col_37`, + `t0`.`bool_col` AS `bfuid_col_38` + FROM `bigframes-dev.sqlglot_test.scalar_types` 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..f5df1bc5f7 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_51`, + `t0`.`bfuid_col_44` AS `bfuid_col_50` + 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_51`, + `t0`.`bfuid_col_44` AS `bfuid_col_50` + 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_51` ASC NULLS LAST ,`bfuid_col_50` 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..a5fc090483 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,59 @@ -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_20` AS `rowindex`, + `t2`.`rowindex` AS `rowindex_1`, + `t2`.`int_list_col`[safe_offset(`t2`.`bfuid_col_55`)] AS `int_list_col`, + `t2`.`string_list_col`[safe_offset(`t2`.`bfuid_col_55`)] AS `string_list_col`, + `t2`.`bfuid_col_55` AS `bfuid_col_56` +FROM ( + SELECT + IF(pos = pos_2, `bfuid_col_55`, NULL) AS `bfuid_col_55`, + `t1`.`bfuid_col_20`, + `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_mmhty7a3izdwnov6fomraqjasq + 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_mmhty7a3izdwnov6fomraqjasq + WHERE + ibis_bq_arr_range_mmhty7a3izdwnov6fomraqjasq <> GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`), ARRAY_LENGTH(`t0`.`string_list_col`))) + ), + [] + ) AS `bfuid_offset_array_57`, + `t0`.`rowindex` AS `bfuid_col_20`, + `t0`.`rowindex`, + `t0`.`int_list_col`, + `t0`.`string_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` + ) AS `t1` + CROSS JOIN UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(`t1`.`bfuid_offset_array_57`)) - 1)) AS pos + CROSS JOIN UNNEST(`t1`.`bfuid_offset_array_57`) AS `bfuid_col_55` WITH OFFSET AS pos_2 + WHERE + pos = pos_2 + OR ( + pos > ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_57`) - 1 + ) + AND pos_2 = ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_57`) - 1 + ) + ) +) AS `t2`) +ORDER BY `bfuid_col_56` 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..92c9f3281b 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,45 @@ -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_20` AS `rowindex`, + `t2`.`int_list_col`[safe_offset(`t2`.`bfuid_col_52`)] AS `int_list_col`, + `t2`.`bfuid_col_52` AS `bfuid_col_53` +FROM ( + SELECT + IF(pos = pos_2, `bfuid_col_52`, NULL) AS `bfuid_col_52`, + `t1`.`bfuid_col_20`, + `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_46mxarmivzexrj3d2qkb5q4xqi + FROM UNNEST(generate_array(0, GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))), 1)) AS ibis_bq_arr_range_46mxarmivzexrj3d2qkb5q4xqi + WHERE + ibis_bq_arr_range_46mxarmivzexrj3d2qkb5q4xqi <> GREATEST(1, LEAST(ARRAY_LENGTH(`t0`.`int_list_col`))) + ), + [] + ) AS `bfuid_offset_array_54`, + `t0`.`rowindex` AS `bfuid_col_20`, + `t0`.`int_list_col` + FROM `bigframes-dev.sqlglot_test.repeated_types` AS `t0` + ) AS `t1` + CROSS JOIN UNNEST(GENERATE_ARRAY(0, GREATEST(ARRAY_LENGTH(`t1`.`bfuid_offset_array_54`)) - 1)) AS pos + CROSS JOIN UNNEST(`t1`.`bfuid_offset_array_54`) AS `bfuid_col_52` WITH OFFSET AS pos_2 + WHERE + pos = pos_2 + OR ( + pos > ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_54`) - 1 + ) + AND pos_2 = ( + ARRAY_LENGTH(`t1`.`bfuid_offset_array_54`) - 1 + ) + ) +) AS `t2`) +ORDER BY `bfuid_col_53` 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..d0ab658b69 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,7 @@ -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 `bigframes-dev.sqlglot_test.scalar_types` 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..a6bae2eb4d 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,17 @@ -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 + `t3`.`int64_col`, + `t4`.`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 `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t3` +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 + `t0`.`int64_col` AS `bfuid_col_63`, + `t0`.`int64_too` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(`t3`.`bfuid_col_1`, 0) = COALESCE(`t4`.`bfuid_col_63`, 0) + AND COALESCE(`t3`.`bfuid_col_1`, 1) = COALESCE(`t4`.`bfuid_col_63`, 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..e34ccc5cb0 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,18 @@ -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_66` 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 `bigframes-dev.sqlglot_test.scalar_types` 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_66`, + `t0`.`bool_col` AS `bfuid_col_67` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(CAST(`t3`.`bool_col` AS STRING), '0') = COALESCE(CAST(`t4`.`bfuid_col_67` AS STRING), '0') + AND COALESCE(CAST(`t3`.`bool_col` AS STRING), '1') = COALESCE(CAST(`t4`.`bfuid_col_67` 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..587580ea2d 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,18 @@ -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_72` 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 `bigframes-dev.sqlglot_test.scalar_types` 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_72`, + `t0`.`float64_col` AS `bfuid_col_73` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON IF(IS_NAN(`t3`.`float64_col`), 2, COALESCE(`t3`.`float64_col`, 0)) = IF(IS_NAN(`t4`.`bfuid_col_73`), 2, COALESCE(`t4`.`bfuid_col_73`, 0)) + AND IF(IS_NAN(`t3`.`float64_col`), 3, COALESCE(`t3`.`float64_col`, 1)) = IF(IS_NAN(`t4`.`bfuid_col_73`), 3, COALESCE(`t4`.`bfuid_col_73`, 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..24f7be9f5e 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,18 @@ -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_69` 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 `bigframes-dev.sqlglot_test.scalar_types` 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_69`, + `t0`.`int64_col` AS `bfuid_col_70` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(`t3`.`int64_col`, 0) = COALESCE(`t4`.`bfuid_col_70`, 0) + AND COALESCE(`t3`.`int64_col`, 1) = COALESCE(`t4`.`bfuid_col_70`, 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..37c0bac163 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,18 @@ -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_81` 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 `bigframes-dev.sqlglot_test.scalar_types` 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_81`, + `t0`.`numeric_col` AS `bfuid_col_82` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(`t3`.`numeric_col`, 0) = COALESCE(`t4`.`bfuid_col_82`, 0) + AND COALESCE(`t3`.`numeric_col`, 1) = COALESCE(`t4`.`bfuid_col_82`, 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..b8c0f4d2c4 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,18 @@ -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_75` 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 `bigframes-dev.sqlglot_test.scalar_types` 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_75`, + `t0`.`string_col` AS `bfuid_col_76` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(`t3`.`string_col`, '0') = COALESCE(`t4`.`bfuid_col_76`, '0') + AND COALESCE(`t3`.`string_col`, '1') = COALESCE(`t4`.`bfuid_col_76`, '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..f66da91f33 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,18 @@ -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_78` 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 `bigframes-dev.sqlglot_test.scalar_types` 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_78`, + `t0`.`time_col` AS `bfuid_col_79` + FROM `bigframes-dev.sqlglot_test.scalar_types` AS `t0` +) AS `t4` + ON COALESCE(CAST(`t3`.`time_col` AS STRING), '0') = COALESCE(CAST(`t4`.`bfuid_col_79` AS STRING), '0') + AND COALESCE(CAST(`t3`.`time_col` AS STRING), '1') = COALESCE(CAST(`t4`.`bfuid_col_79` 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..dfca620caf 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_84` AS `bfuid_col_85` +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_85` 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..524249c3bd 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_90` AS `bfuid_col_91` +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_91` 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..de03bddf11 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_88` AS `bfuid_col_89` +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_88` 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_89` 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..914e1c0dba 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_86` AS `bfuid_col_87` +FROM ( SELECT * - FROM UNNEST(ARRAY>, `bfcol_2` INT64>>[STRUCT( + FROM UNNEST(ARRAY>, `bfuid_col_86` 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_87` 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..e7e2d15e10 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,17 @@ -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 `bigframes-dev.sqlglot_test.scalar_types` 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..d8e2f36527 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,3 @@ -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 `bigframes-dev.sqlglot_test.json_types` 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..5ecd1f95be 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,10 @@ -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 `bigframes-dev.sqlglot_test.scalar_types` 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..ffcb3dcf49 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,5 @@ -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 `bigframes-dev.sqlglot_test.nested_structs_types` 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..fe2612044d 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,9 @@ -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 `bigframes-dev.sqlglot_test.scalar_types` 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..5acbf7ea29 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,11 @@ -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 `bigframes-dev.sqlglot_test.repeated_types` AS `t0` \ No newline at end of file