diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/decompiled.py b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/decompiled.py index df1f5738adcf2..e34179c1dbe20 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/decompiled.py @@ -2,10 +2,11 @@ lit = ibis.timestamp("2018-01-01 00:00:00") -t = ibis.table(name="t", schema={"a": "int64", "b": "string", "c": "timestamp"}) s = ibis.table(name="s", schema={"b": "string"}) +t = ibis.table(name="t", schema={"a": "int64", "b": "string", "c": "timestamp"}) f = t.filter(t.c == lit) -p = f.select(f.a, f.b, lit.name("the_date")) -joinchain = p.inner_join(s, p.b == s.b) +joinchain = f.select(f.a, f.b, lit.name("the_date")).inner_join( + s, f.select(f.a, f.b, lit.name("the_date")).b == s.b +) result = joinchain.filter(joinchain.a < 1.0) diff --git a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/out.sql b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/out.sql index 8a39b803dc8fb..da723ab7519d1 100644 --- a/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_compiler/test_table_drop_with_filter/out.sql @@ -1,8 +1,8 @@ SELECT - t5.a AS a + t6.a AS a FROM ( SELECT - t3.a AS a + t4.a AS a FROM ( SELECT t0.a AS a, @@ -11,9 +11,9 @@ FROM ( FROM t AS t0 WHERE t0.c = MAKE_TIMESTAMP(2018, 1, 1, 0, 0, 0.0) - ) AS t3 + ) AS t4 INNER JOIN s AS t2 - ON t3.b = t2.b -) AS t5 + ON t4.b = t2.b +) AS t6 WHERE - t5.a < CAST(1.0 AS DOUBLE) \ No newline at end of file + t6.a < CAST(1.0 AS DOUBLE) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_count_joined/decompiled.py b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_count_joined/decompiled.py index b3713edb42925..f8b37a31ab639 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_count_joined/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_count_joined/decompiled.py @@ -1,29 +1,34 @@ import ibis -tpch_region = ibis.table( - name="tpch_region", - schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"}, -) - -result = tpch_region.inner_join( +result = ( ibis.table( - name="tpch_nation", - schema={ - "n_nationkey": "int16", - "n_name": "string", - "n_regionkey": "int16", - "n_comment": "string", - }, - ), - tpch_region.r_regionkey - == ibis.table( - name="tpch_nation", - schema={ - "n_nationkey": "int16", - "n_name": "string", - "n_regionkey": "int16", - "n_comment": "string", - }, - ).n_regionkey, -).count() + name="tpch_region", + schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"}, + ) + .inner_join( + ibis.table( + name="tpch_nation", + schema={ + "n_nationkey": "int16", + "n_name": "string", + "n_regionkey": "int16", + "n_comment": "string", + }, + ), + ibis.table( + name="tpch_region", + schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"}, + ).r_regionkey + == ibis.table( + name="tpch_nation", + schema={ + "n_nationkey": "int16", + "n_name": "string", + "n_regionkey": "int16", + "n_comment": "string", + }, + ).n_regionkey, + ) + .count() +) diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_alias_bug/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_alias_bug/out.sql index aaac31cfbc003..bab48a7f215d0 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_alias_bug/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_aggregate_projection_alias_bug/out.sql @@ -1,16 +1,16 @@ SELECT - t4.foo_id AS foo_id, - SUM(t4.value1) AS total + t5.foo_id AS foo_id, + SUM(t5.value1) AS total FROM ( SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id, - t2.value1 AS value1 - FROM star1 AS t0 - INNER JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id -) AS t4 + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id, + t3.value1 AS value1 + FROM star1 AS t2 + INNER JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id +) AS t5 GROUP BY 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_anti_join/decompiled.py b/ibis/backends/tests/sql/snapshots/test_select_sql/test_anti_join/decompiled.py index 2caa74d4179ad..d9a42ee5675b3 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_anti_join/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_anti_join/decompiled.py @@ -1,17 +1,18 @@ import ibis -star1 = ibis.table( +result = ibis.table( name="star1", schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, -) - -result = star1.anti_join( +).anti_join( ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, ), - star1.foo_id + ibis.table( + name="star1", + schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, + ).foo_id == ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_anti_join/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_anti_join/out.sql index db6bfa57e195a..b97f63cc4e25e 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_anti_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_anti_join/out.sql @@ -1,8 +1,8 @@ SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id -FROM star1 AS t0 -ANTI JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id \ No newline at end of file + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id +FROM star1 AS t2 +ANTI JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_filter_self_join_analysis_bug/result.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_filter_self_join_analysis_bug/result.sql index 7299a9b089d3a..5607c99eb6885 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_filter_self_join_analysis_bug/result.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_filter_self_join_analysis_bug/result.sql @@ -1,6 +1,6 @@ SELECT - t2.region AS region, - t2.total - t4.total AS diff + t4.region AS region, + t4.total - t5.total AS diff FROM ( SELECT t1.region AS region, @@ -18,7 +18,7 @@ FROM ( ) AS t1 WHERE t1.kind = 'foo' -) AS t2 +) AS t4 INNER JOIN ( SELECT t1.region AS region, @@ -36,5 +36,5 @@ INNER JOIN ( ) AS t1 WHERE t1.kind = 'bar' -) AS t4 - ON t2.region = t4.region \ No newline at end of file +) AS t5 + ON t4.region = t5.region \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_just_materialized/decompiled.py b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_just_materialized/decompiled.py index 9b70f2fdf1a5b..91ffed7274105 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_just_materialized/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_just_materialized/decompiled.py @@ -1,52 +1,70 @@ import ibis -tpch_nation = ibis.table( - name="tpch_nation", - schema={ - "n_nationkey": "int16", - "n_name": "string", - "n_regionkey": "int16", - "n_comment": "string", - }, -) - -result = tpch_nation.inner_join( - ibis.table( - name="tpch_region", - schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"}, - ), - tpch_nation.n_regionkey - == ibis.table( - name="tpch_region", - schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"}, - ).r_regionkey, -).inner_join( +result = ( ibis.table( - name="tpch_customer", - schema={ - "c_custkey": "int64", - "c_name": "string", - "c_address": "string", - "c_nationkey": "int16", - "c_phone": "string", - "c_acctbal": "decimal", - "c_mktsegment": "string", - "c_comment": "string", - }, - ), - tpch_nation.n_nationkey - == ibis.table( - name="tpch_customer", + name="tpch_nation", schema={ - "c_custkey": "int64", - "c_name": "string", - "c_address": "string", - "c_nationkey": "int16", - "c_phone": "string", - "c_acctbal": "decimal", - "c_mktsegment": "string", - "c_comment": "string", + "n_nationkey": "int16", + "n_name": "string", + "n_regionkey": "int16", + "n_comment": "string", }, - ).c_nationkey, + ) + .inner_join( + ibis.table( + name="tpch_region", + schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"}, + ), + ibis.table( + name="tpch_nation", + schema={ + "n_nationkey": "int16", + "n_name": "string", + "n_regionkey": "int16", + "n_comment": "string", + }, + ).n_regionkey + == ibis.table( + name="tpch_region", + schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"}, + ).r_regionkey, + ) + .inner_join( + ibis.table( + name="tpch_customer", + schema={ + "c_custkey": "int64", + "c_name": "string", + "c_address": "string", + "c_nationkey": "int16", + "c_phone": "string", + "c_acctbal": "decimal", + "c_mktsegment": "string", + "c_comment": "string", + }, + ), + ibis.table( + name="tpch_nation", + schema={ + "n_nationkey": "int16", + "n_name": "string", + "n_regionkey": "int16", + "n_comment": "string", + }, + ).n_nationkey + == ibis.table( + name="tpch_customer", + schema={ + "c_custkey": "int64", + "c_name": "string", + "c_address": "string", + "c_nationkey": "int16", + "c_phone": "string", + "c_acctbal": "decimal", + "c_mktsegment": "string", + "c_comment": "string", + }, + ).c_nationkey, + ) ) diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_just_materialized/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_just_materialized/out.sql index e46aab09c5e56..f8066e7390515 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_just_materialized/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_just_materialized/out.sql @@ -1,21 +1,21 @@ SELECT - t0.n_nationkey AS n_nationkey, - t0.n_name AS n_name, - t0.n_regionkey AS n_regionkey, - t0.n_comment AS n_comment, - t3.r_regionkey AS r_regionkey, - t3.r_name AS r_name, - t3.r_comment AS r_comment, - t4.c_custkey AS c_custkey, - t4.c_name AS c_name, - t4.c_address AS c_address, - t4.c_nationkey AS c_nationkey, - t4.c_phone AS c_phone, - t4.c_acctbal AS c_acctbal, - t4.c_mktsegment AS c_mktsegment, - t4.c_comment AS c_comment -FROM tpch_nation AS t0 -INNER JOIN tpch_region AS t3 - ON t0.n_regionkey = t3.r_regionkey -INNER JOIN tpch_customer AS t4 - ON t0.n_nationkey = t4.c_nationkey \ No newline at end of file + t3.n_nationkey AS n_nationkey, + t3.n_name AS n_name, + t3.n_regionkey AS n_regionkey, + t3.n_comment AS n_comment, + t4.r_regionkey AS r_regionkey, + t4.r_name AS r_name, + t4.r_comment AS r_comment, + t5.c_custkey AS c_custkey, + t5.c_name AS c_name, + t5.c_address AS c_address, + t5.c_nationkey AS c_nationkey, + t5.c_phone AS c_phone, + t5.c_acctbal AS c_acctbal, + t5.c_mktsegment AS c_mktsegment, + t5.c_comment AS c_comment +FROM tpch_nation AS t3 +INNER JOIN tpch_region AS t4 + ON t3.n_regionkey = t4.r_regionkey +INNER JOIN tpch_customer AS t5 + ON t3.n_nationkey = t5.c_nationkey \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_with_conditional_aggregate/result.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_with_conditional_aggregate/result.sql index 679c96568128c..2c10fd3e50069 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_with_conditional_aggregate/result.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_with_conditional_aggregate/result.sql @@ -1,24 +1,24 @@ SELECT - t5.on AS on, - t5.by AS by, - t5.on_right AS on_right, - t5.by_right AS by_right, - t5.val AS val + t6.on AS on, + t6.by AS by, + t6.on_right AS on_right, + t6.by_right AS by_right, + t6.val AS val FROM ( SELECT - t0.on AS on, - t0.by AS by, - t2.on AS on_right, - t2.by AS by_right, - t2.val AS val - FROM left AS t0 - LEFT OUTER JOIN right AS t2 - ON t0.by = t2.by -) AS t5 + t2.on AS on, + t2.by AS by, + t3.on AS on_right, + t3.by AS by_right, + t3.val AS val + FROM left AS t2 + LEFT OUTER JOIN right AS t3 + ON t2.by = t3.by +) AS t6 WHERE - t5.on_right = ( + t6.on_right = ( SELECT - MAX(t3.on) AS "Max(on)" + MAX(t4.on) AS "Max(on)" FROM ( SELECT t1.on AS on, @@ -27,5 +27,5 @@ WHERE FROM right AS t1 WHERE t1.by = t0.by AND t1.on <= t0.on - ) AS t3 + ) AS t4 ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_with_limited_table/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_with_limited_table/out.sql index 0cbd7344b5c7c..2dd1c4945d381 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_with_limited_table/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_join_with_limited_table/out.sql @@ -1,13 +1,13 @@ SELECT - t2.c AS c, - t2.f AS f, - t2.foo_id AS foo_id, - t2.bar_id AS bar_id + t4.c AS c, + t4.f AS f, + t4.foo_id AS foo_id, + t4.bar_id AS bar_id FROM ( SELECT * FROM star1 AS t0 LIMIT 100 -) AS t2 +) AS t4 INNER JOIN star2 AS t3 - ON t2.foo_id = t3.foo_id \ No newline at end of file + ON t4.foo_id = t3.foo_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_loj_subquery_filter_handling/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_loj_subquery_filter_handling/out.sql index 703303b0e755a..9cb4f828cdd3c 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_loj_subquery_filter_handling/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_loj_subquery_filter_handling/out.sql @@ -1,8 +1,8 @@ SELECT - t2.id AS left_id, - t2.desc AS left_desc, - t4.id AS right_id, - t4.desc AS right_desc + t4.id AS left_id, + t4.desc AS left_desc, + t5.id AS right_id, + t5.desc AS right_desc FROM ( SELECT t0.id AS id, @@ -10,7 +10,7 @@ FROM ( FROM foo AS t0 WHERE t0.id < CAST(2 AS TINYINT) -) AS t2 +) AS t4 LEFT OUTER JOIN ( SELECT t1.id AS id, @@ -18,5 +18,5 @@ LEFT OUTER JOIN ( FROM bar AS t1 WHERE t1.id < CAST(3 AS TINYINT) -) AS t4 - ON t2.id = t4.id AND t2.desc = t4.desc \ No newline at end of file +) AS t5 + ON t4.id = t5.id AND t4.desc = t5.desc \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_multiple_joins/decompiled.py b/ibis/backends/tests/sql/snapshots/test_select_sql/test_multiple_joins/decompiled.py index f52f6ad2f2052..5bb29d5bc82b6 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_multiple_joins/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_multiple_joins/decompiled.py @@ -1,25 +1,43 @@ import ibis -star1 = ibis.table( - name="star1", - schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, -) - -result = star1.left_join( +result = ( ibis.table( - name="star2", - schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, - ), - star1.foo_id - == ibis.table( - name="star2", - schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, - ).foo_id, -).inner_join( - ibis.table(name="star3", schema={"bar_id": "string", "value2": "float64"}), - star1.bar_id - == ibis.table( - name="star3", schema={"bar_id": "string", "value2": "float64"} - ).bar_id, + name="star1", + schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, + ) + .left_join( + ibis.table( + name="star2", + schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, + ), + ibis.table( + name="star1", + schema={ + "c": "int32", + "f": "float64", + "foo_id": "string", + "bar_id": "string", + }, + ).foo_id + == ibis.table( + name="star2", + schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, + ).foo_id, + ) + .inner_join( + ibis.table(name="star3", schema={"bar_id": "string", "value2": "float64"}), + ibis.table( + name="star1", + schema={ + "c": "int32", + "f": "float64", + "foo_id": "string", + "bar_id": "string", + }, + ).bar_id + == ibis.table( + name="star3", schema={"bar_id": "string", "value2": "float64"} + ).bar_id, + ) ) diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_multiple_joins/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_multiple_joins/out.sql index 5d1f678029479..7daea6d869b2b 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_multiple_joins/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_multiple_joins/out.sql @@ -1,12 +1,12 @@ SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id, - t3.value1 AS value1, - t4.value2 AS value2 -FROM star1 AS t0 -LEFT OUTER JOIN star2 AS t3 - ON t0.foo_id = t3.foo_id -INNER JOIN star3 AS t4 - ON t0.bar_id = t4.bar_id \ No newline at end of file + t3.c AS c, + t3.f AS f, + t3.foo_id AS foo_id, + t3.bar_id AS bar_id, + t4.value1 AS value1, + t5.value2 AS value2 +FROM star1 AS t3 +LEFT OUTER JOIN star2 AS t4 + ON t3.foo_id = t4.foo_id +INNER JOIN star3 AS t5 + ON t3.bar_id = t5.bar_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_semi_join/decompiled.py b/ibis/backends/tests/sql/snapshots/test_select_sql/test_semi_join/decompiled.py index 7ee6385cffd9b..d5467d18d2873 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_semi_join/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_semi_join/decompiled.py @@ -1,17 +1,18 @@ import ibis -star1 = ibis.table( +result = ibis.table( name="star1", schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, -) - -result = star1.semi_join( +).semi_join( ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, ), - star1.foo_id + ibis.table( + name="star1", + schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, + ).foo_id == ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_semi_join/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_semi_join/out.sql index 68de8203e5810..a9dd246c1eae0 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_semi_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_semi_join/out.sql @@ -1,8 +1,8 @@ SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id -FROM star1 AS t0 -SEMI JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id \ No newline at end of file + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id +FROM star1 AS t2 +SEMI JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/decompiled.py b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/decompiled.py index 5aa211ef0725f..25a93bf9ef6bb 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/decompiled.py @@ -1,23 +1,37 @@ import ibis -star1 = ibis.table( +result = ibis.table( name="star1", schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, -) - -result = star1.inner_join( +).inner_join( ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, ), [ - star1.foo_id + ibis.table( + name="star1", + schema={ + "c": "int32", + "f": "float64", + "foo_id": "string", + "bar_id": "string", + }, + ).foo_id == ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, ).foo_id, - star1.bar_id + ibis.table( + name="star1", + schema={ + "c": "int32", + "f": "float64", + "foo_id": "string", + "bar_id": "string", + }, + ).bar_id == ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/inner.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/inner.sql index 9bd0f7954ef2d..db29f096cfda6 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/inner.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/inner.sql @@ -1,8 +1,8 @@ SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id -FROM star1 AS t0 -INNER JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id \ No newline at end of file + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id +FROM star1 AS t2 +INNER JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/inner_two_preds.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/inner_two_preds.sql index 4517b2b5c803c..9a55315413418 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/inner_two_preds.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/inner_two_preds.sql @@ -1,8 +1,8 @@ SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id -FROM star1 AS t0 -INNER JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id AND t0.bar_id = t2.foo_id \ No newline at end of file + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id +FROM star1 AS t2 +INNER JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id AND t2.bar_id = t3.foo_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/left.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/left.sql index 59edf15c92337..d3ffbfde131c6 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/left.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/left.sql @@ -1,8 +1,8 @@ SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id -FROM star1 AS t0 -LEFT OUTER JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id \ No newline at end of file + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id +FROM star1 AS t2 +LEFT OUTER JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/outer.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/outer.sql index 42c1c115151da..c880bdc100500 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/outer.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_simple_joins/outer.sql @@ -1,8 +1,8 @@ SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id -FROM star1 AS t0 -FULL OUTER JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id \ No newline at end of file + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id +FROM star1 AS t2 +FULL OUTER JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_subquery_factor_correlated_subquery/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_subquery_factor_correlated_subquery/out.sql index be974c8ebfc20..e340d81e27857 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_subquery_factor_correlated_subquery/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_subquery_factor_correlated_subquery/out.sql @@ -1,76 +1,76 @@ SELECT - t10.c_custkey AS c_custkey, - t10.c_name AS c_name, - t10.c_address AS c_address, - t10.c_nationkey AS c_nationkey, - t10.c_phone AS c_phone, - t10.c_acctbal AS c_acctbal, - t10.c_mktsegment AS c_mktsegment, - t10.c_comment AS c_comment, - t10.region AS region, - t10.amount AS amount, - t10.odate AS odate + t11.c_custkey AS c_custkey, + t11.c_name AS c_name, + t11.c_address AS c_address, + t11.c_nationkey AS c_nationkey, + t11.c_phone AS c_phone, + t11.c_acctbal AS c_acctbal, + t11.c_mktsegment AS c_mktsegment, + t11.c_comment AS c_comment, + t11.region AS region, + t11.amount AS amount, + t11.odate AS odate FROM ( SELECT - t5.c_custkey AS c_custkey, - t5.c_name AS c_name, - t5.c_address AS c_address, - t5.c_nationkey AS c_nationkey, - t5.c_phone AS c_phone, - t5.c_acctbal AS c_acctbal, - t5.c_mktsegment AS c_mktsegment, - t5.c_comment AS c_comment, - t0.r_name AS region, - t6.o_totalprice AS amount, - CAST(t6.o_orderdate AS TIMESTAMP) AS odate - FROM tpch_region AS t0 - INNER JOIN tpch_nation AS t4 - ON t0.r_regionkey = t4.n_regionkey - INNER JOIN tpch_customer AS t5 - ON t5.c_nationkey = t4.n_nationkey - INNER JOIN tpch_orders AS t6 - ON t6.o_custkey = t5.c_custkey -) AS t10 + t6.c_custkey AS c_custkey, + t6.c_name AS c_name, + t6.c_address AS c_address, + t6.c_nationkey AS c_nationkey, + t6.c_phone AS c_phone, + t6.c_acctbal AS c_acctbal, + t6.c_mktsegment AS c_mktsegment, + t6.c_comment AS c_comment, + t4.r_name AS region, + t7.o_totalprice AS amount, + CAST(t7.o_orderdate AS TIMESTAMP) AS odate + FROM tpch_region AS t4 + INNER JOIN tpch_nation AS t5 + ON t4.r_regionkey = t5.n_regionkey + INNER JOIN tpch_customer AS t6 + ON t6.c_nationkey = t5.n_nationkey + INNER JOIN tpch_orders AS t7 + ON t7.o_custkey = t6.c_custkey +) AS t11 WHERE - t10.amount > ( + t11.amount > ( SELECT - AVG(t12.amount) AS "Mean(amount)" + AVG(t13.amount) AS "Mean(amount)" FROM ( SELECT - t11.c_custkey AS c_custkey, - t11.c_name AS c_name, - t11.c_address AS c_address, - t11.c_nationkey AS c_nationkey, - t11.c_phone AS c_phone, - t11.c_acctbal AS c_acctbal, - t11.c_mktsegment AS c_mktsegment, - t11.c_comment AS c_comment, - t11.region AS region, - t11.amount AS amount, - t11.odate AS odate + t12.c_custkey AS c_custkey, + t12.c_name AS c_name, + t12.c_address AS c_address, + t12.c_nationkey AS c_nationkey, + t12.c_phone AS c_phone, + t12.c_acctbal AS c_acctbal, + t12.c_mktsegment AS c_mktsegment, + t12.c_comment AS c_comment, + t12.region AS region, + t12.amount AS amount, + t12.odate AS odate FROM ( SELECT - t5.c_custkey AS c_custkey, - t5.c_name AS c_name, - t5.c_address AS c_address, - t5.c_nationkey AS c_nationkey, - t5.c_phone AS c_phone, - t5.c_acctbal AS c_acctbal, - t5.c_mktsegment AS c_mktsegment, - t5.c_comment AS c_comment, - t0.r_name AS region, - t6.o_totalprice AS amount, - CAST(t6.o_orderdate AS TIMESTAMP) AS odate - FROM tpch_region AS t0 - INNER JOIN tpch_nation AS t4 - ON t0.r_regionkey = t4.n_regionkey - INNER JOIN tpch_customer AS t5 - ON t5.c_nationkey = t4.n_nationkey - INNER JOIN tpch_orders AS t6 - ON t6.o_custkey = t5.c_custkey - ) AS t11 + t6.c_custkey AS c_custkey, + t6.c_name AS c_name, + t6.c_address AS c_address, + t6.c_nationkey AS c_nationkey, + t6.c_phone AS c_phone, + t6.c_acctbal AS c_acctbal, + t6.c_mktsegment AS c_mktsegment, + t6.c_comment AS c_comment, + t4.r_name AS region, + t7.o_totalprice AS amount, + CAST(t7.o_orderdate AS TIMESTAMP) AS odate + FROM tpch_region AS t4 + INNER JOIN tpch_nation AS t5 + ON t4.r_regionkey = t5.n_regionkey + INNER JOIN tpch_customer AS t6 + ON t6.c_nationkey = t5.n_nationkey + INNER JOIN tpch_orders AS t7 + ON t7.o_custkey = t6.c_custkey + ) AS t12 WHERE - t11.region = t11.region - ) AS t12 + t12.region = t12.region + ) AS t13 ) LIMIT 10 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_subquery_in_union/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_subquery_in_union/out.sql index 66dc6d7ad32c6..6eabe7655e0c9 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_subquery_in_union/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_subquery_in_union/out.sql @@ -1,12 +1,12 @@ SELECT - t6.a AS a, - t6.g AS g, - t6.metric AS metric + t7.a AS a, + t7.g AS g, + t7.metric AS metric FROM ( SELECT - t1.a AS a, - t1.g AS g, - t1.metric AS metric + t2.a AS a, + t2.g AS g, + t2.metric AS metric FROM ( SELECT t0.a AS a, @@ -16,7 +16,7 @@ FROM ( GROUP BY 1, 2 - ) AS t1 + ) AS t2 INNER JOIN ( SELECT t0.a AS a, @@ -26,13 +26,13 @@ FROM ( GROUP BY 1, 2 - ) AS t2 - ON t1.g = t2.g + ) AS t3 + ON t2.g = t3.g UNION ALL SELECT - t1.a AS a, - t1.g AS g, - t1.metric AS metric + t2.a AS a, + t2.g AS g, + t2.metric AS metric FROM ( SELECT t0.a AS a, @@ -42,7 +42,7 @@ FROM ( GROUP BY 1, 2 - ) AS t1 + ) AS t2 INNER JOIN ( SELECT t0.a AS a, @@ -52,6 +52,6 @@ FROM ( GROUP BY 1, 2 - ) AS t2 - ON t1.g = t2.g -) AS t6 \ No newline at end of file + ) AS t3 + ON t2.g = t3.g +) AS t7 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_analysis_bug/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_analysis_bug/out.sql index ab1fdf149ba66..ef8d9cf8e41d0 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_analysis_bug/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_analysis_bug/out.sql @@ -1,11 +1,11 @@ SELECT - t7.origin AS origin, + t8.origin AS origin, COUNT(*) AS "CountStar()" FROM ( SELECT - t1.dest AS dest, - t1.origin AS origin, - t1.arrdelay AS arrdelay + t2.dest AS dest, + t2.origin AS origin, + t2.arrdelay AS arrdelay FROM ( SELECT t0.dest AS dest, @@ -14,11 +14,11 @@ FROM ( FROM airlines AS t0 WHERE t0.dest IN ('ORD', 'JFK', 'SFO') - ) AS t1 + ) AS t2 SEMI JOIN ( SELECT - t2.dest AS dest, - t2."Mean(arrdelay)" AS "Mean(arrdelay)" + t3.dest AS dest, + t3."Mean(arrdelay)" AS "Mean(arrdelay)" FROM ( SELECT t1.dest AS dest, @@ -34,12 +34,12 @@ FROM ( ) AS t1 GROUP BY 1 - ) AS t2 + ) AS t3 ORDER BY - t2."Mean(arrdelay)" DESC + t3."Mean(arrdelay)" DESC LIMIT 10 - ) AS t5 - ON t1.dest = t5.dest -) AS t7 + ) AS t6 + ON t2.dest = t6.dest +) AS t8 GROUP BY 1 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_operation/e1.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_operation/e1.sql index fb7c1d376e94a..0d362ce0c92fe 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_operation/e1.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_operation/e1.sql @@ -1,14 +1,14 @@ SELECT - t0.foo AS foo, - t0.bar AS bar, - t0.city AS city, - t0.v1 AS v1, - t0.v2 AS v2 -FROM tbl AS t0 + t1.foo AS foo, + t1.bar AS bar, + t1.city AS city, + t1.v1 AS v1, + t1.v2 AS v2 +FROM tbl AS t1 SEMI JOIN ( SELECT - t1.city AS city, - t1."Mean(v2)" AS "Mean(v2)" + t2.city AS city, + t2."Mean(v2)" AS "Mean(v2)" FROM ( SELECT t0.city AS city, @@ -16,9 +16,9 @@ SEMI JOIN ( FROM tbl AS t0 GROUP BY 1 - ) AS t1 + ) AS t2 ORDER BY - t1."Mean(v2)" DESC + t2."Mean(v2)" DESC LIMIT 10 -) AS t4 - ON t0.city = t4.city \ No newline at end of file +) AS t5 + ON t1.city = t5.city \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_operation/e2.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_operation/e2.sql index 948e8686251d1..1370eb16a799a 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_operation/e2.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_operation/e2.sql @@ -1,14 +1,14 @@ SELECT - t0.foo AS foo, - t0.bar AS bar, - t0.city AS city, - t0.v1 AS v1, - t0.v2 AS v2 -FROM tbl AS t0 + t1.foo AS foo, + t1.bar AS bar, + t1.city AS city, + t1.v1 AS v1, + t1.v2 AS v2 +FROM tbl AS t1 SEMI JOIN ( SELECT - t1.city AS city, - t1."Count(city)" AS "Count(city)" + t2.city AS city, + t2."Count(city)" AS "Count(city)" FROM ( SELECT t0.city AS city, @@ -16,9 +16,9 @@ SEMI JOIN ( FROM tbl AS t0 GROUP BY 1 - ) AS t1 + ) AS t2 ORDER BY - t1."Count(city)" DESC + t2."Count(city)" DESC LIMIT 10 -) AS t4 - ON t0.city = t4.city \ No newline at end of file +) AS t5 + ON t1.city = t5.city \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_predicate_pushdown_bug/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_predicate_pushdown_bug/out.sql index 31656ca8a4d9b..ad36d1b15171d 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_predicate_pushdown_bug/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_topk_predicate_pushdown_bug/out.sql @@ -1,50 +1,50 @@ SELECT - t0.c_custkey AS c_custkey, - t0.c_name AS c_name, - t0.c_address AS c_address, - t0.c_nationkey AS c_nationkey, - t0.c_phone AS c_phone, - t0.c_acctbal AS c_acctbal, - t0.c_mktsegment AS c_mktsegment, - t0.c_comment AS c_comment, - t3.n_name AS n_name, - t4.r_name AS r_name -FROM tpch_customer AS t0 -INNER JOIN tpch_nation AS t3 - ON t0.c_nationkey = t3.n_nationkey -INNER JOIN tpch_region AS t4 - ON t3.n_regionkey = t4.r_regionkey + t3.c_custkey AS c_custkey, + t3.c_name AS c_name, + t3.c_address AS c_address, + t3.c_nationkey AS c_nationkey, + t3.c_phone AS c_phone, + t3.c_acctbal AS c_acctbal, + t3.c_mktsegment AS c_mktsegment, + t3.c_comment AS c_comment, + t4.n_name AS n_name, + t5.r_name AS r_name +FROM tpch_customer AS t3 +INNER JOIN tpch_nation AS t4 + ON t3.c_nationkey = t4.n_nationkey +INNER JOIN tpch_region AS t5 + ON t4.n_regionkey = t5.r_regionkey SEMI JOIN ( SELECT - t8.n_name AS n_name, - t8."Sum(c_acctbal)" AS "Sum(c_acctbal)" + t9.n_name AS n_name, + t9."Sum(c_acctbal)" AS "Sum(c_acctbal)" FROM ( SELECT - t7.n_name AS n_name, - SUM(t7.c_acctbal) AS "Sum(c_acctbal)" + t8.n_name AS n_name, + SUM(t8.c_acctbal) AS "Sum(c_acctbal)" FROM ( SELECT - t0.c_custkey AS c_custkey, - t0.c_name AS c_name, - t0.c_address AS c_address, - t0.c_nationkey AS c_nationkey, - t0.c_phone AS c_phone, - t0.c_acctbal AS c_acctbal, - t0.c_mktsegment AS c_mktsegment, - t0.c_comment AS c_comment, - t3.n_name AS n_name, - t4.r_name AS r_name - FROM tpch_customer AS t0 - INNER JOIN tpch_nation AS t3 - ON t0.c_nationkey = t3.n_nationkey - INNER JOIN tpch_region AS t4 - ON t3.n_regionkey = t4.r_regionkey - ) AS t7 + t3.c_custkey AS c_custkey, + t3.c_name AS c_name, + t3.c_address AS c_address, + t3.c_nationkey AS c_nationkey, + t3.c_phone AS c_phone, + t3.c_acctbal AS c_acctbal, + t3.c_mktsegment AS c_mktsegment, + t3.c_comment AS c_comment, + t4.n_name AS n_name, + t5.r_name AS r_name + FROM tpch_customer AS t3 + INNER JOIN tpch_nation AS t4 + ON t3.c_nationkey = t4.n_nationkey + INNER JOIN tpch_region AS t5 + ON t4.n_regionkey = t5.r_regionkey + ) AS t8 GROUP BY 1 - ) AS t8 + ) AS t9 ORDER BY - t8."Sum(c_acctbal)" DESC + t9."Sum(c_acctbal)" DESC LIMIT 10 -) AS t11 - ON t3.n_name = t11.n_name \ No newline at end of file +) AS t12 + ON t4.n_name = t12.n_name \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_tpch_self_join_failure/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_tpch_self_join_failure/out.sql index 49995dc1a2ce2..fcdcba4ffc540 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_tpch_self_join_failure/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_tpch_self_join_failure/out.sql @@ -1,53 +1,53 @@ SELECT - t11.region AS region, - t11.year AS year, - t11.total - t12.total AS yoy_change + t13.region AS region, + t13.year AS year, + t13.total - t14.total AS yoy_change FROM ( SELECT - t10.region AS region, - EXTRACT('year' FROM t10.odate) AS year, - CAST(SUM(t10.amount) AS DOUBLE) AS total + t11.region AS region, + EXTRACT('year' FROM t11.odate) AS year, + CAST(SUM(t11.amount) AS DOUBLE) AS total FROM ( SELECT - t0.r_name AS region, - t4.n_name AS nation, - t6.o_totalprice AS amount, - CAST(t6.o_orderdate AS TIMESTAMP) AS odate - FROM tpch_region AS t0 - INNER JOIN tpch_nation AS t4 - ON t0.r_regionkey = t4.n_regionkey - INNER JOIN tpch_customer AS t5 - ON t5.c_nationkey = t4.n_nationkey - INNER JOIN tpch_orders AS t6 - ON t6.o_custkey = t5.c_custkey - ) AS t10 + t4.r_name AS region, + t5.n_name AS nation, + t7.o_totalprice AS amount, + CAST(t7.o_orderdate AS TIMESTAMP) AS odate + FROM tpch_region AS t4 + INNER JOIN tpch_nation AS t5 + ON t4.r_regionkey = t5.n_regionkey + INNER JOIN tpch_customer AS t6 + ON t6.c_nationkey = t5.n_nationkey + INNER JOIN tpch_orders AS t7 + ON t7.o_custkey = t6.c_custkey + ) AS t11 GROUP BY 1, 2 -) AS t11 +) AS t13 INNER JOIN ( SELECT - t10.region AS region, - EXTRACT('year' FROM t10.odate) AS year, - CAST(SUM(t10.amount) AS DOUBLE) AS total + t11.region AS region, + EXTRACT('year' FROM t11.odate) AS year, + CAST(SUM(t11.amount) AS DOUBLE) AS total FROM ( SELECT - t0.r_name AS region, - t4.n_name AS nation, - t6.o_totalprice AS amount, - CAST(t6.o_orderdate AS TIMESTAMP) AS odate - FROM tpch_region AS t0 - INNER JOIN tpch_nation AS t4 - ON t0.r_regionkey = t4.n_regionkey - INNER JOIN tpch_customer AS t5 - ON t5.c_nationkey = t4.n_nationkey - INNER JOIN tpch_orders AS t6 - ON t6.o_custkey = t5.c_custkey - ) AS t10 + t4.r_name AS region, + t5.n_name AS nation, + t7.o_totalprice AS amount, + CAST(t7.o_orderdate AS TIMESTAMP) AS odate + FROM tpch_region AS t4 + INNER JOIN tpch_nation AS t5 + ON t4.r_regionkey = t5.n_regionkey + INNER JOIN tpch_customer AS t6 + ON t6.c_nationkey = t5.n_nationkey + INNER JOIN tpch_orders AS t7 + ON t7.o_custkey = t6.c_custkey + ) AS t11 GROUP BY 1, 2 -) AS t12 - ON t11.year = ( - t12.year - CAST(1 AS TINYINT) +) AS t14 + ON t13.year = ( + t14.year - CAST(1 AS TINYINT) ) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/decompiled.py b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/decompiled.py index ac0de095bde18..4b71f1c093d3e 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/decompiled.py @@ -1,16 +1,18 @@ import ibis -star1 = ibis.table( +joinchain = ibis.table( name="star1", schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, -) -joinchain = star1.inner_join( +).inner_join( ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, ), - star1.foo_id + ibis.table( + name="star1", + schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, + ).foo_id == ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/out.sql index 59130ddff0b70..af52af7374981 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_no_pushdown_possible/out.sql @@ -1,19 +1,19 @@ SELECT - t4.c AS c, - t4.f AS f, - t4.foo_id AS foo_id, - t4.bar_id AS bar_id, - t4.diff AS diff + t5.c AS c, + t5.f AS f, + t5.foo_id AS foo_id, + t5.bar_id AS bar_id, + t5.diff AS diff FROM ( SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id, - t0.f - t2.value1 AS diff - FROM star1 AS t0 - INNER JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id -) AS t4 + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id, + t2.f - t3.value1 AS diff + FROM star1 AS t2 + INNER JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id +) AS t5 WHERE - t4.diff > CAST(1 AS TINYINT) \ No newline at end of file + t5.diff > CAST(1 AS TINYINT) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/decompiled.py b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/decompiled.py index 2026d6f09a30c..84601e83865ed 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/decompiled.py +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/decompiled.py @@ -1,16 +1,18 @@ import ibis -star1 = ibis.table( +joinchain = ibis.table( name="star1", schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, -) -joinchain = star1.inner_join( +).inner_join( ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, ), - star1.foo_id + ibis.table( + name="star1", + schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"}, + ).foo_id == ibis.table( name="star2", schema={"foo_id": "string", "value1": "float64", "value3": "float64"}, diff --git a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/out.sql b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/out.sql index 8bc007751d261..ad95bd728c9ae 100644 --- a/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_select_sql/test_where_with_join/out.sql @@ -1,21 +1,21 @@ SELECT - t4.c AS c, - t4.f AS f, - t4.foo_id AS foo_id, - t4.bar_id AS bar_id, - t4.value1 AS value1, - t4.value3 AS value3 + t5.c AS c, + t5.f AS f, + t5.foo_id AS foo_id, + t5.bar_id AS bar_id, + t5.value1 AS value1, + t5.value3 AS value3 FROM ( SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id, - t2.value1 AS value1, - t2.value3 AS value3 - FROM star1 AS t0 - INNER JOIN star2 AS t2 - ON t0.foo_id = t2.foo_id -) AS t4 + t2.c AS c, + t2.f AS f, + t2.foo_id AS foo_id, + t2.bar_id AS bar_id, + t3.value1 AS value1, + t3.value3 AS value3 + FROM star1 AS t2 + INNER JOIN star2 AS t3 + ON t2.foo_id = t3.foo_id +) AS t5 WHERE - t4.f > CAST(0 AS TINYINT) AND t4.value3 < CAST(1000 AS SMALLINT) \ No newline at end of file + t5.f > CAST(0 AS TINYINT) AND t5.value3 < CAST(1000 AS SMALLINT) \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_cte_factor_distinct_but_equal/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_cte_factor_distinct_but_equal/out.sql index 4e808e0ff710f..98dba47f3ae07 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_cte_factor_distinct_but_equal/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_cte_factor_distinct_but_equal/out.sql @@ -1,6 +1,6 @@ SELECT - t2.g AS g, - t2.metric AS metric + t3.g AS g, + t3.metric AS metric FROM ( SELECT t0.g AS g, @@ -8,7 +8,7 @@ FROM ( FROM alltypes AS t0 GROUP BY 1 -) AS t2 +) AS t3 INNER JOIN ( SELECT t1.g AS g, @@ -16,5 +16,5 @@ INNER JOIN ( FROM alltypes AS t1 GROUP BY 1 -) AS t4 - ON t2.g = t4.g \ No newline at end of file +) AS t5 + ON t3.g = t5.g \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_join_just_materialized/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_join_just_materialized/out.sql index e46aab09c5e56..f8066e7390515 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_join_just_materialized/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_join_just_materialized/out.sql @@ -1,21 +1,21 @@ SELECT - t0.n_nationkey AS n_nationkey, - t0.n_name AS n_name, - t0.n_regionkey AS n_regionkey, - t0.n_comment AS n_comment, - t3.r_regionkey AS r_regionkey, - t3.r_name AS r_name, - t3.r_comment AS r_comment, - t4.c_custkey AS c_custkey, - t4.c_name AS c_name, - t4.c_address AS c_address, - t4.c_nationkey AS c_nationkey, - t4.c_phone AS c_phone, - t4.c_acctbal AS c_acctbal, - t4.c_mktsegment AS c_mktsegment, - t4.c_comment AS c_comment -FROM tpch_nation AS t0 -INNER JOIN tpch_region AS t3 - ON t0.n_regionkey = t3.r_regionkey -INNER JOIN tpch_customer AS t4 - ON t0.n_nationkey = t4.c_nationkey \ No newline at end of file + t3.n_nationkey AS n_nationkey, + t3.n_name AS n_name, + t3.n_regionkey AS n_regionkey, + t3.n_comment AS n_comment, + t4.r_regionkey AS r_regionkey, + t4.r_name AS r_name, + t4.r_comment AS r_comment, + t5.c_custkey AS c_custkey, + t5.c_name AS c_name, + t5.c_address AS c_address, + t5.c_nationkey AS c_nationkey, + t5.c_phone AS c_phone, + t5.c_acctbal AS c_acctbal, + t5.c_mktsegment AS c_mktsegment, + t5.c_comment AS c_comment +FROM tpch_nation AS t3 +INNER JOIN tpch_region AS t4 + ON t3.n_regionkey = t4.r_regionkey +INNER JOIN tpch_customer AS t5 + ON t3.n_nationkey = t5.c_nationkey \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_lower_projection_sort_key/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_lower_projection_sort_key/out.sql index 5439e662cff9f..db3c0e884dc68 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_lower_projection_sort_key/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_lower_projection_sort_key/out.sql @@ -1,11 +1,11 @@ SELECT - t5.foo_id AS foo_id, - t5.total AS total, - t5.value1 AS value1 + t6.foo_id AS foo_id, + t6.total AS total, + t6.value1 AS value1 FROM ( SELECT - t3.foo_id AS foo_id, - t3.total AS total, + t4.foo_id AS foo_id, + t4.total AS total, t2.value1 AS value1 FROM ( SELECT @@ -14,11 +14,11 @@ FROM ( FROM star1 AS t0 GROUP BY 1 - ) AS t3 + ) AS t4 INNER JOIN star2 AS t2 - ON t3.foo_id = t2.foo_id -) AS t5 + ON t4.foo_id = t2.foo_id +) AS t6 WHERE - t5.total > CAST(100 AS TINYINT) + t6.total > CAST(100 AS TINYINT) ORDER BY - t5.total DESC \ No newline at end of file + t6.total DESC \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_multi_join/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_multi_join/out.sql index 724bdbee44e26..f3368bf304aed 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_multi_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_multi_join/out.sql @@ -1,20 +1,20 @@ SELECT - t0.x1 AS x1, - t0.y1 AS y1, - t4.x2 AS x2, - t9.x3 AS x3, - t9.y2 AS y2, - t9.x4 AS x4 -FROM t1 AS t0 -INNER JOIN t2 AS t4 - ON t0.x1 = t4.x2 + t4.x1 AS x1, + t4.y1 AS y1, + t5.x2 AS x2, + t11.x3 AS x3, + t11.y2 AS y2, + t11.x4 AS x4 +FROM t1 AS t4 +INNER JOIN t2 AS t5 + ON t4.x1 = t5.x2 INNER JOIN ( SELECT - t2.x3 AS x3, - t2.y2 AS y2, - t5.x4 AS x4 - FROM t3 AS t2 - INNER JOIN t4 AS t5 - ON t2.x3 = t5.x4 -) AS t9 - ON t0.y1 = t9.y2 \ No newline at end of file + t6.x3 AS x3, + t6.y2 AS y2, + t7.x4 AS x4 + FROM t3 AS t6 + INNER JOIN t4 AS t7 + ON t6.x3 = t7.x4 +) AS t11 + ON t4.y1 = t11.y2 \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_no_cart_join/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_no_cart_join/out.sql index 6bcd1a8cecc49..df19a2ce88577 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_no_cart_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_no_cart_join/out.sql @@ -1,19 +1,19 @@ SELECT - t6.ancestor_node_sort_order AS ancestor_node_sort_order, - t6.n AS n + t7.ancestor_node_sort_order AS ancestor_node_sort_order, + t7.n AS n FROM ( SELECT - t5.ancestor_node_sort_order AS ancestor_node_sort_order, + t6.ancestor_node_sort_order AS ancestor_node_sort_order, CAST(1 AS TINYINT) AS n FROM ( SELECT - t0.product_id AS product_id, - t3.ancestor_level_name AS ancestor_level_name, - t3.ancestor_level_number AS ancestor_level_number, - t3.ancestor_node_sort_order AS ancestor_node_sort_order, - t3.descendant_node_natural_key AS descendant_node_natural_key, - t3.product_level_name AS product_level_name - FROM facts AS t0 + t2.product_id AS product_id, + t4.ancestor_level_name AS ancestor_level_name, + t4.ancestor_level_number AS ancestor_level_number, + t4.ancestor_node_sort_order AS ancestor_node_sort_order, + t4.descendant_node_natural_key AS descendant_node_natural_key, + t4.product_level_name AS product_level_name + FROM facts AS t2 INNER JOIN ( SELECT t1.ancestor_level_name AS ancestor_level_name, @@ -27,11 +27,11 @@ FROM ( t1.ancestor_level_name ) AS product_level_name FROM products AS t1 - ) AS t3 - ON t0.product_id = t3.descendant_node_natural_key - ) AS t5 + ) AS t4 + ON t2.product_id = t4.descendant_node_natural_key + ) AS t6 GROUP BY 1 -) AS t6 +) AS t7 ORDER BY - t6.ancestor_node_sort_order ASC \ No newline at end of file + t7.ancestor_node_sort_order ASC \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_no_cartesian_join/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_no_cartesian_join/out.sql index 4949ecd7d0964..00a954bff57ae 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_no_cartesian_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_no_cartesian_join/out.sql @@ -1,29 +1,29 @@ SELECT - t12.customer_id AS customer_id, - t12.first_name AS first_name, - t12.last_name AS last_name, - t12.first_order AS first_order, - t12.most_recent_order AS most_recent_order, - t12.number_of_orders AS number_of_orders, - t11.total_amount AS customer_lifetime_value + t15.customer_id AS customer_id, + t15.first_name AS first_name, + t15.last_name AS last_name, + t15.first_order AS first_order, + t15.most_recent_order AS most_recent_order, + t15.number_of_orders AS number_of_orders, + t13.total_amount AS customer_lifetime_value FROM ( SELECT - t10.customer_id AS customer_id, - t10.first_name AS first_name, - t10.last_name AS last_name, - t10.first_order AS first_order, - t10.most_recent_order AS most_recent_order, - t10.number_of_orders AS number_of_orders + t12.customer_id AS customer_id, + t12.first_name AS first_name, + t12.last_name AS last_name, + t12.first_order AS first_order, + t12.most_recent_order AS most_recent_order, + t12.number_of_orders AS number_of_orders FROM ( SELECT - t0.customer_id AS customer_id, - t0.first_name AS first_name, - t0.last_name AS last_name, - t6.customer_id AS customer_id_right, - t6.first_order AS first_order, - t6.most_recent_order AS most_recent_order, - t6.number_of_orders AS number_of_orders - FROM customers AS t0 + t3.customer_id AS customer_id, + t3.first_name AS first_name, + t3.last_name AS last_name, + t8.customer_id AS customer_id_right, + t8.first_order AS first_order, + t8.most_recent_order AS most_recent_order, + t8.number_of_orders AS number_of_orders + FROM customers AS t3 LEFT OUTER JOIN ( SELECT t2.customer_id AS customer_id, @@ -33,29 +33,29 @@ FROM ( FROM orders AS t2 GROUP BY 1 - ) AS t6 - ON t0.customer_id = t6.customer_id - ) AS t10 -) AS t12 + ) AS t8 + ON t3.customer_id = t8.customer_id + ) AS t12 +) AS t15 LEFT OUTER JOIN ( SELECT - t7.customer_id AS customer_id, - SUM(t7.amount) AS total_amount + t9.customer_id AS customer_id, + SUM(t9.amount) AS total_amount FROM ( SELECT - t1.payment_id AS payment_id, - t1.order_id AS order_id, - t1.payment_method AS payment_method, - t1.amount AS amount, - t3.order_id AS order_id_right, - t3.customer_id AS customer_id, - t3.order_date AS order_date, - t3.status AS status - FROM payments AS t1 - LEFT OUTER JOIN orders AS t3 - ON t1.order_id = t3.order_id - ) AS t7 + t4.payment_id AS payment_id, + t4.order_id AS order_id, + t4.payment_method AS payment_method, + t4.amount AS amount, + t5.order_id AS order_id_right, + t5.customer_id AS customer_id, + t5.order_date AS order_date, + t5.status AS status + FROM payments AS t4 + LEFT OUTER JOIN orders AS t5 + ON t4.order_id = t5.order_id + ) AS t9 GROUP BY 1 -) AS t11 - ON t12.customer_id = t11.customer_id \ No newline at end of file +) AS t13 + ON t15.customer_id = t13.customer_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_no_cross_join/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_no_cross_join/out.sql index cc11f692db3eb..17c83f6d66275 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_no_cross_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_no_cross_join/out.sql @@ -1,16 +1,16 @@ SELECT - t0.id AS id, - t0.personal AS personal, - t0.family AS family, - t3.taken AS taken, - t3.person AS person, - t3.quant AS quant, - t3.reading AS reading, - t4.id AS id_right, - t4.site AS site, - t4.dated AS dated -FROM person AS t0 -INNER JOIN survey AS t3 - ON t0.id = t3.person -INNER JOIN visited AS t4 - ON t4.id = t3.taken \ No newline at end of file + t3.id AS id, + t3.personal AS personal, + t3.family AS family, + t4.taken AS taken, + t4.person AS person, + t4.quant AS quant, + t4.reading AS reading, + t5.id AS id_right, + t5.site AS site, + t5.dated AS dated +FROM person AS t3 +INNER JOIN survey AS t4 + ON t3.id = t4.person +INNER JOIN visited AS t5 + ON t5.id = t4.taken \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_self_reference_join/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_self_reference_join/out.sql index de06d3805e28e..c4aa7aae68fb2 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_self_reference_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_self_reference_join/out.sql @@ -1,8 +1,8 @@ SELECT - t0.c AS c, - t0.f AS f, - t0.foo_id AS foo_id, - t0.bar_id AS bar_id -FROM star1 AS t0 -INNER JOIN star1 AS t1 - ON t0.foo_id = t1.bar_id \ No newline at end of file + t1.c AS c, + t1.f AS f, + t1.foo_id AS foo_id, + t1.bar_id AS bar_id +FROM star1 AS t1 +INNER JOIN star1 AS t2 + ON t1.foo_id = t2.bar_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_subquery_aliased/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_subquery_aliased/out.sql index 31853a46b4443..02680ad0e2f57 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_subquery_aliased/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_subquery_aliased/out.sql @@ -1,6 +1,6 @@ SELECT - t3.foo_id AS foo_id, - t3.total AS total, + t4.foo_id AS foo_id, + t4.total AS total, t2.value1 AS value1 FROM ( SELECT @@ -9,6 +9,6 @@ FROM ( FROM star1 AS t0 GROUP BY 1 -) AS t3 +) AS t4 INNER JOIN star2 AS t2 - ON t3.foo_id = t2.foo_id \ No newline at end of file + ON t4.foo_id = t2.foo_id \ No newline at end of file diff --git a/ibis/backends/tests/sql/snapshots/test_sql/test_where_correlated_subquery_with_join/out.sql b/ibis/backends/tests/sql/snapshots/test_sql/test_where_correlated_subquery_with_join/out.sql index f889080fd4abb..44fee8a3ce4cf 100644 --- a/ibis/backends/tests/sql/snapshots/test_sql/test_where_correlated_subquery_with_join/out.sql +++ b/ibis/backends/tests/sql/snapshots/test_sql/test_where_correlated_subquery_with_join/out.sql @@ -1,31 +1,31 @@ SELECT - t7.p_partkey AS p_partkey, - t7.ps_supplycost AS ps_supplycost + t9.p_partkey AS p_partkey, + t9.ps_supplycost AS ps_supplycost FROM ( SELECT - t0.p_partkey AS p_partkey, - t3.ps_supplycost AS ps_supplycost - FROM part AS t0 - INNER JOIN partsupp AS t3 - ON t0.p_partkey = t3.ps_partkey -) AS t7 + t3.p_partkey AS p_partkey, + t4.ps_supplycost AS ps_supplycost + FROM part AS t3 + INNER JOIN partsupp AS t4 + ON t3.p_partkey = t4.ps_partkey +) AS t9 WHERE - t7.ps_supplycost = ( + t9.ps_supplycost = ( SELECT - MIN(t9.ps_supplycost) AS "Min(ps_supplycost)" + MIN(t11.ps_supplycost) AS "Min(ps_supplycost)" FROM ( SELECT - t8.ps_partkey AS ps_partkey, - t8.ps_supplycost AS ps_supplycost + t10.ps_partkey AS ps_partkey, + t10.ps_supplycost AS ps_supplycost FROM ( SELECT - t1.ps_partkey AS ps_partkey, - t1.ps_supplycost AS ps_supplycost - FROM partsupp AS t1 - INNER JOIN supplier AS t4 - ON t4.s_suppkey = t1.ps_suppkey - ) AS t8 + t5.ps_partkey AS ps_partkey, + t5.ps_supplycost AS ps_supplycost + FROM partsupp AS t5 + INNER JOIN supplier AS t6 + ON t6.s_suppkey = t5.ps_suppkey + ) AS t10 WHERE - t8.ps_partkey = t7.p_partkey - ) AS t9 + t10.ps_partkey = t9.p_partkey + ) AS t11 ) \ No newline at end of file