From cabd7e88fd8878d8a3294aeec558d049a1195205 Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Thu, 14 Dec 2023 05:28:05 -0500 Subject: [PATCH] [sql 207/208] chore(snowflake): regen tpch sql --- .../test_h01/test_tpc_h01/snowflake/h01.sql | 85 +++-- .../test_h02/test_tpc_h02/snowflake/h02.sql | 356 +++++++++--------- .../test_h03/test_tpc_h03/snowflake/h03.sql | 246 ++++++------ .../test_h04/test_tpc_h04/snowflake/h04.sql | 84 ++--- .../test_h05/test_tpc_h05/snowflake/h05.sql | 176 +++++---- .../test_h06/test_tpc_h06/snowflake/h06.sql | 56 ++- .../test_h08/test_tpc_h08/snowflake/h08.sql | 255 ++++++------- .../test_h09/test_tpc_h09/snowflake/h09.sql | 55 +-- .../test_h10/test_tpc_h10/snowflake/h10.sql | 298 ++++++++------- .../test_h11/test_tpc_h11/snowflake/h11.sql | 265 +++++++------ .../test_h12/test_tpc_h12/snowflake/h12.sql | 98 +++-- .../test_h13/test_tpc_h13/snowflake/h13.sql | 43 +-- .../test_h14/test_tpc_h14/snowflake/h14.sql | 68 ++-- .../test_h15/test_tpc_h15/snowflake/h15.sql | 200 +++++----- .../test_h16/test_tpc_h16/snowflake/h16.sql | 108 +++--- .../test_h18/test_tpc_h18/snowflake/h18.sql | 181 +++++---- .../test_h19/test_tpc_h19/snowflake/h19.sql | 136 ++++--- .../test_h20/test_tpc_h20/snowflake/h20.sql | 200 ++++------ .../test_h21/test_tpc_h21/snowflake/h21.sql | 147 ++++---- .../test_h22/test_tpc_h22/snowflake/h22.sql | 117 ++---- 20 files changed, 1604 insertions(+), 1570 deletions(-) diff --git a/ibis/backends/tests/tpch/snapshots/test_h01/test_tpc_h01/snowflake/h01.sql b/ibis/backends/tests/tpch/snapshots/test_h01/test_tpc_h01/snowflake/h01.sql index 85aa49c35512e..9f1cf92c38e25 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h01/test_tpc_h01/snowflake/h01.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h01/test_tpc_h01/snowflake/h01.sql @@ -1,59 +1,62 @@ SELECT - * + "t2"."l_returnflag" AS "l_returnflag", + "t2"."l_linestatus" AS "l_linestatus", + "t2"."sum_qty" AS "sum_qty", + "t2"."sum_base_price" AS "sum_base_price", + "t2"."sum_disc_price" AS "sum_disc_price", + "t2"."sum_charge" AS "sum_charge", + "t2"."avg_qty" AS "avg_qty", + "t2"."avg_price" AS "avg_price", + "t2"."avg_disc" AS "avg_disc", + "t2"."count_order" AS "count_order" FROM ( SELECT - "t2"."l_returnflag" AS "l_returnflag", - "t2"."l_linestatus" AS "l_linestatus", - SUM("t2"."l_quantity") AS "sum_qty", - SUM("t2"."l_extendedprice") AS "sum_base_price", - SUM("t2"."l_extendedprice" * ( - 1 - "t2"."l_discount" + "t1"."l_returnflag" AS "l_returnflag", + "t1"."l_linestatus" AS "l_linestatus", + SUM("t1"."l_quantity") AS "sum_qty", + SUM("t1"."l_extendedprice") AS "sum_base_price", + SUM("t1"."l_extendedprice" * ( + 1 - "t1"."l_discount" )) AS "sum_disc_price", SUM( ( - "t2"."l_extendedprice" * ( - 1 - "t2"."l_discount" + "t1"."l_extendedprice" * ( + 1 - "t1"."l_discount" ) ) * ( - "t2"."l_tax" + 1 + "t1"."l_tax" + 1 ) ) AS "sum_charge", - AVG("t2"."l_quantity") AS "avg_qty", - AVG("t2"."l_extendedprice") AS "avg_price", - AVG("t2"."l_discount") AS "avg_disc", + AVG("t1"."l_quantity") AS "avg_qty", + AVG("t1"."l_extendedprice") AS "avg_price", + AVG("t1"."l_discount") AS "avg_disc", COUNT(*) AS "count_order" FROM ( SELECT - * - FROM ( - SELECT - "t0"."L_ORDERKEY" AS "l_orderkey", - "t0"."L_PARTKEY" AS "l_partkey", - "t0"."L_SUPPKEY" AS "l_suppkey", - "t0"."L_LINENUMBER" AS "l_linenumber", - "t0"."L_QUANTITY" AS "l_quantity", - "t0"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t0"."L_DISCOUNT" AS "l_discount", - "t0"."L_TAX" AS "l_tax", - "t0"."L_RETURNFLAG" AS "l_returnflag", - "t0"."L_LINESTATUS" AS "l_linestatus", - "t0"."L_SHIPDATE" AS "l_shipdate", - "t0"."L_COMMITDATE" AS "l_commitdate", - "t0"."L_RECEIPTDATE" AS "l_receiptdate", - "t0"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t0"."L_SHIPMODE" AS "l_shipmode", - "t0"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t0" - ) AS "t1" + "t0"."L_ORDERKEY" AS "l_orderkey", + "t0"."L_PARTKEY" AS "l_partkey", + "t0"."L_SUPPKEY" AS "l_suppkey", + "t0"."L_LINENUMBER" AS "l_linenumber", + "t0"."L_QUANTITY" AS "l_quantity", + "t0"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t0"."L_DISCOUNT" AS "l_discount", + "t0"."L_TAX" AS "l_tax", + "t0"."L_RETURNFLAG" AS "l_returnflag", + "t0"."L_LINESTATUS" AS "l_linestatus", + "t0"."L_SHIPDATE" AS "l_shipdate", + "t0"."L_COMMITDATE" AS "l_commitdate", + "t0"."L_RECEIPTDATE" AS "l_receiptdate", + "t0"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t0"."L_SHIPMODE" AS "l_shipmode", + "t0"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t0" WHERE - ( - "t1"."l_shipdate" <= DATEFROMPARTS(1998, 9, 2) - ) - ) AS "t2" + "t0"."L_SHIPDATE" <= DATEFROMPARTS(1998, 9, 2) + ) AS "t1" GROUP BY 1, 2 -) AS "t3" +) AS "t2" ORDER BY - "t3"."l_returnflag" ASC, - "t3"."l_linestatus" ASC \ No newline at end of file + "t2"."l_returnflag" ASC, + "t2"."l_linestatus" ASC \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h02/test_tpc_h02/snowflake/h02.sql b/ibis/backends/tests/tpch/snapshots/test_h02/test_tpc_h02/snowflake/h02.sql index dcdbc5f581637..01cfa3a33d2e1 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h02/test_tpc_h02/snowflake/h02.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h02/test_tpc_h02/snowflake/h02.sql @@ -1,190 +1,190 @@ SELECT - * + "t24"."s_acctbal" AS "s_acctbal", + "t24"."s_name" AS "s_name", + "t24"."n_name" AS "n_name", + "t24"."p_partkey" AS "p_partkey", + "t24"."p_mfgr" AS "p_mfgr", + "t24"."s_address" AS "s_address", + "t24"."s_phone" AS "s_phone", + "t24"."s_comment" AS "s_comment" FROM ( SELECT - "t18"."s_acctbal" AS "s_acctbal", - "t18"."s_name" AS "s_name", - "t18"."n_name" AS "n_name", - "t18"."p_partkey" AS "p_partkey", - "t18"."p_mfgr" AS "p_mfgr", - "t18"."s_address" AS "s_address", - "t18"."s_phone" AS "s_phone", - "t18"."s_comment" AS "s_comment" + "t5"."p_partkey" AS "p_partkey", + "t5"."p_name" AS "p_name", + "t5"."p_mfgr" AS "p_mfgr", + "t5"."p_brand" AS "p_brand", + "t5"."p_type" AS "p_type", + "t5"."p_size" AS "p_size", + "t5"."p_container" AS "p_container", + "t5"."p_retailprice" AS "p_retailprice", + "t5"."p_comment" AS "p_comment", + "t10"."ps_partkey" AS "ps_partkey", + "t10"."ps_suppkey" AS "ps_suppkey", + "t10"."ps_availqty" AS "ps_availqty", + "t10"."ps_supplycost" AS "ps_supplycost", + "t10"."ps_comment" AS "ps_comment", + "t11"."s_suppkey" AS "s_suppkey", + "t11"."s_name" AS "s_name", + "t11"."s_address" AS "s_address", + "t11"."s_nationkey" AS "s_nationkey", + "t11"."s_phone" AS "s_phone", + "t11"."s_acctbal" AS "s_acctbal", + "t11"."s_comment" AS "s_comment", + "t13"."n_nationkey" AS "n_nationkey", + "t13"."n_name" AS "n_name", + "t13"."n_regionkey" AS "n_regionkey", + "t13"."n_comment" AS "n_comment", + "t15"."r_regionkey" AS "r_regionkey", + "t15"."r_name" AS "r_name", + "t15"."r_comment" AS "r_comment" FROM ( SELECT - * + "t0"."P_PARTKEY" AS "p_partkey", + "t0"."P_NAME" AS "p_name", + "t0"."P_MFGR" AS "p_mfgr", + "t0"."P_BRAND" AS "p_brand", + "t0"."P_TYPE" AS "p_type", + "t0"."P_SIZE" AS "p_size", + "t0"."P_CONTAINER" AS "p_container", + "t0"."P_RETAILPRICE" AS "p_retailprice", + "t0"."P_COMMENT" AS "p_comment" + FROM "PART" AS "t0" + ) AS "t5" + INNER JOIN ( + SELECT + "t1"."PS_PARTKEY" AS "ps_partkey", + "t1"."PS_SUPPKEY" AS "ps_suppkey", + "t1"."PS_AVAILQTY" AS "ps_availqty", + "t1"."PS_SUPPLYCOST" AS "ps_supplycost", + "t1"."PS_COMMENT" AS "ps_comment" + FROM "PARTSUPP" AS "t1" + ) AS "t10" + ON "t5"."p_partkey" = "t10"."ps_partkey" + INNER JOIN ( + SELECT + "t2"."S_SUPPKEY" AS "s_suppkey", + "t2"."S_NAME" AS "s_name", + "t2"."S_ADDRESS" AS "s_address", + "t2"."S_NATIONKEY" AS "s_nationkey", + "t2"."S_PHONE" AS "s_phone", + "t2"."S_ACCTBAL" AS "s_acctbal", + "t2"."S_COMMENT" AS "s_comment" + FROM "SUPPLIER" AS "t2" + ) AS "t11" + ON "t11"."s_suppkey" = "t10"."ps_suppkey" + INNER JOIN ( + SELECT + "t3"."N_NATIONKEY" AS "n_nationkey", + "t3"."N_NAME" AS "n_name", + "t3"."N_REGIONKEY" AS "n_regionkey", + "t3"."N_COMMENT" AS "n_comment" + FROM "NATION" AS "t3" + ) AS "t13" + ON "t11"."s_nationkey" = "t13"."n_nationkey" + INNER JOIN ( + SELECT + "t4"."R_REGIONKEY" AS "r_regionkey", + "t4"."R_NAME" AS "r_name", + "t4"."R_COMMENT" AS "r_comment" + FROM "REGION" AS "t4" + ) AS "t15" + ON "t13"."n_regionkey" = "t15"."r_regionkey" +) AS "t24" +WHERE + "t24"."p_size" = 15 + AND "t24"."p_type" LIKE '%BRASS' + AND "t24"."r_name" = 'EUROPE' + AND "t24"."ps_supplycost" = ( + SELECT + MIN("t26"."ps_supplycost") AS "Min(ps_supplycost)" FROM ( SELECT - "t5"."p_partkey" AS "p_partkey", - "t5"."p_name" AS "p_name", - "t5"."p_mfgr" AS "p_mfgr", - "t5"."p_brand" AS "p_brand", - "t5"."p_type" AS "p_type", - "t5"."p_size" AS "p_size", - "t5"."p_container" AS "p_container", - "t5"."p_retailprice" AS "p_retailprice", - "t5"."p_comment" AS "p_comment", - "t6"."ps_partkey" AS "ps_partkey", - "t6"."ps_suppkey" AS "ps_suppkey", - "t6"."ps_availqty" AS "ps_availqty", - "t6"."ps_supplycost" AS "ps_supplycost", - "t6"."ps_comment" AS "ps_comment", - "t7"."s_suppkey" AS "s_suppkey", - "t7"."s_name" AS "s_name", - "t7"."s_address" AS "s_address", - "t7"."s_nationkey" AS "s_nationkey", - "t7"."s_phone" AS "s_phone", - "t7"."s_acctbal" AS "s_acctbal", - "t7"."s_comment" AS "s_comment", - "t8"."n_nationkey" AS "n_nationkey", - "t8"."n_name" AS "n_name", - "t8"."n_regionkey" AS "n_regionkey", - "t8"."n_comment" AS "n_comment", - "t9"."r_regionkey" AS "r_regionkey", - "t9"."r_name" AS "r_name", - "t9"."r_comment" AS "r_comment" + "t25"."ps_partkey" AS "ps_partkey", + "t25"."ps_suppkey" AS "ps_suppkey", + "t25"."ps_availqty" AS "ps_availqty", + "t25"."ps_supplycost" AS "ps_supplycost", + "t25"."ps_comment" AS "ps_comment", + "t25"."s_suppkey" AS "s_suppkey", + "t25"."s_name" AS "s_name", + "t25"."s_address" AS "s_address", + "t25"."s_nationkey" AS "s_nationkey", + "t25"."s_phone" AS "s_phone", + "t25"."s_acctbal" AS "s_acctbal", + "t25"."s_comment" AS "s_comment", + "t25"."n_nationkey" AS "n_nationkey", + "t25"."n_name" AS "n_name", + "t25"."n_regionkey" AS "n_regionkey", + "t25"."n_comment" AS "n_comment", + "t25"."r_regionkey" AS "r_regionkey", + "t25"."r_name" AS "r_name", + "t25"."r_comment" AS "r_comment" FROM ( SELECT - "t0"."P_PARTKEY" AS "p_partkey", - "t0"."P_NAME" AS "p_name", - "t0"."P_MFGR" AS "p_mfgr", - "t0"."P_BRAND" AS "p_brand", - "t0"."P_TYPE" AS "p_type", - "t0"."P_SIZE" AS "p_size", - "t0"."P_CONTAINER" AS "p_container", - "t0"."P_RETAILPRICE" AS "p_retailprice", - "t0"."P_COMMENT" AS "p_comment" - FROM "PART" AS "t0" - ) AS "t5" - INNER JOIN ( - SELECT - "t1"."PS_PARTKEY" AS "ps_partkey", - "t1"."PS_SUPPKEY" AS "ps_suppkey", - "t1"."PS_AVAILQTY" AS "ps_availqty", - "t1"."PS_SUPPLYCOST" AS "ps_supplycost", - "t1"."PS_COMMENT" AS "ps_comment" - FROM "PARTSUPP" AS "t1" - ) AS "t6" - ON "t5"."p_partkey" = "t6"."ps_partkey" - INNER JOIN ( - SELECT - "t2"."S_SUPPKEY" AS "s_suppkey", - "t2"."S_NAME" AS "s_name", - "t2"."S_ADDRESS" AS "s_address", - "t2"."S_NATIONKEY" AS "s_nationkey", - "t2"."S_PHONE" AS "s_phone", - "t2"."S_ACCTBAL" AS "s_acctbal", - "t2"."S_COMMENT" AS "s_comment" - FROM "SUPPLIER" AS "t2" - ) AS "t7" - ON "t7"."s_suppkey" = "t6"."ps_suppkey" - INNER JOIN ( - SELECT - "t3"."N_NATIONKEY" AS "n_nationkey", - "t3"."N_NAME" AS "n_name", - "t3"."N_REGIONKEY" AS "n_regionkey", - "t3"."N_COMMENT" AS "n_comment" - FROM "NATION" AS "t3" - ) AS "t8" - ON "t7"."s_nationkey" = "t8"."n_nationkey" - INNER JOIN ( - SELECT - "t4"."R_REGIONKEY" AS "r_regionkey", - "t4"."R_NAME" AS "r_name", - "t4"."R_COMMENT" AS "r_comment" - FROM "REGION" AS "t4" - ) AS "t9" - ON "t8"."n_regionkey" = "t9"."r_regionkey" - ) AS "t14" - WHERE - ( - "t14"."p_size" = 15 - ) - AND "t14"."p_type" LIKE '%BRASS' - AND ( - "t14"."r_name" = 'EUROPE' - ) - AND ( - "t14"."ps_supplycost" = ( + "t6"."ps_partkey" AS "ps_partkey", + "t6"."ps_suppkey" AS "ps_suppkey", + "t6"."ps_availqty" AS "ps_availqty", + "t6"."ps_supplycost" AS "ps_supplycost", + "t6"."ps_comment" AS "ps_comment", + "t12"."s_suppkey" AS "s_suppkey", + "t12"."s_name" AS "s_name", + "t12"."s_address" AS "s_address", + "t12"."s_nationkey" AS "s_nationkey", + "t12"."s_phone" AS "s_phone", + "t12"."s_acctbal" AS "s_acctbal", + "t12"."s_comment" AS "s_comment", + "t14"."n_nationkey" AS "n_nationkey", + "t14"."n_name" AS "n_name", + "t14"."n_regionkey" AS "n_regionkey", + "t14"."n_comment" AS "n_comment", + "t16"."r_regionkey" AS "r_regionkey", + "t16"."r_name" AS "r_name", + "t16"."r_comment" AS "r_comment" + FROM ( + SELECT + "t1"."PS_PARTKEY" AS "ps_partkey", + "t1"."PS_SUPPKEY" AS "ps_suppkey", + "t1"."PS_AVAILQTY" AS "ps_availqty", + "t1"."PS_SUPPLYCOST" AS "ps_supplycost", + "t1"."PS_COMMENT" AS "ps_comment" + FROM "PARTSUPP" AS "t1" + ) AS "t6" + INNER JOIN ( + SELECT + "t2"."S_SUPPKEY" AS "s_suppkey", + "t2"."S_NAME" AS "s_name", + "t2"."S_ADDRESS" AS "s_address", + "t2"."S_NATIONKEY" AS "s_nationkey", + "t2"."S_PHONE" AS "s_phone", + "t2"."S_ACCTBAL" AS "s_acctbal", + "t2"."S_COMMENT" AS "s_comment" + FROM "SUPPLIER" AS "t2" + ) AS "t12" + ON "t12"."s_suppkey" = "t6"."ps_suppkey" + INNER JOIN ( + SELECT + "t3"."N_NATIONKEY" AS "n_nationkey", + "t3"."N_NAME" AS "n_name", + "t3"."N_REGIONKEY" AS "n_regionkey", + "t3"."N_COMMENT" AS "n_comment" + FROM "NATION" AS "t3" + ) AS "t14" + ON "t12"."s_nationkey" = "t14"."n_nationkey" + INNER JOIN ( SELECT - MIN("t16"."ps_supplycost") AS "Min(ps_supplycost)" - FROM ( - SELECT - * - FROM ( - SELECT - "t6"."ps_partkey" AS "ps_partkey", - "t6"."ps_suppkey" AS "ps_suppkey", - "t6"."ps_availqty" AS "ps_availqty", - "t6"."ps_supplycost" AS "ps_supplycost", - "t6"."ps_comment" AS "ps_comment", - "t7"."s_suppkey" AS "s_suppkey", - "t7"."s_name" AS "s_name", - "t7"."s_address" AS "s_address", - "t7"."s_nationkey" AS "s_nationkey", - "t7"."s_phone" AS "s_phone", - "t7"."s_acctbal" AS "s_acctbal", - "t7"."s_comment" AS "s_comment", - "t8"."n_nationkey" AS "n_nationkey", - "t8"."n_name" AS "n_name", - "t8"."n_regionkey" AS "n_regionkey", - "t8"."n_comment" AS "n_comment", - "t9"."r_regionkey" AS "r_regionkey", - "t9"."r_name" AS "r_name", - "t9"."r_comment" AS "r_comment" - FROM ( - SELECT - "t1"."PS_PARTKEY" AS "ps_partkey", - "t1"."PS_SUPPKEY" AS "ps_suppkey", - "t1"."PS_AVAILQTY" AS "ps_availqty", - "t1"."PS_SUPPLYCOST" AS "ps_supplycost", - "t1"."PS_COMMENT" AS "ps_comment" - FROM "PARTSUPP" AS "t1" - ) AS "t6" - INNER JOIN ( - SELECT - "t2"."S_SUPPKEY" AS "s_suppkey", - "t2"."S_NAME" AS "s_name", - "t2"."S_ADDRESS" AS "s_address", - "t2"."S_NATIONKEY" AS "s_nationkey", - "t2"."S_PHONE" AS "s_phone", - "t2"."S_ACCTBAL" AS "s_acctbal", - "t2"."S_COMMENT" AS "s_comment" - FROM "SUPPLIER" AS "t2" - ) AS "t7" - ON "t7"."s_suppkey" = "t6"."ps_suppkey" - INNER JOIN ( - SELECT - "t3"."N_NATIONKEY" AS "n_nationkey", - "t3"."N_NAME" AS "n_name", - "t3"."N_REGIONKEY" AS "n_regionkey", - "t3"."N_COMMENT" AS "n_comment" - FROM "NATION" AS "t3" - ) AS "t8" - ON "t7"."s_nationkey" = "t8"."n_nationkey" - INNER JOIN ( - SELECT - "t4"."R_REGIONKEY" AS "r_regionkey", - "t4"."R_NAME" AS "r_name", - "t4"."R_COMMENT" AS "r_comment" - FROM "REGION" AS "t4" - ) AS "t9" - ON "t8"."n_regionkey" = "t9"."r_regionkey" - ) AS "t15" - WHERE - ( - "t15"."r_name" = 'EUROPE' - ) AND ( - "t14"."p_partkey" = "t15"."ps_partkey" - ) - ) AS "t16" - ) - ) - ) AS "t18" -) AS "t19" + "t4"."R_REGIONKEY" AS "r_regionkey", + "t4"."R_NAME" AS "r_name", + "t4"."R_COMMENT" AS "r_comment" + FROM "REGION" AS "t4" + ) AS "t16" + ON "t14"."n_regionkey" = "t16"."r_regionkey" + ) AS "t25" + WHERE + "t25"."r_name" = 'EUROPE' AND "t24"."p_partkey" = "t25"."ps_partkey" + ) AS "t26" + ) ORDER BY - "t19"."s_acctbal" DESC NULLS LAST, - "t19"."n_name" ASC, - "t19"."s_name" ASC, - "t19"."p_partkey" ASC + "t24"."s_acctbal" DESC NULLS LAST, + "t24"."n_name" ASC, + "t24"."s_name" ASC, + "t24"."p_partkey" ASC LIMIT 100 \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h03/test_tpc_h03/snowflake/h03.sql b/ibis/backends/tests/tpch/snapshots/test_h03/test_tpc_h03/snowflake/h03.sql index 8a11e34442991..13a8f7da2bd2d 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h03/test_tpc_h03/snowflake/h03.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h03/test_tpc_h03/snowflake/h03.sql @@ -1,123 +1,145 @@ SELECT - * + "t12"."l_orderkey" AS "l_orderkey", + "t12"."revenue" AS "revenue", + "t12"."o_orderdate" AS "o_orderdate", + "t12"."o_shippriority" AS "o_shippriority" FROM ( SELECT - "t10"."l_orderkey" AS "l_orderkey", - "t10"."revenue" AS "revenue", - "t10"."o_orderdate" AS "o_orderdate", - "t10"."o_shippriority" AS "o_shippriority" + "t11"."l_orderkey" AS "l_orderkey", + "t11"."o_orderdate" AS "o_orderdate", + "t11"."o_shippriority" AS "o_shippriority", + SUM("t11"."l_extendedprice" * ( + 1 - "t11"."l_discount" + )) AS "revenue" FROM ( SELECT - "t9"."l_orderkey" AS "l_orderkey", - "t9"."o_orderdate" AS "o_orderdate", - "t9"."o_shippriority" AS "o_shippriority", - SUM("t9"."l_extendedprice" * ( - 1 - "t9"."l_discount" - )) AS "revenue" + "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"."o_orderkey" AS "o_orderkey", + "t10"."o_custkey" AS "o_custkey", + "t10"."o_orderstatus" AS "o_orderstatus", + "t10"."o_totalprice" AS "o_totalprice", + "t10"."o_orderdate" AS "o_orderdate", + "t10"."o_orderpriority" AS "o_orderpriority", + "t10"."o_clerk" AS "o_clerk", + "t10"."o_shippriority" AS "o_shippriority", + "t10"."o_comment" AS "o_comment", + "t10"."l_orderkey" AS "l_orderkey", + "t10"."l_partkey" AS "l_partkey", + "t10"."l_suppkey" AS "l_suppkey", + "t10"."l_linenumber" AS "l_linenumber", + "t10"."l_quantity" AS "l_quantity", + "t10"."l_extendedprice" AS "l_extendedprice", + "t10"."l_discount" AS "l_discount", + "t10"."l_tax" AS "l_tax", + "t10"."l_returnflag" AS "l_returnflag", + "t10"."l_linestatus" AS "l_linestatus", + "t10"."l_shipdate" AS "l_shipdate", + "t10"."l_commitdate" AS "l_commitdate", + "t10"."l_receiptdate" AS "l_receiptdate", + "t10"."l_shipinstruct" AS "l_shipinstruct", + "t10"."l_shipmode" AS "l_shipmode", + "t10"."l_comment" AS "l_comment" FROM ( SELECT - * + "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", + "t6"."o_orderkey" AS "o_orderkey", + "t6"."o_custkey" AS "o_custkey", + "t6"."o_orderstatus" AS "o_orderstatus", + "t6"."o_totalprice" AS "o_totalprice", + "t6"."o_orderdate" AS "o_orderdate", + "t6"."o_orderpriority" AS "o_orderpriority", + "t6"."o_clerk" AS "o_clerk", + "t6"."o_shippriority" AS "o_shippriority", + "t6"."o_comment" AS "o_comment", + "t7"."l_orderkey" AS "l_orderkey", + "t7"."l_partkey" AS "l_partkey", + "t7"."l_suppkey" AS "l_suppkey", + "t7"."l_linenumber" AS "l_linenumber", + "t7"."l_quantity" AS "l_quantity", + "t7"."l_extendedprice" AS "l_extendedprice", + "t7"."l_discount" AS "l_discount", + "t7"."l_tax" AS "l_tax", + "t7"."l_returnflag" AS "l_returnflag", + "t7"."l_linestatus" AS "l_linestatus", + "t7"."l_shipdate" AS "l_shipdate", + "t7"."l_commitdate" AS "l_commitdate", + "t7"."l_receiptdate" AS "l_receiptdate", + "t7"."l_shipinstruct" AS "l_shipinstruct", + "t7"."l_shipmode" AS "l_shipmode", + "t7"."l_comment" AS "l_comment" FROM ( SELECT - "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"."o_orderkey" AS "o_orderkey", - "t4"."o_custkey" AS "o_custkey", - "t4"."o_orderstatus" AS "o_orderstatus", - "t4"."o_totalprice" AS "o_totalprice", - "t4"."o_orderdate" AS "o_orderdate", - "t4"."o_orderpriority" AS "o_orderpriority", - "t4"."o_clerk" AS "o_clerk", - "t4"."o_shippriority" AS "o_shippriority", - "t4"."o_comment" AS "o_comment", - "t5"."l_orderkey" AS "l_orderkey", - "t5"."l_partkey" AS "l_partkey", - "t5"."l_suppkey" AS "l_suppkey", - "t5"."l_linenumber" AS "l_linenumber", - "t5"."l_quantity" AS "l_quantity", - "t5"."l_extendedprice" AS "l_extendedprice", - "t5"."l_discount" AS "l_discount", - "t5"."l_tax" AS "l_tax", - "t5"."l_returnflag" AS "l_returnflag", - "t5"."l_linestatus" AS "l_linestatus", - "t5"."l_shipdate" AS "l_shipdate", - "t5"."l_commitdate" AS "l_commitdate", - "t5"."l_receiptdate" AS "l_receiptdate", - "t5"."l_shipinstruct" AS "l_shipinstruct", - "t5"."l_shipmode" AS "l_shipmode", - "t5"."l_comment" AS "l_comment" - 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" - FROM "CUSTOMER" AS "t0" - ) AS "t3" - INNER JOIN ( - SELECT - "t1"."O_ORDERKEY" AS "o_orderkey", - "t1"."O_CUSTKEY" AS "o_custkey", - "t1"."O_ORDERSTATUS" AS "o_orderstatus", - "t1"."O_TOTALPRICE" AS "o_totalprice", - "t1"."O_ORDERDATE" AS "o_orderdate", - "t1"."O_ORDERPRIORITY" AS "o_orderpriority", - "t1"."O_CLERK" AS "o_clerk", - "t1"."O_SHIPPRIORITY" AS "o_shippriority", - "t1"."O_COMMENT" AS "o_comment" - FROM "ORDERS" AS "t1" - ) AS "t4" - ON "t3"."c_custkey" = "t4"."o_custkey" - INNER JOIN ( - SELECT - "t2"."L_ORDERKEY" AS "l_orderkey", - "t2"."L_PARTKEY" AS "l_partkey", - "t2"."L_SUPPKEY" AS "l_suppkey", - "t2"."L_LINENUMBER" AS "l_linenumber", - "t2"."L_QUANTITY" AS "l_quantity", - "t2"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t2"."L_DISCOUNT" AS "l_discount", - "t2"."L_TAX" AS "l_tax", - "t2"."L_RETURNFLAG" AS "l_returnflag", - "t2"."L_LINESTATUS" AS "l_linestatus", - "t2"."L_SHIPDATE" AS "l_shipdate", - "t2"."L_COMMITDATE" AS "l_commitdate", - "t2"."L_RECEIPTDATE" AS "l_receiptdate", - "t2"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t2"."L_SHIPMODE" AS "l_shipmode", - "t2"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t2" - ) AS "t5" - ON "t5"."l_orderkey" = "t4"."o_orderkey" - ) AS "t8" - WHERE - ( - "t8"."c_mktsegment" = 'BUILDING' - ) - AND ( - "t8"."o_orderdate" < DATEFROMPARTS(1995, 3, 15) - ) - AND ( - "t8"."l_shipdate" > DATEFROMPARTS(1995, 3, 15) - ) - ) AS "t9" - GROUP BY - 1, - 2, - 3 - ) AS "t10" -) AS "t11" + "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" + FROM "CUSTOMER" AS "t0" + ) AS "t3" + INNER JOIN ( + SELECT + "t1"."O_ORDERKEY" AS "o_orderkey", + "t1"."O_CUSTKEY" AS "o_custkey", + "t1"."O_ORDERSTATUS" AS "o_orderstatus", + "t1"."O_TOTALPRICE" AS "o_totalprice", + "t1"."O_ORDERDATE" AS "o_orderdate", + "t1"."O_ORDERPRIORITY" AS "o_orderpriority", + "t1"."O_CLERK" AS "o_clerk", + "t1"."O_SHIPPRIORITY" AS "o_shippriority", + "t1"."O_COMMENT" AS "o_comment" + FROM "ORDERS" AS "t1" + ) AS "t6" + ON "t3"."c_custkey" = "t6"."o_custkey" + INNER JOIN ( + SELECT + "t2"."L_ORDERKEY" AS "l_orderkey", + "t2"."L_PARTKEY" AS "l_partkey", + "t2"."L_SUPPKEY" AS "l_suppkey", + "t2"."L_LINENUMBER" AS "l_linenumber", + "t2"."L_QUANTITY" AS "l_quantity", + "t2"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t2"."L_DISCOUNT" AS "l_discount", + "t2"."L_TAX" AS "l_tax", + "t2"."L_RETURNFLAG" AS "l_returnflag", + "t2"."L_LINESTATUS" AS "l_linestatus", + "t2"."L_SHIPDATE" AS "l_shipdate", + "t2"."L_COMMITDATE" AS "l_commitdate", + "t2"."L_RECEIPTDATE" AS "l_receiptdate", + "t2"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t2"."L_SHIPMODE" AS "l_shipmode", + "t2"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t2" + ) AS "t7" + ON "t7"."l_orderkey" = "t6"."o_orderkey" + ) AS "t10" + WHERE + "t10"."c_mktsegment" = 'BUILDING' + AND "t10"."o_orderdate" < DATEFROMPARTS(1995, 3, 15) + AND "t10"."l_shipdate" > DATEFROMPARTS(1995, 3, 15) + ) AS "t11" + GROUP BY + 1, + 2, + 3 +) AS "t12" ORDER BY - "t11"."revenue" DESC NULLS LAST, - "t11"."o_orderdate" ASC + "t12"."revenue" DESC NULLS LAST, + "t12"."o_orderdate" ASC LIMIT 10 \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h04/test_tpc_h04/snowflake/h04.sql b/ibis/backends/tests/tpch/snapshots/test_h04/test_tpc_h04/snowflake/h04.sql index c398eb7d90253..67291d6a36324 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h04/test_tpc_h04/snowflake/h04.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h04/test_tpc_h04/snowflake/h04.sql @@ -1,74 +1,42 @@ SELECT - * + "t4"."o_orderpriority" AS "o_orderpriority", + "t4"."order_count" AS "order_count" FROM ( SELECT - "t6"."o_orderpriority" AS "o_orderpriority", + "t3"."o_orderpriority" AS "o_orderpriority", COUNT(*) AS "order_count" FROM ( SELECT - * - FROM ( - SELECT - "t0"."O_ORDERKEY" AS "o_orderkey", - "t0"."O_CUSTKEY" AS "o_custkey", - "t0"."O_ORDERSTATUS" AS "o_orderstatus", - "t0"."O_TOTALPRICE" AS "o_totalprice", - "t0"."O_ORDERDATE" AS "o_orderdate", - "t0"."O_ORDERPRIORITY" AS "o_orderpriority", - "t0"."O_CLERK" AS "o_clerk", - "t0"."O_SHIPPRIORITY" AS "o_shippriority", - "t0"."O_COMMENT" AS "o_comment" - FROM "ORDERS" AS "t0" - ) AS "t2" + "t0"."O_ORDERKEY" AS "o_orderkey", + "t0"."O_CUSTKEY" AS "o_custkey", + "t0"."O_ORDERSTATUS" AS "o_orderstatus", + "t0"."O_TOTALPRICE" AS "o_totalprice", + "t0"."O_ORDERDATE" AS "o_orderdate", + "t0"."O_ORDERPRIORITY" AS "o_orderpriority", + "t0"."O_CLERK" AS "o_clerk", + "t0"."O_SHIPPRIORITY" AS "o_shippriority", + "t0"."O_COMMENT" AS "o_comment" + FROM "ORDERS" AS "t0" WHERE EXISTS( ( SELECT 1 AS "1" - FROM ( - SELECT - * - FROM ( - SELECT - "t1"."L_ORDERKEY" AS "l_orderkey", - "t1"."L_PARTKEY" AS "l_partkey", - "t1"."L_SUPPKEY" AS "l_suppkey", - "t1"."L_LINENUMBER" AS "l_linenumber", - "t1"."L_QUANTITY" AS "l_quantity", - "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t1"."L_DISCOUNT" AS "l_discount", - "t1"."L_TAX" AS "l_tax", - "t1"."L_RETURNFLAG" AS "l_returnflag", - "t1"."L_LINESTATUS" AS "l_linestatus", - "t1"."L_SHIPDATE" AS "l_shipdate", - "t1"."L_COMMITDATE" AS "l_commitdate", - "t1"."L_RECEIPTDATE" AS "l_receiptdate", - "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t1"."L_SHIPMODE" AS "l_shipmode", - "t1"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t1" - ) AS "t3" - WHERE - ( - ( - "t3"."l_orderkey" = "t2"."o_orderkey" - ) - AND ( - "t3"."l_commitdate" < "t3"."l_receiptdate" - ) - ) - ) AS "t4" + FROM "LINEITEM" AS "t1" + WHERE + ( + "t1"."L_ORDERKEY" = "t0"."O_ORDERKEY" + ) + AND ( + "t1"."L_COMMITDATE" < "t1"."L_RECEIPTDATE" + ) ) ) - AND ( - "t2"."o_orderdate" >= DATEFROMPARTS(1993, 7, 1) - ) - AND ( - "t2"."o_orderdate" < DATEFROMPARTS(1993, 10, 1) - ) - ) AS "t6" + AND "t0"."O_ORDERDATE" >= DATEFROMPARTS(1993, 7, 1) + AND "t0"."O_ORDERDATE" < DATEFROMPARTS(1993, 10, 1) + ) AS "t3" GROUP BY 1 -) AS "t7" +) AS "t4" ORDER BY - "t7"."o_orderpriority" ASC \ No newline at end of file + "t4"."o_orderpriority" ASC \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h05/test_tpc_h05/snowflake/h05.sql b/ibis/backends/tests/tpch/snapshots/test_h05/test_tpc_h05/snowflake/h05.sql index ebcdc72188a5d..4ec8d7241f0dd 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h05/test_tpc_h05/snowflake/h05.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h05/test_tpc_h05/snowflake/h05.sql @@ -1,14 +1,61 @@ SELECT - * + "t24"."n_name" AS "n_name", + "t24"."revenue" AS "revenue" FROM ( SELECT - "t18"."n_name" AS "n_name", - SUM("t18"."l_extendedprice" * ( - 1 - "t18"."l_discount" + "t23"."n_name" AS "n_name", + SUM("t23"."l_extendedprice" * ( + 1 - "t23"."l_discount" )) AS "revenue" FROM ( SELECT - * + "t22"."c_custkey" AS "c_custkey", + "t22"."c_name" AS "c_name", + "t22"."c_address" AS "c_address", + "t22"."c_nationkey" AS "c_nationkey", + "t22"."c_phone" AS "c_phone", + "t22"."c_acctbal" AS "c_acctbal", + "t22"."c_mktsegment" AS "c_mktsegment", + "t22"."c_comment" AS "c_comment", + "t22"."o_orderkey" AS "o_orderkey", + "t22"."o_custkey" AS "o_custkey", + "t22"."o_orderstatus" AS "o_orderstatus", + "t22"."o_totalprice" AS "o_totalprice", + "t22"."o_orderdate" AS "o_orderdate", + "t22"."o_orderpriority" AS "o_orderpriority", + "t22"."o_clerk" AS "o_clerk", + "t22"."o_shippriority" AS "o_shippriority", + "t22"."o_comment" AS "o_comment", + "t22"."l_orderkey" AS "l_orderkey", + "t22"."l_partkey" AS "l_partkey", + "t22"."l_suppkey" AS "l_suppkey", + "t22"."l_linenumber" AS "l_linenumber", + "t22"."l_quantity" AS "l_quantity", + "t22"."l_extendedprice" AS "l_extendedprice", + "t22"."l_discount" AS "l_discount", + "t22"."l_tax" AS "l_tax", + "t22"."l_returnflag" AS "l_returnflag", + "t22"."l_linestatus" AS "l_linestatus", + "t22"."l_shipdate" AS "l_shipdate", + "t22"."l_commitdate" AS "l_commitdate", + "t22"."l_receiptdate" AS "l_receiptdate", + "t22"."l_shipinstruct" AS "l_shipinstruct", + "t22"."l_shipmode" AS "l_shipmode", + "t22"."l_comment" AS "l_comment", + "t22"."s_suppkey" AS "s_suppkey", + "t22"."s_name" AS "s_name", + "t22"."s_address" AS "s_address", + "t22"."s_nationkey" AS "s_nationkey", + "t22"."s_phone" AS "s_phone", + "t22"."s_acctbal" AS "s_acctbal", + "t22"."s_comment" AS "s_comment", + "t22"."n_nationkey" AS "n_nationkey", + "t22"."n_name" AS "n_name", + "t22"."n_regionkey" AS "n_regionkey", + "t22"."n_comment" AS "n_comment", + "t22"."r_regionkey" AS "r_regionkey", + "t22"."r_name" AS "r_name", + "t22"."r_comment" AS "r_comment" FROM ( SELECT "t6"."c_custkey" AS "c_custkey", @@ -19,45 +66,45 @@ FROM ( "t6"."c_acctbal" AS "c_acctbal", "t6"."c_mktsegment" AS "c_mktsegment", "t6"."c_comment" AS "c_comment", - "t7"."o_orderkey" AS "o_orderkey", - "t7"."o_custkey" AS "o_custkey", - "t7"."o_orderstatus" AS "o_orderstatus", - "t7"."o_totalprice" AS "o_totalprice", - "t7"."o_orderdate" AS "o_orderdate", - "t7"."o_orderpriority" AS "o_orderpriority", - "t7"."o_clerk" AS "o_clerk", - "t7"."o_shippriority" AS "o_shippriority", - "t7"."o_comment" AS "o_comment", - "t8"."l_orderkey" AS "l_orderkey", - "t8"."l_partkey" AS "l_partkey", - "t8"."l_suppkey" AS "l_suppkey", - "t8"."l_linenumber" AS "l_linenumber", - "t8"."l_quantity" AS "l_quantity", - "t8"."l_extendedprice" AS "l_extendedprice", - "t8"."l_discount" AS "l_discount", - "t8"."l_tax" AS "l_tax", - "t8"."l_returnflag" AS "l_returnflag", - "t8"."l_linestatus" AS "l_linestatus", - "t8"."l_shipdate" AS "l_shipdate", - "t8"."l_commitdate" AS "l_commitdate", - "t8"."l_receiptdate" AS "l_receiptdate", - "t8"."l_shipinstruct" AS "l_shipinstruct", - "t8"."l_shipmode" AS "l_shipmode", - "t8"."l_comment" AS "l_comment", - "t9"."s_suppkey" AS "s_suppkey", - "t9"."s_name" AS "s_name", - "t9"."s_address" AS "s_address", - "t9"."s_nationkey" AS "s_nationkey", - "t9"."s_phone" AS "s_phone", - "t9"."s_acctbal" AS "s_acctbal", - "t9"."s_comment" AS "s_comment", - "t10"."n_nationkey" AS "n_nationkey", - "t10"."n_name" AS "n_name", - "t10"."n_regionkey" AS "n_regionkey", - "t10"."n_comment" AS "n_comment", - "t11"."r_regionkey" AS "r_regionkey", - "t11"."r_name" AS "r_name", - "t11"."r_comment" AS "r_comment" + "t12"."o_orderkey" AS "o_orderkey", + "t12"."o_custkey" AS "o_custkey", + "t12"."o_orderstatus" AS "o_orderstatus", + "t12"."o_totalprice" AS "o_totalprice", + "t12"."o_orderdate" AS "o_orderdate", + "t12"."o_orderpriority" AS "o_orderpriority", + "t12"."o_clerk" AS "o_clerk", + "t12"."o_shippriority" AS "o_shippriority", + "t12"."o_comment" AS "o_comment", + "t13"."l_orderkey" AS "l_orderkey", + "t13"."l_partkey" AS "l_partkey", + "t13"."l_suppkey" AS "l_suppkey", + "t13"."l_linenumber" AS "l_linenumber", + "t13"."l_quantity" AS "l_quantity", + "t13"."l_extendedprice" AS "l_extendedprice", + "t13"."l_discount" AS "l_discount", + "t13"."l_tax" AS "l_tax", + "t13"."l_returnflag" AS "l_returnflag", + "t13"."l_linestatus" AS "l_linestatus", + "t13"."l_shipdate" AS "l_shipdate", + "t13"."l_commitdate" AS "l_commitdate", + "t13"."l_receiptdate" AS "l_receiptdate", + "t13"."l_shipinstruct" AS "l_shipinstruct", + "t13"."l_shipmode" AS "l_shipmode", + "t13"."l_comment" AS "l_comment", + "t14"."s_suppkey" AS "s_suppkey", + "t14"."s_name" AS "s_name", + "t14"."s_address" AS "s_address", + "t14"."s_nationkey" AS "s_nationkey", + "t14"."s_phone" AS "s_phone", + "t14"."s_acctbal" AS "s_acctbal", + "t14"."s_comment" AS "s_comment", + "t15"."n_nationkey" AS "n_nationkey", + "t15"."n_name" AS "n_name", + "t15"."n_regionkey" AS "n_regionkey", + "t15"."n_comment" AS "n_comment", + "t16"."r_regionkey" AS "r_regionkey", + "t16"."r_name" AS "r_name", + "t16"."r_comment" AS "r_comment" FROM ( SELECT "t0"."C_CUSTKEY" AS "c_custkey", @@ -82,8 +129,8 @@ FROM ( "t1"."O_SHIPPRIORITY" AS "o_shippriority", "t1"."O_COMMENT" AS "o_comment" FROM "ORDERS" AS "t1" - ) AS "t7" - ON "t6"."c_custkey" = "t7"."o_custkey" + ) AS "t12" + ON "t6"."c_custkey" = "t12"."o_custkey" INNER JOIN ( SELECT "t2"."L_ORDERKEY" AS "l_orderkey", @@ -103,8 +150,8 @@ FROM ( "t2"."L_SHIPMODE" AS "l_shipmode", "t2"."L_COMMENT" AS "l_comment" FROM "LINEITEM" AS "t2" - ) AS "t8" - ON "t8"."l_orderkey" = "t7"."o_orderkey" + ) AS "t13" + ON "t13"."l_orderkey" = "t12"."o_orderkey" INNER JOIN ( SELECT "t3"."S_SUPPKEY" AS "s_suppkey", @@ -115,8 +162,8 @@ FROM ( "t3"."S_ACCTBAL" AS "s_acctbal", "t3"."S_COMMENT" AS "s_comment" FROM "SUPPLIER" AS "t3" - ) AS "t9" - ON "t8"."l_suppkey" = "t9"."s_suppkey" + ) AS "t14" + ON "t13"."l_suppkey" = "t14"."s_suppkey" INNER JOIN ( SELECT "t4"."N_NATIONKEY" AS "n_nationkey", @@ -124,30 +171,25 @@ FROM ( "t4"."N_REGIONKEY" AS "n_regionkey", "t4"."N_COMMENT" AS "n_comment" FROM "NATION" AS "t4" - ) AS "t10" - ON "t6"."c_nationkey" = "t9"."s_nationkey" AND "t9"."s_nationkey" = "t10"."n_nationkey" + ) AS "t15" + ON "t6"."c_nationkey" = "t14"."s_nationkey" + AND "t14"."s_nationkey" = "t15"."n_nationkey" INNER JOIN ( SELECT "t5"."R_REGIONKEY" AS "r_regionkey", "t5"."R_NAME" AS "r_name", "t5"."R_COMMENT" AS "r_comment" FROM "REGION" AS "t5" - ) AS "t11" - ON "t10"."n_regionkey" = "t11"."r_regionkey" - ) AS "t17" + ) AS "t16" + ON "t15"."n_regionkey" = "t16"."r_regionkey" + ) AS "t22" WHERE - ( - "t17"."r_name" = 'ASIA' - ) - AND ( - "t17"."o_orderdate" >= DATEFROMPARTS(1994, 1, 1) - ) - AND ( - "t17"."o_orderdate" < DATEFROMPARTS(1995, 1, 1) - ) - ) AS "t18" + "t22"."r_name" = 'ASIA' + AND "t22"."o_orderdate" >= DATEFROMPARTS(1994, 1, 1) + AND "t22"."o_orderdate" < DATEFROMPARTS(1995, 1, 1) + ) AS "t23" GROUP BY 1 -) AS "t19" +) AS "t24" ORDER BY - "t19"."revenue" DESC NULLS LAST \ No newline at end of file + "t24"."revenue" DESC NULLS LAST \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h06/test_tpc_h06/snowflake/h06.sql b/ibis/backends/tests/tpch/snapshots/test_h06/test_tpc_h06/snowflake/h06.sql index 682255ef715b0..5d0be126fb131 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h06/test_tpc_h06/snowflake/h06.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h06/test_tpc_h06/snowflake/h06.sql @@ -1,37 +1,27 @@ SELECT - SUM("t2"."l_extendedprice" * "t2"."l_discount") AS "revenue" + SUM("t1"."l_extendedprice" * "t1"."l_discount") AS "revenue" FROM ( SELECT - * - FROM ( - SELECT - "t0"."L_ORDERKEY" AS "l_orderkey", - "t0"."L_PARTKEY" AS "l_partkey", - "t0"."L_SUPPKEY" AS "l_suppkey", - "t0"."L_LINENUMBER" AS "l_linenumber", - "t0"."L_QUANTITY" AS "l_quantity", - "t0"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t0"."L_DISCOUNT" AS "l_discount", - "t0"."L_TAX" AS "l_tax", - "t0"."L_RETURNFLAG" AS "l_returnflag", - "t0"."L_LINESTATUS" AS "l_linestatus", - "t0"."L_SHIPDATE" AS "l_shipdate", - "t0"."L_COMMITDATE" AS "l_commitdate", - "t0"."L_RECEIPTDATE" AS "l_receiptdate", - "t0"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t0"."L_SHIPMODE" AS "l_shipmode", - "t0"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t0" - ) AS "t1" + "t0"."L_ORDERKEY" AS "l_orderkey", + "t0"."L_PARTKEY" AS "l_partkey", + "t0"."L_SUPPKEY" AS "l_suppkey", + "t0"."L_LINENUMBER" AS "l_linenumber", + "t0"."L_QUANTITY" AS "l_quantity", + "t0"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t0"."L_DISCOUNT" AS "l_discount", + "t0"."L_TAX" AS "l_tax", + "t0"."L_RETURNFLAG" AS "l_returnflag", + "t0"."L_LINESTATUS" AS "l_linestatus", + "t0"."L_SHIPDATE" AS "l_shipdate", + "t0"."L_COMMITDATE" AS "l_commitdate", + "t0"."L_RECEIPTDATE" AS "l_receiptdate", + "t0"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t0"."L_SHIPMODE" AS "l_shipmode", + "t0"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t0" WHERE - ( - "t1"."l_shipdate" >= DATEFROMPARTS(1994, 1, 1) - ) - AND ( - "t1"."l_shipdate" < DATEFROMPARTS(1995, 1, 1) - ) - AND "t1"."l_discount" BETWEEN 0.05 AND 0.07 - AND ( - "t1"."l_quantity" < 24 - ) -) AS "t2" \ No newline at end of file + "t0"."L_SHIPDATE" >= DATEFROMPARTS(1994, 1, 1) + AND "t0"."L_SHIPDATE" < DATEFROMPARTS(1995, 1, 1) + AND "t0"."L_DISCOUNT" BETWEEN 0.05 AND 0.07 + AND "t0"."L_QUANTITY" < 24 +) AS "t1" \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h08/test_tpc_h08/snowflake/h08.sql b/ibis/backends/tests/tpch/snapshots/test_h08/test_tpc_h08/snowflake/h08.sql index 0ba21f1e85db3..800d7a74c6456 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h08/test_tpc_h08/snowflake/h08.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h08/test_tpc_h08/snowflake/h08.sql @@ -1,143 +1,136 @@ SELECT - * + "t30"."o_year" AS "o_year", + "t30"."mkt_share" AS "mkt_share" FROM ( SELECT - "t24"."o_year" AS "o_year", - SUM("t24"."nation_volume") / SUM("t24"."volume") AS "mkt_share" + "t29"."o_year" AS "o_year", + SUM("t29"."nation_volume") / SUM("t29"."volume") AS "mkt_share" FROM ( SELECT - "t23"."o_year" AS "o_year", - "t23"."volume" AS "volume", - "t23"."nation" AS "nation", - "t23"."r_name" AS "r_name", - "t23"."o_orderdate" AS "o_orderdate", - "t23"."p_type" AS "p_type", - CASE WHEN "t23"."nation" = 'BRAZIL' THEN "t23"."volume" ELSE 0 END AS "nation_volume" + "t28"."o_year" AS "o_year", + "t28"."volume" AS "volume", + "t28"."nation" AS "nation", + "t28"."r_name" AS "r_name", + "t28"."o_orderdate" AS "o_orderdate", + "t28"."p_type" AS "p_type", + CASE WHEN "t28"."nation" = 'BRAZIL' THEN "t28"."volume" ELSE 0 END AS "nation_volume" FROM ( SELECT - * + DATE_PART('year', "t16"."o_orderdate") AS "o_year", + "t14"."l_extendedprice" * ( + 1 - "t14"."l_discount" + ) AS "volume", + "t19"."n_name" AS "nation", + "t20"."r_name" AS "r_name", + "t16"."o_orderdate" AS "o_orderdate", + "t7"."p_type" AS "p_type" FROM ( SELECT - DATE_PART('year', "t10"."o_orderdate") AS "o_year", - "t8"."l_extendedprice" * ( - 1 - "t8"."l_discount" - ) AS "volume", - "t14"."n_name" AS "nation", - "t13"."r_name" AS "r_name", - "t10"."o_orderdate" AS "o_orderdate", - "t7"."p_type" AS "p_type" - FROM ( - SELECT - "t0"."P_PARTKEY" AS "p_partkey", - "t0"."P_NAME" AS "p_name", - "t0"."P_MFGR" AS "p_mfgr", - "t0"."P_BRAND" AS "p_brand", - "t0"."P_TYPE" AS "p_type", - "t0"."P_SIZE" AS "p_size", - "t0"."P_CONTAINER" AS "p_container", - "t0"."P_RETAILPRICE" AS "p_retailprice", - "t0"."P_COMMENT" AS "p_comment" - FROM "PART" AS "t0" - ) AS "t7" - INNER JOIN ( - SELECT - "t1"."L_ORDERKEY" AS "l_orderkey", - "t1"."L_PARTKEY" AS "l_partkey", - "t1"."L_SUPPKEY" AS "l_suppkey", - "t1"."L_LINENUMBER" AS "l_linenumber", - "t1"."L_QUANTITY" AS "l_quantity", - "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t1"."L_DISCOUNT" AS "l_discount", - "t1"."L_TAX" AS "l_tax", - "t1"."L_RETURNFLAG" AS "l_returnflag", - "t1"."L_LINESTATUS" AS "l_linestatus", - "t1"."L_SHIPDATE" AS "l_shipdate", - "t1"."L_COMMITDATE" AS "l_commitdate", - "t1"."L_RECEIPTDATE" AS "l_receiptdate", - "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t1"."L_SHIPMODE" AS "l_shipmode", - "t1"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t1" - ) AS "t8" - ON "t7"."p_partkey" = "t8"."l_partkey" - INNER JOIN ( - SELECT - "t2"."S_SUPPKEY" AS "s_suppkey", - "t2"."S_NAME" AS "s_name", - "t2"."S_ADDRESS" AS "s_address", - "t2"."S_NATIONKEY" AS "s_nationkey", - "t2"."S_PHONE" AS "s_phone", - "t2"."S_ACCTBAL" AS "s_acctbal", - "t2"."S_COMMENT" AS "s_comment" - FROM "SUPPLIER" AS "t2" - ) AS "t9" - ON "t9"."s_suppkey" = "t8"."l_suppkey" - INNER JOIN ( - SELECT - "t3"."O_ORDERKEY" AS "o_orderkey", - "t3"."O_CUSTKEY" AS "o_custkey", - "t3"."O_ORDERSTATUS" AS "o_orderstatus", - "t3"."O_TOTALPRICE" AS "o_totalprice", - "t3"."O_ORDERDATE" AS "o_orderdate", - "t3"."O_ORDERPRIORITY" AS "o_orderpriority", - "t3"."O_CLERK" AS "o_clerk", - "t3"."O_SHIPPRIORITY" AS "o_shippriority", - "t3"."O_COMMENT" AS "o_comment" - FROM "ORDERS" AS "t3" - ) AS "t10" - ON "t8"."l_orderkey" = "t10"."o_orderkey" - INNER JOIN ( - SELECT - "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 "CUSTOMER" AS "t4" - ) AS "t11" - ON "t10"."o_custkey" = "t11"."c_custkey" - INNER JOIN ( - SELECT - "t5"."N_NATIONKEY" AS "n_nationkey", - "t5"."N_NAME" AS "n_name", - "t5"."N_REGIONKEY" AS "n_regionkey", - "t5"."N_COMMENT" AS "n_comment" - FROM "NATION" AS "t5" - ) AS "t12" - ON "t11"."c_nationkey" = "t12"."n_nationkey" - INNER JOIN ( - SELECT - "t6"."R_REGIONKEY" AS "r_regionkey", - "t6"."R_NAME" AS "r_name", - "t6"."R_COMMENT" AS "r_comment" - FROM "REGION" AS "t6" - ) AS "t13" - ON "t12"."n_regionkey" = "t13"."r_regionkey" - INNER JOIN ( - SELECT - "t5"."N_NATIONKEY" AS "n_nationkey", - "t5"."N_NAME" AS "n_name", - "t5"."N_REGIONKEY" AS "n_regionkey", - "t5"."N_COMMENT" AS "n_comment" - FROM "NATION" AS "t5" - ) AS "t14" - ON "t9"."s_nationkey" = "t14"."n_nationkey" - ) AS "t22" - WHERE - ( - "t22"."r_name" = 'AMERICA' - ) - AND "t22"."o_orderdate" BETWEEN DATEFROMPARTS(1995, 1, 1) AND DATEFROMPARTS(1996, 12, 31) - AND ( - "t22"."p_type" = 'ECONOMY ANODIZED STEEL' - ) - ) AS "t23" - ) AS "t24" + "t0"."P_PARTKEY" AS "p_partkey", + "t0"."P_NAME" AS "p_name", + "t0"."P_MFGR" AS "p_mfgr", + "t0"."P_BRAND" AS "p_brand", + "t0"."P_TYPE" AS "p_type", + "t0"."P_SIZE" AS "p_size", + "t0"."P_CONTAINER" AS "p_container", + "t0"."P_RETAILPRICE" AS "p_retailprice", + "t0"."P_COMMENT" AS "p_comment" + FROM "PART" AS "t0" + ) AS "t7" + INNER JOIN ( + SELECT + "t1"."L_ORDERKEY" AS "l_orderkey", + "t1"."L_PARTKEY" AS "l_partkey", + "t1"."L_SUPPKEY" AS "l_suppkey", + "t1"."L_LINENUMBER" AS "l_linenumber", + "t1"."L_QUANTITY" AS "l_quantity", + "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t1"."L_DISCOUNT" AS "l_discount", + "t1"."L_TAX" AS "l_tax", + "t1"."L_RETURNFLAG" AS "l_returnflag", + "t1"."L_LINESTATUS" AS "l_linestatus", + "t1"."L_SHIPDATE" AS "l_shipdate", + "t1"."L_COMMITDATE" AS "l_commitdate", + "t1"."L_RECEIPTDATE" AS "l_receiptdate", + "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t1"."L_SHIPMODE" AS "l_shipmode", + "t1"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t1" + ) AS "t14" + ON "t7"."p_partkey" = "t14"."l_partkey" + INNER JOIN ( + SELECT + "t2"."S_SUPPKEY" AS "s_suppkey", + "t2"."S_NAME" AS "s_name", + "t2"."S_ADDRESS" AS "s_address", + "t2"."S_NATIONKEY" AS "s_nationkey", + "t2"."S_PHONE" AS "s_phone", + "t2"."S_ACCTBAL" AS "s_acctbal", + "t2"."S_COMMENT" AS "s_comment" + FROM "SUPPLIER" AS "t2" + ) AS "t15" + ON "t15"."s_suppkey" = "t14"."l_suppkey" + INNER JOIN ( + SELECT + "t3"."O_ORDERKEY" AS "o_orderkey", + "t3"."O_CUSTKEY" AS "o_custkey", + "t3"."O_ORDERSTATUS" AS "o_orderstatus", + "t3"."O_TOTALPRICE" AS "o_totalprice", + "t3"."O_ORDERDATE" AS "o_orderdate", + "t3"."O_ORDERPRIORITY" AS "o_orderpriority", + "t3"."O_CLERK" AS "o_clerk", + "t3"."O_SHIPPRIORITY" AS "o_shippriority", + "t3"."O_COMMENT" AS "o_comment" + FROM "ORDERS" AS "t3" + ) AS "t16" + ON "t14"."l_orderkey" = "t16"."o_orderkey" + INNER JOIN ( + SELECT + "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 "CUSTOMER" AS "t4" + ) AS "t17" + ON "t16"."o_custkey" = "t17"."c_custkey" + INNER JOIN ( + SELECT + "t5"."N_NATIONKEY" AS "n_nationkey", + "t5"."N_NAME" AS "n_name", + "t5"."N_REGIONKEY" AS "n_regionkey", + "t5"."N_COMMENT" AS "n_comment" + FROM "NATION" AS "t5" + ) AS "t18" + ON "t17"."c_nationkey" = "t18"."n_nationkey" + INNER JOIN ( + SELECT + "t6"."R_REGIONKEY" AS "r_regionkey", + "t6"."R_NAME" AS "r_name", + "t6"."R_COMMENT" AS "r_comment" + FROM "REGION" AS "t6" + ) AS "t20" + ON "t18"."n_regionkey" = "t20"."r_regionkey" + INNER JOIN ( + SELECT + "t5"."N_NATIONKEY" AS "n_nationkey", + "t5"."N_NAME" AS "n_name", + "t5"."N_REGIONKEY" AS "n_regionkey", + "t5"."N_COMMENT" AS "n_comment" + FROM "NATION" AS "t5" + ) AS "t19" + ON "t15"."s_nationkey" = "t19"."n_nationkey" + ) AS "t28" + WHERE + "t28"."r_name" = 'AMERICA' + AND "t28"."o_orderdate" BETWEEN DATEFROMPARTS(1995, 1, 1) AND DATEFROMPARTS(1996, 12, 31) + AND "t28"."p_type" = 'ECONOMY ANODIZED STEEL' + ) AS "t29" GROUP BY 1 -) AS "t25" +) AS "t30" ORDER BY - "t25"."o_year" ASC \ No newline at end of file + "t30"."o_year" ASC \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h09/test_tpc_h09/snowflake/h09.sql b/ibis/backends/tests/tpch/snapshots/test_h09/test_tpc_h09/snowflake/h09.sql index a6455511d5c8b..2ae1e11724036 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h09/test_tpc_h09/snowflake/h09.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h09/test_tpc_h09/snowflake/h09.sql @@ -1,13 +1,18 @@ SELECT - * + "t24"."nation" AS "nation", + "t24"."o_year" AS "o_year", + "t24"."sum_profit" AS "sum_profit" FROM ( SELECT - "t18"."nation" AS "nation", - "t18"."o_year" AS "o_year", - SUM("t18"."amount") AS "sum_profit" + "t23"."nation" AS "nation", + "t23"."o_year" AS "o_year", + SUM("t23"."amount") AS "sum_profit" FROM ( SELECT - * + "t22"."amount" AS "amount", + "t22"."o_year" AS "o_year", + "t22"."nation" AS "nation", + "t22"."p_name" AS "p_name" FROM ( SELECT ( @@ -15,11 +20,11 @@ FROM ( 1 - "t6"."l_discount" ) ) - ( - "t8"."ps_supplycost" * "t6"."l_quantity" + "t13"."ps_supplycost" * "t6"."l_quantity" ) AS "amount", - DATE_PART('year', "t10"."o_orderdate") AS "o_year", - "t11"."n_name" AS "nation", - "t9"."p_name" AS "p_name" + DATE_PART('year', "t15"."o_orderdate") AS "o_year", + "t16"."n_name" AS "nation", + "t14"."p_name" AS "p_name" FROM ( SELECT "t0"."L_ORDERKEY" AS "l_orderkey", @@ -50,8 +55,8 @@ FROM ( "t1"."S_ACCTBAL" AS "s_acctbal", "t1"."S_COMMENT" AS "s_comment" FROM "SUPPLIER" AS "t1" - ) AS "t7" - ON "t7"."s_suppkey" = "t6"."l_suppkey" + ) AS "t12" + ON "t12"."s_suppkey" = "t6"."l_suppkey" INNER JOIN ( SELECT "t2"."PS_PARTKEY" AS "ps_partkey", @@ -60,8 +65,8 @@ FROM ( "t2"."PS_SUPPLYCOST" AS "ps_supplycost", "t2"."PS_COMMENT" AS "ps_comment" FROM "PARTSUPP" AS "t2" - ) AS "t8" - ON "t8"."ps_suppkey" = "t6"."l_suppkey" AND "t8"."ps_partkey" = "t6"."l_partkey" + ) AS "t13" + ON "t13"."ps_suppkey" = "t6"."l_suppkey" AND "t13"."ps_partkey" = "t6"."l_partkey" INNER JOIN ( SELECT "t3"."P_PARTKEY" AS "p_partkey", @@ -74,8 +79,8 @@ FROM ( "t3"."P_RETAILPRICE" AS "p_retailprice", "t3"."P_COMMENT" AS "p_comment" FROM "PART" AS "t3" - ) AS "t9" - ON "t9"."p_partkey" = "t6"."l_partkey" + ) AS "t14" + ON "t14"."p_partkey" = "t6"."l_partkey" INNER JOIN ( SELECT "t4"."O_ORDERKEY" AS "o_orderkey", @@ -88,8 +93,8 @@ FROM ( "t4"."O_SHIPPRIORITY" AS "o_shippriority", "t4"."O_COMMENT" AS "o_comment" FROM "ORDERS" AS "t4" - ) AS "t10" - ON "t10"."o_orderkey" = "t6"."l_orderkey" + ) AS "t15" + ON "t15"."o_orderkey" = "t6"."l_orderkey" INNER JOIN ( SELECT "t5"."N_NATIONKEY" AS "n_nationkey", @@ -97,16 +102,16 @@ FROM ( "t5"."N_REGIONKEY" AS "n_regionkey", "t5"."N_COMMENT" AS "n_comment" FROM "NATION" AS "t5" - ) AS "t11" - ON "t7"."s_nationkey" = "t11"."n_nationkey" - ) AS "t17" + ) AS "t16" + ON "t12"."s_nationkey" = "t16"."n_nationkey" + ) AS "t22" WHERE - "t17"."p_name" LIKE '%green%' - ) AS "t18" + "t22"."p_name" LIKE '%green%' + ) AS "t23" GROUP BY 1, 2 -) AS "t19" +) AS "t24" ORDER BY - "t19"."nation" ASC, - "t19"."o_year" DESC NULLS LAST \ No newline at end of file + "t24"."nation" ASC, + "t24"."o_year" DESC NULLS LAST \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h10/test_tpc_h10/snowflake/h10.sql b/ibis/backends/tests/tpch/snapshots/test_h10/test_tpc_h10/snowflake/h10.sql index 8a0691b37cba2..a6f5f97cb8c8d 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h10/test_tpc_h10/snowflake/h10.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h10/test_tpc_h10/snowflake/h10.sql @@ -1,147 +1,173 @@ SELECT - * + "t16"."c_custkey" AS "c_custkey", + "t16"."c_name" AS "c_name", + "t16"."revenue" AS "revenue", + "t16"."c_acctbal" AS "c_acctbal", + "t16"."n_name" AS "n_name", + "t16"."c_address" AS "c_address", + "t16"."c_phone" AS "c_phone", + "t16"."c_comment" AS "c_comment" FROM ( SELECT - "t13"."c_custkey" AS "c_custkey", - "t13"."c_name" AS "c_name", - "t13"."revenue" AS "revenue", - "t13"."c_acctbal" AS "c_acctbal", - "t13"."n_name" AS "n_name", - "t13"."c_address" AS "c_address", - "t13"."c_phone" AS "c_phone", - "t13"."c_comment" AS "c_comment" + "t15"."c_custkey" AS "c_custkey", + "t15"."c_name" AS "c_name", + "t15"."c_acctbal" AS "c_acctbal", + "t15"."n_name" AS "n_name", + "t15"."c_address" AS "c_address", + "t15"."c_phone" AS "c_phone", + "t15"."c_comment" AS "c_comment", + SUM("t15"."l_extendedprice" * ( + 1 - "t15"."l_discount" + )) AS "revenue" FROM ( SELECT - "t12"."c_custkey" AS "c_custkey", - "t12"."c_name" AS "c_name", - "t12"."c_acctbal" AS "c_acctbal", - "t12"."n_name" AS "n_name", - "t12"."c_address" AS "c_address", - "t12"."c_phone" AS "c_phone", - "t12"."c_comment" AS "c_comment", - SUM("t12"."l_extendedprice" * ( - 1 - "t12"."l_discount" - )) AS "revenue" + "t14"."c_custkey" AS "c_custkey", + "t14"."c_name" AS "c_name", + "t14"."c_address" AS "c_address", + "t14"."c_nationkey" AS "c_nationkey", + "t14"."c_phone" AS "c_phone", + "t14"."c_acctbal" AS "c_acctbal", + "t14"."c_mktsegment" AS "c_mktsegment", + "t14"."c_comment" AS "c_comment", + "t14"."o_orderkey" AS "o_orderkey", + "t14"."o_custkey" AS "o_custkey", + "t14"."o_orderstatus" AS "o_orderstatus", + "t14"."o_totalprice" AS "o_totalprice", + "t14"."o_orderdate" AS "o_orderdate", + "t14"."o_orderpriority" AS "o_orderpriority", + "t14"."o_clerk" AS "o_clerk", + "t14"."o_shippriority" AS "o_shippriority", + "t14"."o_comment" AS "o_comment", + "t14"."l_orderkey" AS "l_orderkey", + "t14"."l_partkey" AS "l_partkey", + "t14"."l_suppkey" AS "l_suppkey", + "t14"."l_linenumber" AS "l_linenumber", + "t14"."l_quantity" AS "l_quantity", + "t14"."l_extendedprice" AS "l_extendedprice", + "t14"."l_discount" AS "l_discount", + "t14"."l_tax" AS "l_tax", + "t14"."l_returnflag" AS "l_returnflag", + "t14"."l_linestatus" AS "l_linestatus", + "t14"."l_shipdate" AS "l_shipdate", + "t14"."l_commitdate" AS "l_commitdate", + "t14"."l_receiptdate" AS "l_receiptdate", + "t14"."l_shipinstruct" AS "l_shipinstruct", + "t14"."l_shipmode" AS "l_shipmode", + "t14"."l_comment" AS "l_comment", + "t14"."n_nationkey" AS "n_nationkey", + "t14"."n_name" AS "n_name", + "t14"."n_regionkey" AS "n_regionkey", + "t14"."n_comment" AS "n_comment" FROM ( SELECT - * + "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", + "t8"."o_orderkey" AS "o_orderkey", + "t8"."o_custkey" AS "o_custkey", + "t8"."o_orderstatus" AS "o_orderstatus", + "t8"."o_totalprice" AS "o_totalprice", + "t8"."o_orderdate" AS "o_orderdate", + "t8"."o_orderpriority" AS "o_orderpriority", + "t8"."o_clerk" AS "o_clerk", + "t8"."o_shippriority" AS "o_shippriority", + "t8"."o_comment" AS "o_comment", + "t9"."l_orderkey" AS "l_orderkey", + "t9"."l_partkey" AS "l_partkey", + "t9"."l_suppkey" AS "l_suppkey", + "t9"."l_linenumber" AS "l_linenumber", + "t9"."l_quantity" AS "l_quantity", + "t9"."l_extendedprice" AS "l_extendedprice", + "t9"."l_discount" AS "l_discount", + "t9"."l_tax" AS "l_tax", + "t9"."l_returnflag" AS "l_returnflag", + "t9"."l_linestatus" AS "l_linestatus", + "t9"."l_shipdate" AS "l_shipdate", + "t9"."l_commitdate" AS "l_commitdate", + "t9"."l_receiptdate" AS "l_receiptdate", + "t9"."l_shipinstruct" AS "l_shipinstruct", + "t9"."l_shipmode" AS "l_shipmode", + "t9"."l_comment" AS "l_comment", + "t10"."n_nationkey" AS "n_nationkey", + "t10"."n_name" AS "n_name", + "t10"."n_regionkey" AS "n_regionkey", + "t10"."n_comment" AS "n_comment" FROM ( SELECT - "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", - "t5"."o_orderkey" AS "o_orderkey", - "t5"."o_custkey" AS "o_custkey", - "t5"."o_orderstatus" AS "o_orderstatus", - "t5"."o_totalprice" AS "o_totalprice", - "t5"."o_orderdate" AS "o_orderdate", - "t5"."o_orderpriority" AS "o_orderpriority", - "t5"."o_clerk" AS "o_clerk", - "t5"."o_shippriority" AS "o_shippriority", - "t5"."o_comment" AS "o_comment", - "t6"."l_orderkey" AS "l_orderkey", - "t6"."l_partkey" AS "l_partkey", - "t6"."l_suppkey" AS "l_suppkey", - "t6"."l_linenumber" AS "l_linenumber", - "t6"."l_quantity" AS "l_quantity", - "t6"."l_extendedprice" AS "l_extendedprice", - "t6"."l_discount" AS "l_discount", - "t6"."l_tax" AS "l_tax", - "t6"."l_returnflag" AS "l_returnflag", - "t6"."l_linestatus" AS "l_linestatus", - "t6"."l_shipdate" AS "l_shipdate", - "t6"."l_commitdate" AS "l_commitdate", - "t6"."l_receiptdate" AS "l_receiptdate", - "t6"."l_shipinstruct" AS "l_shipinstruct", - "t6"."l_shipmode" AS "l_shipmode", - "t6"."l_comment" AS "l_comment", - "t7"."n_nationkey" AS "n_nationkey", - "t7"."n_name" AS "n_name", - "t7"."n_regionkey" AS "n_regionkey", - "t7"."n_comment" AS "n_comment" - 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" - FROM "CUSTOMER" AS "t0" - ) AS "t4" - INNER JOIN ( - SELECT - "t1"."O_ORDERKEY" AS "o_orderkey", - "t1"."O_CUSTKEY" AS "o_custkey", - "t1"."O_ORDERSTATUS" AS "o_orderstatus", - "t1"."O_TOTALPRICE" AS "o_totalprice", - "t1"."O_ORDERDATE" AS "o_orderdate", - "t1"."O_ORDERPRIORITY" AS "o_orderpriority", - "t1"."O_CLERK" AS "o_clerk", - "t1"."O_SHIPPRIORITY" AS "o_shippriority", - "t1"."O_COMMENT" AS "o_comment" - FROM "ORDERS" AS "t1" - ) AS "t5" - ON "t4"."c_custkey" = "t5"."o_custkey" - INNER JOIN ( - SELECT - "t2"."L_ORDERKEY" AS "l_orderkey", - "t2"."L_PARTKEY" AS "l_partkey", - "t2"."L_SUPPKEY" AS "l_suppkey", - "t2"."L_LINENUMBER" AS "l_linenumber", - "t2"."L_QUANTITY" AS "l_quantity", - "t2"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t2"."L_DISCOUNT" AS "l_discount", - "t2"."L_TAX" AS "l_tax", - "t2"."L_RETURNFLAG" AS "l_returnflag", - "t2"."L_LINESTATUS" AS "l_linestatus", - "t2"."L_SHIPDATE" AS "l_shipdate", - "t2"."L_COMMITDATE" AS "l_commitdate", - "t2"."L_RECEIPTDATE" AS "l_receiptdate", - "t2"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t2"."L_SHIPMODE" AS "l_shipmode", - "t2"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t2" - ) AS "t6" - ON "t6"."l_orderkey" = "t5"."o_orderkey" - INNER JOIN ( - SELECT - "t3"."N_NATIONKEY" AS "n_nationkey", - "t3"."N_NAME" AS "n_name", - "t3"."N_REGIONKEY" AS "n_regionkey", - "t3"."N_COMMENT" AS "n_comment" - FROM "NATION" AS "t3" - ) AS "t7" - ON "t4"."c_nationkey" = "t7"."n_nationkey" - ) AS "t11" - WHERE - ( - "t11"."o_orderdate" >= DATEFROMPARTS(1993, 10, 1) - ) - AND ( - "t11"."o_orderdate" < DATEFROMPARTS(1994, 1, 1) - ) - AND ( - "t11"."l_returnflag" = 'R' - ) - ) AS "t12" - GROUP BY - 1, - 2, - 3, - 4, - 5, - 6, - 7 - ) AS "t13" -) AS "t14" + "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" + FROM "CUSTOMER" AS "t0" + ) AS "t4" + INNER JOIN ( + SELECT + "t1"."O_ORDERKEY" AS "o_orderkey", + "t1"."O_CUSTKEY" AS "o_custkey", + "t1"."O_ORDERSTATUS" AS "o_orderstatus", + "t1"."O_TOTALPRICE" AS "o_totalprice", + "t1"."O_ORDERDATE" AS "o_orderdate", + "t1"."O_ORDERPRIORITY" AS "o_orderpriority", + "t1"."O_CLERK" AS "o_clerk", + "t1"."O_SHIPPRIORITY" AS "o_shippriority", + "t1"."O_COMMENT" AS "o_comment" + FROM "ORDERS" AS "t1" + ) AS "t8" + ON "t4"."c_custkey" = "t8"."o_custkey" + INNER JOIN ( + SELECT + "t2"."L_ORDERKEY" AS "l_orderkey", + "t2"."L_PARTKEY" AS "l_partkey", + "t2"."L_SUPPKEY" AS "l_suppkey", + "t2"."L_LINENUMBER" AS "l_linenumber", + "t2"."L_QUANTITY" AS "l_quantity", + "t2"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t2"."L_DISCOUNT" AS "l_discount", + "t2"."L_TAX" AS "l_tax", + "t2"."L_RETURNFLAG" AS "l_returnflag", + "t2"."L_LINESTATUS" AS "l_linestatus", + "t2"."L_SHIPDATE" AS "l_shipdate", + "t2"."L_COMMITDATE" AS "l_commitdate", + "t2"."L_RECEIPTDATE" AS "l_receiptdate", + "t2"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t2"."L_SHIPMODE" AS "l_shipmode", + "t2"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t2" + ) AS "t9" + ON "t9"."l_orderkey" = "t8"."o_orderkey" + INNER JOIN ( + SELECT + "t3"."N_NATIONKEY" AS "n_nationkey", + "t3"."N_NAME" AS "n_name", + "t3"."N_REGIONKEY" AS "n_regionkey", + "t3"."N_COMMENT" AS "n_comment" + FROM "NATION" AS "t3" + ) AS "t10" + ON "t4"."c_nationkey" = "t10"."n_nationkey" + ) AS "t14" + WHERE + "t14"."o_orderdate" >= DATEFROMPARTS(1993, 10, 1) + AND "t14"."o_orderdate" < DATEFROMPARTS(1994, 1, 1) + AND "t14"."l_returnflag" = 'R' + ) AS "t15" + GROUP BY + 1, + 2, + 3, + 4, + 5, + 6, + 7 +) AS "t16" ORDER BY - "t14"."revenue" DESC NULLS LAST + "t16"."revenue" DESC NULLS LAST LIMIT 20 \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h11/test_tpc_h11/snowflake/h11.sql b/ibis/backends/tests/tpch/snapshots/test_h11/test_tpc_h11/snowflake/h11.sql index 0172fab2905c8..5d311642834a4 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h11/test_tpc_h11/snowflake/h11.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h11/test_tpc_h11/snowflake/h11.sql @@ -1,138 +1,159 @@ SELECT - * + "t18"."ps_partkey" AS "ps_partkey", + "t18"."value" AS "value" FROM ( SELECT - * + "t16"."ps_partkey" AS "ps_partkey", + SUM("t16"."ps_supplycost" * "t16"."ps_availqty") AS "value" FROM ( SELECT - "t9"."ps_partkey" AS "ps_partkey", - SUM("t9"."ps_supplycost" * "t9"."ps_availqty") AS "value" + "t14"."ps_partkey" AS "ps_partkey", + "t14"."ps_suppkey" AS "ps_suppkey", + "t14"."ps_availqty" AS "ps_availqty", + "t14"."ps_supplycost" AS "ps_supplycost", + "t14"."ps_comment" AS "ps_comment", + "t14"."s_suppkey" AS "s_suppkey", + "t14"."s_name" AS "s_name", + "t14"."s_address" AS "s_address", + "t14"."s_nationkey" AS "s_nationkey", + "t14"."s_phone" AS "s_phone", + "t14"."s_acctbal" AS "s_acctbal", + "t14"."s_comment" AS "s_comment", + "t14"."n_nationkey" AS "n_nationkey", + "t14"."n_name" AS "n_name", + "t14"."n_regionkey" AS "n_regionkey", + "t14"."n_comment" AS "n_comment" FROM ( SELECT - * + "t3"."ps_partkey" AS "ps_partkey", + "t3"."ps_suppkey" AS "ps_suppkey", + "t3"."ps_availqty" AS "ps_availqty", + "t3"."ps_supplycost" AS "ps_supplycost", + "t3"."ps_comment" AS "ps_comment", + "t6"."s_suppkey" AS "s_suppkey", + "t6"."s_name" AS "s_name", + "t6"."s_address" AS "s_address", + "t6"."s_nationkey" AS "s_nationkey", + "t6"."s_phone" AS "s_phone", + "t6"."s_acctbal" AS "s_acctbal", + "t6"."s_comment" AS "s_comment", + "t8"."n_nationkey" AS "n_nationkey", + "t8"."n_name" AS "n_name", + "t8"."n_regionkey" AS "n_regionkey", + "t8"."n_comment" AS "n_comment" FROM ( SELECT - "t3"."ps_partkey" AS "ps_partkey", - "t3"."ps_suppkey" AS "ps_suppkey", - "t3"."ps_availqty" AS "ps_availqty", - "t3"."ps_supplycost" AS "ps_supplycost", - "t3"."ps_comment" AS "ps_comment", - "t4"."s_suppkey" AS "s_suppkey", - "t4"."s_name" AS "s_name", - "t4"."s_address" AS "s_address", - "t4"."s_nationkey" AS "s_nationkey", - "t4"."s_phone" AS "s_phone", - "t4"."s_acctbal" AS "s_acctbal", - "t4"."s_comment" AS "s_comment", - "t5"."n_nationkey" AS "n_nationkey", - "t5"."n_name" AS "n_name", - "t5"."n_regionkey" AS "n_regionkey", - "t5"."n_comment" AS "n_comment" - FROM ( - SELECT - "t0"."PS_PARTKEY" AS "ps_partkey", - "t0"."PS_SUPPKEY" AS "ps_suppkey", - "t0"."PS_AVAILQTY" AS "ps_availqty", - "t0"."PS_SUPPLYCOST" AS "ps_supplycost", - "t0"."PS_COMMENT" AS "ps_comment" - FROM "PARTSUPP" AS "t0" - ) AS "t3" - INNER JOIN ( - SELECT - "t1"."S_SUPPKEY" AS "s_suppkey", - "t1"."S_NAME" AS "s_name", - "t1"."S_ADDRESS" AS "s_address", - "t1"."S_NATIONKEY" AS "s_nationkey", - "t1"."S_PHONE" AS "s_phone", - "t1"."S_ACCTBAL" AS "s_acctbal", - "t1"."S_COMMENT" AS "s_comment" - FROM "SUPPLIER" AS "t1" - ) AS "t4" - ON "t3"."ps_suppkey" = "t4"."s_suppkey" - INNER JOIN ( - SELECT - "t2"."N_NATIONKEY" AS "n_nationkey", - "t2"."N_NAME" AS "n_name", - "t2"."N_REGIONKEY" AS "n_regionkey", - "t2"."N_COMMENT" AS "n_comment" - FROM "NATION" AS "t2" - ) AS "t5" - ON "t5"."n_nationkey" = "t4"."s_nationkey" + "t0"."PS_PARTKEY" AS "ps_partkey", + "t0"."PS_SUPPKEY" AS "ps_suppkey", + "t0"."PS_AVAILQTY" AS "ps_availqty", + "t0"."PS_SUPPLYCOST" AS "ps_supplycost", + "t0"."PS_COMMENT" AS "ps_comment" + FROM "PARTSUPP" AS "t0" + ) AS "t3" + INNER JOIN ( + SELECT + "t1"."S_SUPPKEY" AS "s_suppkey", + "t1"."S_NAME" AS "s_name", + "t1"."S_ADDRESS" AS "s_address", + "t1"."S_NATIONKEY" AS "s_nationkey", + "t1"."S_PHONE" AS "s_phone", + "t1"."S_ACCTBAL" AS "s_acctbal", + "t1"."S_COMMENT" AS "s_comment" + FROM "SUPPLIER" AS "t1" + ) AS "t6" + ON "t3"."ps_suppkey" = "t6"."s_suppkey" + INNER JOIN ( + SELECT + "t2"."N_NATIONKEY" AS "n_nationkey", + "t2"."N_NAME" AS "n_name", + "t2"."N_REGIONKEY" AS "n_regionkey", + "t2"."N_COMMENT" AS "n_comment" + FROM "NATION" AS "t2" ) AS "t8" - WHERE - ( - "t8"."n_name" = 'GERMANY' - ) - ) AS "t9" - GROUP BY - 1 - ) AS "t10" - WHERE + ON "t8"."n_nationkey" = "t6"."s_nationkey" + ) AS "t14" + WHERE + "t14"."n_name" = 'GERMANY' + ) AS "t16" + GROUP BY + 1 +) AS "t18" +WHERE + "t18"."value" > ( ( - "t10"."value" > ( - ( + SELECT + SUM("t17"."ps_supplycost" * "t17"."ps_availqty") AS "Sum(Multiply(ps_supplycost, ps_availqty))" + FROM ( + SELECT + "t15"."ps_partkey" AS "ps_partkey", + "t15"."ps_suppkey" AS "ps_suppkey", + "t15"."ps_availqty" AS "ps_availqty", + "t15"."ps_supplycost" AS "ps_supplycost", + "t15"."ps_comment" AS "ps_comment", + "t15"."s_suppkey" AS "s_suppkey", + "t15"."s_name" AS "s_name", + "t15"."s_address" AS "s_address", + "t15"."s_nationkey" AS "s_nationkey", + "t15"."s_phone" AS "s_phone", + "t15"."s_acctbal" AS "s_acctbal", + "t15"."s_comment" AS "s_comment", + "t15"."n_nationkey" AS "n_nationkey", + "t15"."n_name" AS "n_name", + "t15"."n_regionkey" AS "n_regionkey", + "t15"."n_comment" AS "n_comment" + FROM ( SELECT - SUM("t9"."ps_supplycost" * "t9"."ps_availqty") AS "Sum(Multiply(ps_supplycost, ps_availqty))" + "t3"."ps_partkey" AS "ps_partkey", + "t3"."ps_suppkey" AS "ps_suppkey", + "t3"."ps_availqty" AS "ps_availqty", + "t3"."ps_supplycost" AS "ps_supplycost", + "t3"."ps_comment" AS "ps_comment", + "t7"."s_suppkey" AS "s_suppkey", + "t7"."s_name" AS "s_name", + "t7"."s_address" AS "s_address", + "t7"."s_nationkey" AS "s_nationkey", + "t7"."s_phone" AS "s_phone", + "t7"."s_acctbal" AS "s_acctbal", + "t7"."s_comment" AS "s_comment", + "t9"."n_nationkey" AS "n_nationkey", + "t9"."n_name" AS "n_name", + "t9"."n_regionkey" AS "n_regionkey", + "t9"."n_comment" AS "n_comment" FROM ( SELECT - * - FROM ( - SELECT - "t3"."ps_partkey" AS "ps_partkey", - "t3"."ps_suppkey" AS "ps_suppkey", - "t3"."ps_availqty" AS "ps_availqty", - "t3"."ps_supplycost" AS "ps_supplycost", - "t3"."ps_comment" AS "ps_comment", - "t4"."s_suppkey" AS "s_suppkey", - "t4"."s_name" AS "s_name", - "t4"."s_address" AS "s_address", - "t4"."s_nationkey" AS "s_nationkey", - "t4"."s_phone" AS "s_phone", - "t4"."s_acctbal" AS "s_acctbal", - "t4"."s_comment" AS "s_comment", - "t5"."n_nationkey" AS "n_nationkey", - "t5"."n_name" AS "n_name", - "t5"."n_regionkey" AS "n_regionkey", - "t5"."n_comment" AS "n_comment" - FROM ( - SELECT - "t0"."PS_PARTKEY" AS "ps_partkey", - "t0"."PS_SUPPKEY" AS "ps_suppkey", - "t0"."PS_AVAILQTY" AS "ps_availqty", - "t0"."PS_SUPPLYCOST" AS "ps_supplycost", - "t0"."PS_COMMENT" AS "ps_comment" - FROM "PARTSUPP" AS "t0" - ) AS "t3" - INNER JOIN ( - SELECT - "t1"."S_SUPPKEY" AS "s_suppkey", - "t1"."S_NAME" AS "s_name", - "t1"."S_ADDRESS" AS "s_address", - "t1"."S_NATIONKEY" AS "s_nationkey", - "t1"."S_PHONE" AS "s_phone", - "t1"."S_ACCTBAL" AS "s_acctbal", - "t1"."S_COMMENT" AS "s_comment" - FROM "SUPPLIER" AS "t1" - ) AS "t4" - ON "t3"."ps_suppkey" = "t4"."s_suppkey" - INNER JOIN ( - SELECT - "t2"."N_NATIONKEY" AS "n_nationkey", - "t2"."N_NAME" AS "n_name", - "t2"."N_REGIONKEY" AS "n_regionkey", - "t2"."N_COMMENT" AS "n_comment" - FROM "NATION" AS "t2" - ) AS "t5" - ON "t5"."n_nationkey" = "t4"."s_nationkey" - ) AS "t8" - WHERE - ( - "t8"."n_name" = 'GERMANY' - ) + "t0"."PS_PARTKEY" AS "ps_partkey", + "t0"."PS_SUPPKEY" AS "ps_suppkey", + "t0"."PS_AVAILQTY" AS "ps_availqty", + "t0"."PS_SUPPLYCOST" AS "ps_supplycost", + "t0"."PS_COMMENT" AS "ps_comment" + FROM "PARTSUPP" AS "t0" + ) AS "t3" + INNER JOIN ( + SELECT + "t1"."S_SUPPKEY" AS "s_suppkey", + "t1"."S_NAME" AS "s_name", + "t1"."S_ADDRESS" AS "s_address", + "t1"."S_NATIONKEY" AS "s_nationkey", + "t1"."S_PHONE" AS "s_phone", + "t1"."S_ACCTBAL" AS "s_acctbal", + "t1"."S_COMMENT" AS "s_comment" + FROM "SUPPLIER" AS "t1" + ) AS "t7" + ON "t3"."ps_suppkey" = "t7"."s_suppkey" + INNER JOIN ( + SELECT + "t2"."N_NATIONKEY" AS "n_nationkey", + "t2"."N_NAME" AS "n_name", + "t2"."N_REGIONKEY" AS "n_regionkey", + "t2"."N_COMMENT" AS "n_comment" + FROM "NATION" AS "t2" ) AS "t9" - ) * 0.0001 - ) - ) -) AS "t12" + ON "t9"."n_nationkey" = "t7"."s_nationkey" + ) AS "t15" + WHERE + "t15"."n_name" = 'GERMANY' + ) AS "t17" + ) * 0.0001 + ) ORDER BY - "t12"."value" DESC NULLS LAST \ No newline at end of file + "t18"."value" DESC NULLS LAST \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h12/test_tpc_h12/snowflake/h12.sql b/ibis/backends/tests/tpch/snapshots/test_h12/test_tpc_h12/snowflake/h12.sql index ae82e49af1af0..799ef5b12cd08 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h12/test_tpc_h12/snowflake/h12.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h12/test_tpc_h12/snowflake/h12.sql @@ -1,17 +1,43 @@ SELECT - * + "t8"."l_shipmode" AS "l_shipmode", + "t8"."high_line_count" AS "high_line_count", + "t8"."low_line_count" AS "low_line_count" FROM ( SELECT - "t6"."l_shipmode" AS "l_shipmode", + "t7"."l_shipmode" AS "l_shipmode", SUM( - CASE "t6"."o_orderpriority" WHEN '1-URGENT' THEN 1 WHEN '2-HIGH' THEN 1 ELSE 0 END + CASE "t7"."o_orderpriority" WHEN '1-URGENT' THEN 1 WHEN '2-HIGH' THEN 1 ELSE 0 END ) AS "high_line_count", SUM( - CASE "t6"."o_orderpriority" WHEN '1-URGENT' THEN 0 WHEN '2-HIGH' THEN 0 ELSE 1 END + CASE "t7"."o_orderpriority" WHEN '1-URGENT' THEN 0 WHEN '2-HIGH' THEN 0 ELSE 1 END ) AS "low_line_count" FROM ( SELECT - * + "t6"."o_orderkey" AS "o_orderkey", + "t6"."o_custkey" AS "o_custkey", + "t6"."o_orderstatus" AS "o_orderstatus", + "t6"."o_totalprice" AS "o_totalprice", + "t6"."o_orderdate" AS "o_orderdate", + "t6"."o_orderpriority" AS "o_orderpriority", + "t6"."o_clerk" AS "o_clerk", + "t6"."o_shippriority" AS "o_shippriority", + "t6"."o_comment" AS "o_comment", + "t6"."l_orderkey" AS "l_orderkey", + "t6"."l_partkey" AS "l_partkey", + "t6"."l_suppkey" AS "l_suppkey", + "t6"."l_linenumber" AS "l_linenumber", + "t6"."l_quantity" AS "l_quantity", + "t6"."l_extendedprice" AS "l_extendedprice", + "t6"."l_discount" AS "l_discount", + "t6"."l_tax" AS "l_tax", + "t6"."l_returnflag" AS "l_returnflag", + "t6"."l_linestatus" AS "l_linestatus", + "t6"."l_shipdate" AS "l_shipdate", + "t6"."l_commitdate" AS "l_commitdate", + "t6"."l_receiptdate" AS "l_receiptdate", + "t6"."l_shipinstruct" AS "l_shipinstruct", + "t6"."l_shipmode" AS "l_shipmode", + "t6"."l_comment" AS "l_comment" FROM ( SELECT "t2"."o_orderkey" AS "o_orderkey", @@ -23,22 +49,22 @@ FROM ( "t2"."o_clerk" AS "o_clerk", "t2"."o_shippriority" AS "o_shippriority", "t2"."o_comment" AS "o_comment", - "t3"."l_orderkey" AS "l_orderkey", - "t3"."l_partkey" AS "l_partkey", - "t3"."l_suppkey" AS "l_suppkey", - "t3"."l_linenumber" AS "l_linenumber", - "t3"."l_quantity" AS "l_quantity", - "t3"."l_extendedprice" AS "l_extendedprice", - "t3"."l_discount" AS "l_discount", - "t3"."l_tax" AS "l_tax", - "t3"."l_returnflag" AS "l_returnflag", - "t3"."l_linestatus" AS "l_linestatus", - "t3"."l_shipdate" AS "l_shipdate", - "t3"."l_commitdate" AS "l_commitdate", - "t3"."l_receiptdate" AS "l_receiptdate", - "t3"."l_shipinstruct" AS "l_shipinstruct", - "t3"."l_shipmode" AS "l_shipmode", - "t3"."l_comment" AS "l_comment" + "t4"."l_orderkey" AS "l_orderkey", + "t4"."l_partkey" AS "l_partkey", + "t4"."l_suppkey" AS "l_suppkey", + "t4"."l_linenumber" AS "l_linenumber", + "t4"."l_quantity" AS "l_quantity", + "t4"."l_extendedprice" AS "l_extendedprice", + "t4"."l_discount" AS "l_discount", + "t4"."l_tax" AS "l_tax", + "t4"."l_returnflag" AS "l_returnflag", + "t4"."l_linestatus" AS "l_linestatus", + "t4"."l_shipdate" AS "l_shipdate", + "t4"."l_commitdate" AS "l_commitdate", + "t4"."l_receiptdate" AS "l_receiptdate", + "t4"."l_shipinstruct" AS "l_shipinstruct", + "t4"."l_shipmode" AS "l_shipmode", + "t4"."l_comment" AS "l_comment" FROM ( SELECT "t0"."O_ORDERKEY" AS "o_orderkey", @@ -71,26 +97,18 @@ FROM ( "t1"."L_SHIPMODE" AS "l_shipmode", "t1"."L_COMMENT" AS "l_comment" FROM "LINEITEM" AS "t1" - ) AS "t3" - ON "t2"."o_orderkey" = "t3"."l_orderkey" - ) AS "t5" + ) AS "t4" + ON "t2"."o_orderkey" = "t4"."l_orderkey" + ) AS "t6" WHERE - "t5"."l_shipmode" IN ('MAIL', 'SHIP') - AND ( - "t5"."l_commitdate" < "t5"."l_receiptdate" - ) - AND ( - "t5"."l_shipdate" < "t5"."l_commitdate" - ) - AND ( - "t5"."l_receiptdate" >= DATEFROMPARTS(1994, 1, 1) - ) - AND ( - "t5"."l_receiptdate" < DATEFROMPARTS(1995, 1, 1) - ) - ) AS "t6" + "t6"."l_shipmode" IN ('MAIL', 'SHIP') + AND "t6"."l_commitdate" < "t6"."l_receiptdate" + AND "t6"."l_shipdate" < "t6"."l_commitdate" + AND "t6"."l_receiptdate" >= DATEFROMPARTS(1994, 1, 1) + AND "t6"."l_receiptdate" < DATEFROMPARTS(1995, 1, 1) + ) AS "t7" GROUP BY 1 -) AS "t7" +) AS "t8" ORDER BY - "t7"."l_shipmode" ASC \ No newline at end of file + "t8"."l_shipmode" ASC \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h13/test_tpc_h13/snowflake/h13.sql b/ibis/backends/tests/tpch/snapshots/test_h13/test_tpc_h13/snowflake/h13.sql index 6128cab471ca8..fd4edd9dfb77c 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h13/test_tpc_h13/snowflake/h13.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h13/test_tpc_h13/snowflake/h13.sql @@ -1,13 +1,14 @@ SELECT - * + "t8"."c_count" AS "c_count", + "t8"."custdist" AS "custdist" FROM ( SELECT - "t6"."c_count" AS "c_count", + "t7"."c_count" AS "c_count", COUNT(*) AS "custdist" FROM ( SELECT - "t5"."c_custkey" AS "c_custkey", - COUNT("t5"."o_orderkey") AS "c_count" + "t6"."c_custkey" AS "c_custkey", + COUNT("t6"."o_orderkey") AS "c_count" FROM ( SELECT "t2"."c_custkey" AS "c_custkey", @@ -18,15 +19,15 @@ FROM ( "t2"."c_acctbal" AS "c_acctbal", "t2"."c_mktsegment" AS "c_mktsegment", "t2"."c_comment" AS "c_comment", - "t3"."o_orderkey" AS "o_orderkey", - "t3"."o_custkey" AS "o_custkey", - "t3"."o_orderstatus" AS "o_orderstatus", - "t3"."o_totalprice" AS "o_totalprice", - "t3"."o_orderdate" AS "o_orderdate", - "t3"."o_orderpriority" AS "o_orderpriority", - "t3"."o_clerk" AS "o_clerk", - "t3"."o_shippriority" AS "o_shippriority", - "t3"."o_comment" AS "o_comment" + "t4"."o_orderkey" AS "o_orderkey", + "t4"."o_custkey" AS "o_custkey", + "t4"."o_orderstatus" AS "o_orderstatus", + "t4"."o_totalprice" AS "o_totalprice", + "t4"."o_orderdate" AS "o_orderdate", + "t4"."o_orderpriority" AS "o_orderpriority", + "t4"."o_clerk" AS "o_clerk", + "t4"."o_shippriority" AS "o_shippriority", + "t4"."o_comment" AS "o_comment" FROM ( SELECT "t0"."C_CUSTKEY" AS "c_custkey", @@ -51,18 +52,18 @@ FROM ( "t1"."O_SHIPPRIORITY" AS "o_shippriority", "t1"."O_COMMENT" AS "o_comment" FROM "ORDERS" AS "t1" - ) AS "t3" - ON "t2"."c_custkey" = "t3"."o_custkey" + ) AS "t4" + ON "t2"."c_custkey" = "t4"."o_custkey" AND NOT ( - "t3"."o_comment" LIKE '%special%requests%' + "t4"."o_comment" LIKE '%special%requests%' ) - ) AS "t5" + ) AS "t6" GROUP BY 1 - ) AS "t6" + ) AS "t7" GROUP BY 1 -) AS "t7" +) AS "t8" ORDER BY - "t7"."custdist" DESC NULLS LAST, - "t7"."c_count" DESC NULLS LAST \ No newline at end of file + "t8"."custdist" DESC NULLS LAST, + "t8"."c_count" DESC NULLS LAST \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h14/test_tpc_h14/snowflake/h14.sql b/ibis/backends/tests/tpch/snapshots/test_h14/test_tpc_h14/snowflake/h14.sql index 4cc4252641999..a417e7d42d34a 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h14/test_tpc_h14/snowflake/h14.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h14/test_tpc_h14/snowflake/h14.sql @@ -1,16 +1,40 @@ SELECT ( SUM( - IFF("t6"."p_type" LIKE 'PROMO%', "t6"."l_extendedprice" * ( - 1 - "t6"."l_discount" + IFF("t7"."p_type" LIKE 'PROMO%', "t7"."l_extendedprice" * ( + 1 - "t7"."l_discount" ), 0) ) * 100 - ) / SUM("t6"."l_extendedprice" * ( - 1 - "t6"."l_discount" + ) / SUM("t7"."l_extendedprice" * ( + 1 - "t7"."l_discount" )) AS "promo_revenue" FROM ( SELECT - * + "t6"."l_orderkey" AS "l_orderkey", + "t6"."l_partkey" AS "l_partkey", + "t6"."l_suppkey" AS "l_suppkey", + "t6"."l_linenumber" AS "l_linenumber", + "t6"."l_quantity" AS "l_quantity", + "t6"."l_extendedprice" AS "l_extendedprice", + "t6"."l_discount" AS "l_discount", + "t6"."l_tax" AS "l_tax", + "t6"."l_returnflag" AS "l_returnflag", + "t6"."l_linestatus" AS "l_linestatus", + "t6"."l_shipdate" AS "l_shipdate", + "t6"."l_commitdate" AS "l_commitdate", + "t6"."l_receiptdate" AS "l_receiptdate", + "t6"."l_shipinstruct" AS "l_shipinstruct", + "t6"."l_shipmode" AS "l_shipmode", + "t6"."l_comment" AS "l_comment", + "t6"."p_partkey" AS "p_partkey", + "t6"."p_name" AS "p_name", + "t6"."p_mfgr" AS "p_mfgr", + "t6"."p_brand" AS "p_brand", + "t6"."p_type" AS "p_type", + "t6"."p_size" AS "p_size", + "t6"."p_container" AS "p_container", + "t6"."p_retailprice" AS "p_retailprice", + "t6"."p_comment" AS "p_comment" FROM ( SELECT "t2"."l_orderkey" AS "l_orderkey", @@ -29,15 +53,15 @@ FROM ( "t2"."l_shipinstruct" AS "l_shipinstruct", "t2"."l_shipmode" AS "l_shipmode", "t2"."l_comment" AS "l_comment", - "t3"."p_partkey" AS "p_partkey", - "t3"."p_name" AS "p_name", - "t3"."p_mfgr" AS "p_mfgr", - "t3"."p_brand" AS "p_brand", - "t3"."p_type" AS "p_type", - "t3"."p_size" AS "p_size", - "t3"."p_container" AS "p_container", - "t3"."p_retailprice" AS "p_retailprice", - "t3"."p_comment" AS "p_comment" + "t4"."p_partkey" AS "p_partkey", + "t4"."p_name" AS "p_name", + "t4"."p_mfgr" AS "p_mfgr", + "t4"."p_brand" AS "p_brand", + "t4"."p_type" AS "p_type", + "t4"."p_size" AS "p_size", + "t4"."p_container" AS "p_container", + "t4"."p_retailprice" AS "p_retailprice", + "t4"."p_comment" AS "p_comment" FROM ( SELECT "t0"."L_ORDERKEY" AS "l_orderkey", @@ -70,14 +94,10 @@ FROM ( "t1"."P_RETAILPRICE" AS "p_retailprice", "t1"."P_COMMENT" AS "p_comment" FROM "PART" AS "t1" - ) AS "t3" - ON "t2"."l_partkey" = "t3"."p_partkey" - ) AS "t5" + ) AS "t4" + ON "t2"."l_partkey" = "t4"."p_partkey" + ) AS "t6" WHERE - ( - "t5"."l_shipdate" >= DATEFROMPARTS(1995, 9, 1) - ) - AND ( - "t5"."l_shipdate" < DATEFROMPARTS(1995, 10, 1) - ) -) AS "t6" \ No newline at end of file + "t6"."l_shipdate" >= DATEFROMPARTS(1995, 9, 1) + AND "t6"."l_shipdate" < DATEFROMPARTS(1995, 10, 1) +) AS "t7" \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h15/test_tpc_h15/snowflake/h15.sql b/ibis/backends/tests/tpch/snapshots/test_h15/test_tpc_h15/snowflake/h15.sql index 187e626fd936e..c919360a42d2c 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h15/test_tpc_h15/snowflake/h15.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h15/test_tpc_h15/snowflake/h15.sql @@ -1,15 +1,69 @@ SELECT - "t10"."s_suppkey" AS "s_suppkey", - "t10"."s_name" AS "s_name", - "t10"."s_address" AS "s_address", - "t10"."s_phone" AS "s_phone", - "t10"."total_revenue" AS "total_revenue" + "t7"."s_suppkey" AS "s_suppkey", + "t7"."s_name" AS "s_name", + "t7"."s_address" AS "s_address", + "t7"."s_phone" AS "s_phone", + "t7"."total_revenue" AS "total_revenue" FROM ( SELECT - * + "t2"."s_suppkey" AS "s_suppkey", + "t2"."s_name" AS "s_name", + "t2"."s_address" AS "s_address", + "t2"."s_nationkey" AS "s_nationkey", + "t2"."s_phone" AS "s_phone", + "t2"."s_acctbal" AS "s_acctbal", + "t2"."s_comment" AS "s_comment", + "t5"."l_suppkey" AS "l_suppkey", + "t5"."total_revenue" AS "total_revenue" FROM ( SELECT - * + "t0"."S_SUPPKEY" AS "s_suppkey", + "t0"."S_NAME" AS "s_name", + "t0"."S_ADDRESS" AS "s_address", + "t0"."S_NATIONKEY" AS "s_nationkey", + "t0"."S_PHONE" AS "s_phone", + "t0"."S_ACCTBAL" AS "s_acctbal", + "t0"."S_COMMENT" AS "s_comment" + FROM "SUPPLIER" AS "t0" + ) AS "t2" + INNER JOIN ( + SELECT + "t3"."l_suppkey" AS "l_suppkey", + SUM("t3"."l_extendedprice" * ( + 1 - "t3"."l_discount" + )) AS "total_revenue" + FROM ( + SELECT + "t1"."L_ORDERKEY" AS "l_orderkey", + "t1"."L_PARTKEY" AS "l_partkey", + "t1"."L_SUPPKEY" AS "l_suppkey", + "t1"."L_LINENUMBER" AS "l_linenumber", + "t1"."L_QUANTITY" AS "l_quantity", + "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t1"."L_DISCOUNT" AS "l_discount", + "t1"."L_TAX" AS "l_tax", + "t1"."L_RETURNFLAG" AS "l_returnflag", + "t1"."L_LINESTATUS" AS "l_linestatus", + "t1"."L_SHIPDATE" AS "l_shipdate", + "t1"."L_COMMITDATE" AS "l_commitdate", + "t1"."L_RECEIPTDATE" AS "l_receiptdate", + "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t1"."L_SHIPMODE" AS "l_shipmode", + "t1"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t1" + WHERE + "t1"."L_SHIPDATE" >= DATEFROMPARTS(1996, 1, 1) + AND "t1"."L_SHIPDATE" < DATEFROMPARTS(1996, 4, 1) + ) AS "t3" + GROUP BY + 1 + ) AS "t5" + ON "t2"."s_suppkey" = "t5"."l_suppkey" +) AS "t7" +WHERE + "t7"."total_revenue" = ( + SELECT + MAX("t7"."total_revenue") AS "Max(total_revenue)" FROM ( SELECT "t2"."s_suppkey" AS "s_suppkey", @@ -34,118 +88,38 @@ FROM ( ) AS "t2" INNER JOIN ( SELECT - "t4"."l_suppkey" AS "l_suppkey", - SUM("t4"."l_extendedprice" * ( - 1 - "t4"."l_discount" + "t3"."l_suppkey" AS "l_suppkey", + SUM("t3"."l_extendedprice" * ( + 1 - "t3"."l_discount" )) AS "total_revenue" FROM ( SELECT - * - FROM ( - SELECT - "t1"."L_ORDERKEY" AS "l_orderkey", - "t1"."L_PARTKEY" AS "l_partkey", - "t1"."L_SUPPKEY" AS "l_suppkey", - "t1"."L_LINENUMBER" AS "l_linenumber", - "t1"."L_QUANTITY" AS "l_quantity", - "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t1"."L_DISCOUNT" AS "l_discount", - "t1"."L_TAX" AS "l_tax", - "t1"."L_RETURNFLAG" AS "l_returnflag", - "t1"."L_LINESTATUS" AS "l_linestatus", - "t1"."L_SHIPDATE" AS "l_shipdate", - "t1"."L_COMMITDATE" AS "l_commitdate", - "t1"."L_RECEIPTDATE" AS "l_receiptdate", - "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t1"."L_SHIPMODE" AS "l_shipmode", - "t1"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t1" - ) AS "t3" + "t1"."L_ORDERKEY" AS "l_orderkey", + "t1"."L_PARTKEY" AS "l_partkey", + "t1"."L_SUPPKEY" AS "l_suppkey", + "t1"."L_LINENUMBER" AS "l_linenumber", + "t1"."L_QUANTITY" AS "l_quantity", + "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t1"."L_DISCOUNT" AS "l_discount", + "t1"."L_TAX" AS "l_tax", + "t1"."L_RETURNFLAG" AS "l_returnflag", + "t1"."L_LINESTATUS" AS "l_linestatus", + "t1"."L_SHIPDATE" AS "l_shipdate", + "t1"."L_COMMITDATE" AS "l_commitdate", + "t1"."L_RECEIPTDATE" AS "l_receiptdate", + "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t1"."L_SHIPMODE" AS "l_shipmode", + "t1"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t1" WHERE - ( - "t3"."l_shipdate" >= DATEFROMPARTS(1996, 1, 1) - ) - AND ( - "t3"."l_shipdate" < DATEFROMPARTS(1996, 4, 1) - ) - ) AS "t4" + "t1"."L_SHIPDATE" >= DATEFROMPARTS(1996, 1, 1) + AND "t1"."L_SHIPDATE" < DATEFROMPARTS(1996, 4, 1) + ) AS "t3" GROUP BY 1 ) AS "t5" ON "t2"."s_suppkey" = "t5"."l_suppkey" ) AS "t7" - WHERE - ( - "t7"."total_revenue" = ( - SELECT - MAX("t7"."total_revenue") AS "Max(total_revenue)" - FROM ( - SELECT - "t2"."s_suppkey" AS "s_suppkey", - "t2"."s_name" AS "s_name", - "t2"."s_address" AS "s_address", - "t2"."s_nationkey" AS "s_nationkey", - "t2"."s_phone" AS "s_phone", - "t2"."s_acctbal" AS "s_acctbal", - "t2"."s_comment" AS "s_comment", - "t5"."l_suppkey" AS "l_suppkey", - "t5"."total_revenue" AS "total_revenue" - FROM ( - SELECT - "t0"."S_SUPPKEY" AS "s_suppkey", - "t0"."S_NAME" AS "s_name", - "t0"."S_ADDRESS" AS "s_address", - "t0"."S_NATIONKEY" AS "s_nationkey", - "t0"."S_PHONE" AS "s_phone", - "t0"."S_ACCTBAL" AS "s_acctbal", - "t0"."S_COMMENT" AS "s_comment" - FROM "SUPPLIER" AS "t0" - ) AS "t2" - INNER JOIN ( - SELECT - "t4"."l_suppkey" AS "l_suppkey", - SUM("t4"."l_extendedprice" * ( - 1 - "t4"."l_discount" - )) AS "total_revenue" - FROM ( - SELECT - * - FROM ( - SELECT - "t1"."L_ORDERKEY" AS "l_orderkey", - "t1"."L_PARTKEY" AS "l_partkey", - "t1"."L_SUPPKEY" AS "l_suppkey", - "t1"."L_LINENUMBER" AS "l_linenumber", - "t1"."L_QUANTITY" AS "l_quantity", - "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t1"."L_DISCOUNT" AS "l_discount", - "t1"."L_TAX" AS "l_tax", - "t1"."L_RETURNFLAG" AS "l_returnflag", - "t1"."L_LINESTATUS" AS "l_linestatus", - "t1"."L_SHIPDATE" AS "l_shipdate", - "t1"."L_COMMITDATE" AS "l_commitdate", - "t1"."L_RECEIPTDATE" AS "l_receiptdate", - "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t1"."L_SHIPMODE" AS "l_shipmode", - "t1"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t1" - ) AS "t3" - WHERE - ( - "t3"."l_shipdate" >= DATEFROMPARTS(1996, 1, 1) - ) - AND ( - "t3"."l_shipdate" < DATEFROMPARTS(1996, 4, 1) - ) - ) AS "t4" - GROUP BY - 1 - ) AS "t5" - ON "t2"."s_suppkey" = "t5"."l_suppkey" - ) AS "t7" - ) - ) - ) AS "t9" - ORDER BY - "t9"."s_suppkey" ASC -) AS "t10" \ No newline at end of file + ) +ORDER BY + "t7"."s_suppkey" ASC \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h16/test_tpc_h16/snowflake/h16.sql b/ibis/backends/tests/tpch/snapshots/test_h16/test_tpc_h16/snowflake/h16.sql index 61b6192b4082d..6ebdf27930bf6 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h16/test_tpc_h16/snowflake/h16.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h16/test_tpc_h16/snowflake/h16.sql @@ -1,14 +1,30 @@ SELECT - * + "t10"."p_brand" AS "p_brand", + "t10"."p_type" AS "p_type", + "t10"."p_size" AS "p_size", + "t10"."supplier_cnt" AS "supplier_cnt" FROM ( SELECT - "t10"."p_brand" AS "p_brand", - "t10"."p_type" AS "p_type", - "t10"."p_size" AS "p_size", - COUNT(DISTINCT "t10"."ps_suppkey") AS "supplier_cnt" + "t9"."p_brand" AS "p_brand", + "t9"."p_type" AS "p_type", + "t9"."p_size" AS "p_size", + COUNT(DISTINCT "t9"."ps_suppkey") AS "supplier_cnt" FROM ( SELECT - * + "t8"."ps_partkey" AS "ps_partkey", + "t8"."ps_suppkey" AS "ps_suppkey", + "t8"."ps_availqty" AS "ps_availqty", + "t8"."ps_supplycost" AS "ps_supplycost", + "t8"."ps_comment" AS "ps_comment", + "t8"."p_partkey" AS "p_partkey", + "t8"."p_name" AS "p_name", + "t8"."p_mfgr" AS "p_mfgr", + "t8"."p_brand" AS "p_brand", + "t8"."p_type" AS "p_type", + "t8"."p_size" AS "p_size", + "t8"."p_container" AS "p_container", + "t8"."p_retailprice" AS "p_retailprice", + "t8"."p_comment" AS "p_comment" FROM ( SELECT "t3"."ps_partkey" AS "ps_partkey", @@ -16,15 +32,15 @@ FROM ( "t3"."ps_availqty" AS "ps_availqty", "t3"."ps_supplycost" AS "ps_supplycost", "t3"."ps_comment" AS "ps_comment", - "t4"."p_partkey" AS "p_partkey", - "t4"."p_name" AS "p_name", - "t4"."p_mfgr" AS "p_mfgr", - "t4"."p_brand" AS "p_brand", - "t4"."p_type" AS "p_type", - "t4"."p_size" AS "p_size", - "t4"."p_container" AS "p_container", - "t4"."p_retailprice" AS "p_retailprice", - "t4"."p_comment" AS "p_comment" + "t6"."p_partkey" AS "p_partkey", + "t6"."p_name" AS "p_name", + "t6"."p_mfgr" AS "p_mfgr", + "t6"."p_brand" AS "p_brand", + "t6"."p_type" AS "p_type", + "t6"."p_size" AS "p_size", + "t6"."p_container" AS "p_container", + "t6"."p_retailprice" AS "p_retailprice", + "t6"."p_comment" AS "p_comment" FROM ( SELECT "t0"."PS_PARTKEY" AS "ps_partkey", @@ -36,23 +52,21 @@ FROM ( ) AS "t3" INNER JOIN ( SELECT - "t1"."P_PARTKEY" AS "p_partkey", - "t1"."P_NAME" AS "p_name", - "t1"."P_MFGR" AS "p_mfgr", - "t1"."P_BRAND" AS "p_brand", - "t1"."P_TYPE" AS "p_type", - "t1"."P_SIZE" AS "p_size", - "t1"."P_CONTAINER" AS "p_container", - "t1"."P_RETAILPRICE" AS "p_retailprice", - "t1"."P_COMMENT" AS "p_comment" - FROM "PART" AS "t1" - ) AS "t4" - ON "t4"."p_partkey" = "t3"."ps_partkey" + "t2"."P_PARTKEY" AS "p_partkey", + "t2"."P_NAME" AS "p_name", + "t2"."P_MFGR" AS "p_mfgr", + "t2"."P_BRAND" AS "p_brand", + "t2"."P_TYPE" AS "p_type", + "t2"."P_SIZE" AS "p_size", + "t2"."P_CONTAINER" AS "p_container", + "t2"."P_RETAILPRICE" AS "p_retailprice", + "t2"."P_COMMENT" AS "p_comment" + FROM "PART" AS "t2" + ) AS "t6" + ON "t6"."p_partkey" = "t3"."ps_partkey" ) AS "t8" WHERE - ( - "t8"."p_brand" <> 'Brand#45' - ) + "t8"."p_brand" <> 'Brand#45' AND NOT ( "t8"."p_type" LIKE 'MEDIUM POLISHED%' ) @@ -60,34 +74,20 @@ FROM ( AND NOT ( "t8"."ps_suppkey" IN (( SELECT - "t7"."s_suppkey" AS "s_suppkey" - FROM ( - SELECT - * - FROM ( - SELECT - "t2"."S_SUPPKEY" AS "s_suppkey", - "t2"."S_NAME" AS "s_name", - "t2"."S_ADDRESS" AS "s_address", - "t2"."S_NATIONKEY" AS "s_nationkey", - "t2"."S_PHONE" AS "s_phone", - "t2"."S_ACCTBAL" AS "s_acctbal", - "t2"."S_COMMENT" AS "s_comment" - FROM "SUPPLIER" AS "t2" - ) AS "t5" - WHERE - "t5"."s_comment" LIKE '%Customer%Complaints%' - ) AS "t7" + "t1"."S_SUPPKEY" AS "s_suppkey" + FROM "SUPPLIER" AS "t1" + WHERE + "t1"."S_COMMENT" LIKE '%Customer%Complaints%' )) ) - ) AS "t10" + ) AS "t9" GROUP BY 1, 2, 3 -) AS "t11" +) AS "t10" ORDER BY - "t11"."supplier_cnt" DESC NULLS LAST, - "t11"."p_brand" ASC, - "t11"."p_type" ASC, - "t11"."p_size" ASC \ No newline at end of file + "t10"."supplier_cnt" DESC NULLS LAST, + "t10"."p_brand" ASC, + "t10"."p_type" ASC, + "t10"."p_size" ASC \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h18/test_tpc_h18/snowflake/h18.sql b/ibis/backends/tests/tpch/snapshots/test_h18/test_tpc_h18/snowflake/h18.sql index 7e1097065f21a..e2a86eb98ccf7 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h18/test_tpc_h18/snowflake/h18.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h18/test_tpc_h18/snowflake/h18.sql @@ -1,16 +1,53 @@ SELECT - * + "t14"."c_name" AS "c_name", + "t14"."c_custkey" AS "c_custkey", + "t14"."o_orderkey" AS "o_orderkey", + "t14"."o_orderdate" AS "o_orderdate", + "t14"."o_totalprice" AS "o_totalprice", + "t14"."sum_qty" AS "sum_qty" FROM ( SELECT - "t12"."c_name" AS "c_name", - "t12"."c_custkey" AS "c_custkey", - "t12"."o_orderkey" AS "o_orderkey", - "t12"."o_orderdate" AS "o_orderdate", - "t12"."o_totalprice" AS "o_totalprice", - SUM("t12"."l_quantity") AS "sum_qty" + "t13"."c_name" AS "c_name", + "t13"."c_custkey" AS "c_custkey", + "t13"."o_orderkey" AS "o_orderkey", + "t13"."o_orderdate" AS "o_orderdate", + "t13"."o_totalprice" AS "o_totalprice", + SUM("t13"."l_quantity") AS "sum_qty" 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"."o_orderkey" AS "o_orderkey", + "t11"."o_custkey" AS "o_custkey", + "t11"."o_orderstatus" AS "o_orderstatus", + "t11"."o_totalprice" AS "o_totalprice", + "t11"."o_orderdate" AS "o_orderdate", + "t11"."o_orderpriority" AS "o_orderpriority", + "t11"."o_clerk" AS "o_clerk", + "t11"."o_shippriority" AS "o_shippriority", + "t11"."o_comment" AS "o_comment", + "t11"."l_orderkey" AS "l_orderkey", + "t11"."l_partkey" AS "l_partkey", + "t11"."l_suppkey" AS "l_suppkey", + "t11"."l_linenumber" AS "l_linenumber", + "t11"."l_quantity" AS "l_quantity", + "t11"."l_extendedprice" AS "l_extendedprice", + "t11"."l_discount" AS "l_discount", + "t11"."l_tax" AS "l_tax", + "t11"."l_returnflag" AS "l_returnflag", + "t11"."l_linestatus" AS "l_linestatus", + "t11"."l_shipdate" AS "l_shipdate", + "t11"."l_commitdate" AS "l_commitdate", + "t11"."l_receiptdate" AS "l_receiptdate", + "t11"."l_shipinstruct" AS "l_shipinstruct", + "t11"."l_shipmode" AS "l_shipmode", + "t11"."l_comment" AS "l_comment" FROM ( SELECT "t3"."c_custkey" AS "c_custkey", @@ -21,31 +58,31 @@ FROM ( "t3"."c_acctbal" AS "c_acctbal", "t3"."c_mktsegment" AS "c_mktsegment", "t3"."c_comment" AS "c_comment", - "t4"."o_orderkey" AS "o_orderkey", - "t4"."o_custkey" AS "o_custkey", - "t4"."o_orderstatus" AS "o_orderstatus", - "t4"."o_totalprice" AS "o_totalprice", - "t4"."o_orderdate" AS "o_orderdate", - "t4"."o_orderpriority" AS "o_orderpriority", - "t4"."o_clerk" AS "o_clerk", - "t4"."o_shippriority" AS "o_shippriority", - "t4"."o_comment" AS "o_comment", - "t5"."l_orderkey" AS "l_orderkey", - "t5"."l_partkey" AS "l_partkey", - "t5"."l_suppkey" AS "l_suppkey", - "t5"."l_linenumber" AS "l_linenumber", - "t5"."l_quantity" AS "l_quantity", - "t5"."l_extendedprice" AS "l_extendedprice", - "t5"."l_discount" AS "l_discount", - "t5"."l_tax" AS "l_tax", - "t5"."l_returnflag" AS "l_returnflag", - "t5"."l_linestatus" AS "l_linestatus", - "t5"."l_shipdate" AS "l_shipdate", - "t5"."l_commitdate" AS "l_commitdate", - "t5"."l_receiptdate" AS "l_receiptdate", - "t5"."l_shipinstruct" AS "l_shipinstruct", - "t5"."l_shipmode" AS "l_shipmode", - "t5"."l_comment" AS "l_comment" + "t6"."o_orderkey" AS "o_orderkey", + "t6"."o_custkey" AS "o_custkey", + "t6"."o_orderstatus" AS "o_orderstatus", + "t6"."o_totalprice" AS "o_totalprice", + "t6"."o_orderdate" AS "o_orderdate", + "t6"."o_orderpriority" AS "o_orderpriority", + "t6"."o_clerk" AS "o_clerk", + "t6"."o_shippriority" AS "o_shippriority", + "t6"."o_comment" AS "o_comment", + "t7"."l_orderkey" AS "l_orderkey", + "t7"."l_partkey" AS "l_partkey", + "t7"."l_suppkey" AS "l_suppkey", + "t7"."l_linenumber" AS "l_linenumber", + "t7"."l_quantity" AS "l_quantity", + "t7"."l_extendedprice" AS "l_extendedprice", + "t7"."l_discount" AS "l_discount", + "t7"."l_tax" AS "l_tax", + "t7"."l_returnflag" AS "l_returnflag", + "t7"."l_linestatus" AS "l_linestatus", + "t7"."l_shipdate" AS "l_shipdate", + "t7"."l_commitdate" AS "l_commitdate", + "t7"."l_receiptdate" AS "l_receiptdate", + "t7"."l_shipinstruct" AS "l_shipinstruct", + "t7"."l_shipmode" AS "l_shipmode", + "t7"."l_comment" AS "l_comment" FROM ( SELECT "t0"."C_CUSTKEY" AS "c_custkey", @@ -70,8 +107,8 @@ FROM ( "t1"."O_SHIPPRIORITY" AS "o_shippriority", "t1"."O_COMMENT" AS "o_comment" FROM "ORDERS" AS "t1" - ) AS "t4" - ON "t3"."c_custkey" = "t4"."o_custkey" + ) AS "t6" + ON "t3"."c_custkey" = "t6"."o_custkey" INNER JOIN ( SELECT "t2"."L_ORDERKEY" AS "l_orderkey", @@ -91,58 +128,52 @@ FROM ( "t2"."L_SHIPMODE" AS "l_shipmode", "t2"."L_COMMENT" AS "l_comment" FROM "LINEITEM" AS "t2" - ) AS "t5" - ON "t4"."o_orderkey" = "t5"."l_orderkey" - ) AS "t9" + ) AS "t7" + ON "t6"."o_orderkey" = "t7"."l_orderkey" + ) AS "t11" WHERE - "t9"."o_orderkey" IN (( + "t11"."o_orderkey" IN (( SELECT - "t10"."l_orderkey" AS "l_orderkey" + "t8"."l_orderkey" AS "l_orderkey" FROM ( SELECT - * + "t5"."l_orderkey" AS "l_orderkey", + SUM("t5"."l_quantity") AS "qty_sum" FROM ( SELECT - "t5"."l_orderkey" AS "l_orderkey", - SUM("t5"."l_quantity") AS "qty_sum" - FROM ( - SELECT - "t2"."L_ORDERKEY" AS "l_orderkey", - "t2"."L_PARTKEY" AS "l_partkey", - "t2"."L_SUPPKEY" AS "l_suppkey", - "t2"."L_LINENUMBER" AS "l_linenumber", - "t2"."L_QUANTITY" AS "l_quantity", - "t2"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t2"."L_DISCOUNT" AS "l_discount", - "t2"."L_TAX" AS "l_tax", - "t2"."L_RETURNFLAG" AS "l_returnflag", - "t2"."L_LINESTATUS" AS "l_linestatus", - "t2"."L_SHIPDATE" AS "l_shipdate", - "t2"."L_COMMITDATE" AS "l_commitdate", - "t2"."L_RECEIPTDATE" AS "l_receiptdate", - "t2"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t2"."L_SHIPMODE" AS "l_shipmode", - "t2"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t2" - ) AS "t5" - GROUP BY - 1 - ) AS "t8" - WHERE - ( - "t8"."qty_sum" > 300 - ) - ) AS "t10" + "t2"."L_ORDERKEY" AS "l_orderkey", + "t2"."L_PARTKEY" AS "l_partkey", + "t2"."L_SUPPKEY" AS "l_suppkey", + "t2"."L_LINENUMBER" AS "l_linenumber", + "t2"."L_QUANTITY" AS "l_quantity", + "t2"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t2"."L_DISCOUNT" AS "l_discount", + "t2"."L_TAX" AS "l_tax", + "t2"."L_RETURNFLAG" AS "l_returnflag", + "t2"."L_LINESTATUS" AS "l_linestatus", + "t2"."L_SHIPDATE" AS "l_shipdate", + "t2"."L_COMMITDATE" AS "l_commitdate", + "t2"."L_RECEIPTDATE" AS "l_receiptdate", + "t2"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t2"."L_SHIPMODE" AS "l_shipmode", + "t2"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t2" + ) AS "t5" + GROUP BY + 1 + ) AS "t8" + WHERE + "t8"."qty_sum" > 300 )) - ) AS "t12" + ) AS "t13" GROUP BY 1, 2, 3, 4, 5 -) AS "t13" +) AS "t14" ORDER BY - "t13"."o_totalprice" DESC NULLS LAST, - "t13"."o_orderdate" ASC + "t14"."o_totalprice" DESC NULLS LAST, + "t14"."o_orderdate" ASC LIMIT 100 \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h19/test_tpc_h19/snowflake/h19.sql b/ibis/backends/tests/tpch/snapshots/test_h19/test_tpc_h19/snowflake/h19.sql index 2c435997f823e..b6db87f2435ce 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h19/test_tpc_h19/snowflake/h19.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h19/test_tpc_h19/snowflake/h19.sql @@ -1,10 +1,34 @@ SELECT - SUM("t6"."l_extendedprice" * ( - 1 - "t6"."l_discount" + SUM("t7"."l_extendedprice" * ( + 1 - "t7"."l_discount" )) AS "revenue" FROM ( SELECT - * + "t6"."l_orderkey" AS "l_orderkey", + "t6"."l_partkey" AS "l_partkey", + "t6"."l_suppkey" AS "l_suppkey", + "t6"."l_linenumber" AS "l_linenumber", + "t6"."l_quantity" AS "l_quantity", + "t6"."l_extendedprice" AS "l_extendedprice", + "t6"."l_discount" AS "l_discount", + "t6"."l_tax" AS "l_tax", + "t6"."l_returnflag" AS "l_returnflag", + "t6"."l_linestatus" AS "l_linestatus", + "t6"."l_shipdate" AS "l_shipdate", + "t6"."l_commitdate" AS "l_commitdate", + "t6"."l_receiptdate" AS "l_receiptdate", + "t6"."l_shipinstruct" AS "l_shipinstruct", + "t6"."l_shipmode" AS "l_shipmode", + "t6"."l_comment" AS "l_comment", + "t6"."p_partkey" AS "p_partkey", + "t6"."p_name" AS "p_name", + "t6"."p_mfgr" AS "p_mfgr", + "t6"."p_brand" AS "p_brand", + "t6"."p_type" AS "p_type", + "t6"."p_size" AS "p_size", + "t6"."p_container" AS "p_container", + "t6"."p_retailprice" AS "p_retailprice", + "t6"."p_comment" AS "p_comment" FROM ( SELECT "t2"."l_orderkey" AS "l_orderkey", @@ -23,15 +47,15 @@ FROM ( "t2"."l_shipinstruct" AS "l_shipinstruct", "t2"."l_shipmode" AS "l_shipmode", "t2"."l_comment" AS "l_comment", - "t3"."p_partkey" AS "p_partkey", - "t3"."p_name" AS "p_name", - "t3"."p_mfgr" AS "p_mfgr", - "t3"."p_brand" AS "p_brand", - "t3"."p_type" AS "p_type", - "t3"."p_size" AS "p_size", - "t3"."p_container" AS "p_container", - "t3"."p_retailprice" AS "p_retailprice", - "t3"."p_comment" AS "p_comment" + "t4"."p_partkey" AS "p_partkey", + "t4"."p_name" AS "p_name", + "t4"."p_mfgr" AS "p_mfgr", + "t4"."p_brand" AS "p_brand", + "t4"."p_type" AS "p_type", + "t4"."p_size" AS "p_size", + "t4"."p_container" AS "p_container", + "t4"."p_retailprice" AS "p_retailprice", + "t4"."p_comment" AS "p_comment" FROM ( SELECT "t0"."L_ORDERKEY" AS "l_orderkey", @@ -64,9 +88,9 @@ FROM ( "t1"."P_RETAILPRICE" AS "p_retailprice", "t1"."P_COMMENT" AS "p_comment" FROM "PART" AS "t1" - ) AS "t3" - ON "t3"."p_partkey" = "t2"."l_partkey" - ) AS "t5" + ) AS "t4" + ON "t4"."p_partkey" = "t2"."l_partkey" + ) AS "t6" WHERE ( ( @@ -76,81 +100,79 @@ FROM ( ( ( ( - ( - "t5"."p_brand" = 'Brand#12' - ) - AND "t5"."p_container" IN ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') - ) - AND ( - "t5"."l_quantity" >= 1 + "t6"."p_brand" = 'Brand#12' ) + AND "t6"."p_container" IN ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') ) AND ( - "t5"."l_quantity" <= 11 + "t6"."l_quantity" >= 1 ) ) - AND "t5"."p_size" BETWEEN 1 AND 5 + AND ( + "t6"."l_quantity" <= 11 + ) ) - AND "t5"."l_shipmode" IN ('AIR', 'AIR REG') - ) - AND ( - "t5"."l_shipinstruct" = 'DELIVER IN PERSON' + AND "t6"."p_size" BETWEEN 1 AND 5 ) + AND "t6"."l_shipmode" IN ('AIR', 'AIR REG') ) - OR ( + AND ( + "t6"."l_shipinstruct" = 'DELIVER IN PERSON' + ) + ) + OR ( + ( ( ( ( ( ( - ( - "t5"."p_brand" = 'Brand#23' - ) - AND "t5"."p_container" IN ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') - ) - AND ( - "t5"."l_quantity" >= 10 + "t6"."p_brand" = 'Brand#23' ) + AND "t6"."p_container" IN ('MED BAG', 'MED BOX', 'MED PKG', 'MED PACK') ) AND ( - "t5"."l_quantity" <= 20 + "t6"."l_quantity" >= 10 ) ) - AND "t5"."p_size" BETWEEN 1 AND 10 + AND ( + "t6"."l_quantity" <= 20 + ) ) - AND "t5"."l_shipmode" IN ('AIR', 'AIR REG') - ) - AND ( - "t5"."l_shipinstruct" = 'DELIVER IN PERSON' + AND "t6"."p_size" BETWEEN 1 AND 10 ) + AND "t6"."l_shipmode" IN ('AIR', 'AIR REG') + ) + AND ( + "t6"."l_shipinstruct" = 'DELIVER IN PERSON' ) ) - OR ( + ) + OR ( + ( ( ( ( ( ( - ( - "t5"."p_brand" = 'Brand#34' - ) - AND "t5"."p_container" IN ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') - ) - AND ( - "t5"."l_quantity" >= 20 + "t6"."p_brand" = 'Brand#34' ) + AND "t6"."p_container" IN ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') ) AND ( - "t5"."l_quantity" <= 30 + "t6"."l_quantity" >= 20 ) ) - AND "t5"."p_size" BETWEEN 1 AND 15 + AND ( + "t6"."l_quantity" <= 30 + ) ) - AND "t5"."l_shipmode" IN ('AIR', 'AIR REG') - ) - AND ( - "t5"."l_shipinstruct" = 'DELIVER IN PERSON' + AND "t6"."p_size" BETWEEN 1 AND 15 ) + AND "t6"."l_shipmode" IN ('AIR', 'AIR REG') + ) + AND ( + "t6"."l_shipinstruct" = 'DELIVER IN PERSON' ) ) -) AS "t6" \ No newline at end of file +) AS "t7" \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h20/test_tpc_h20/snowflake/h20.sql b/ibis/backends/tests/tpch/snapshots/test_h20/test_tpc_h20/snowflake/h20.sql index 912079ab96aca..3b49410ea9965 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h20/test_tpc_h20/snowflake/h20.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h20/test_tpc_h20/snowflake/h20.sql @@ -1,137 +1,85 @@ SELECT - * + "t12"."s_name" AS "s_name", + "t12"."s_address" AS "s_address" FROM ( SELECT - "t18"."s_name" AS "s_name", - "t18"."s_address" AS "s_address" + "t5"."s_suppkey" AS "s_suppkey", + "t5"."s_name" AS "s_name", + "t5"."s_address" AS "s_address", + "t5"."s_nationkey" AS "s_nationkey", + "t5"."s_phone" AS "s_phone", + "t5"."s_acctbal" AS "s_acctbal", + "t5"."s_comment" AS "s_comment", + "t7"."n_nationkey" AS "n_nationkey", + "t7"."n_name" AS "n_name", + "t7"."n_regionkey" AS "n_regionkey", + "t7"."n_comment" AS "n_comment" FROM ( SELECT - * - FROM ( - SELECT - "t5"."s_suppkey" AS "s_suppkey", - "t5"."s_name" AS "s_name", - "t5"."s_address" AS "s_address", - "t5"."s_nationkey" AS "s_nationkey", - "t5"."s_phone" AS "s_phone", - "t5"."s_acctbal" AS "s_acctbal", - "t5"."s_comment" AS "s_comment", - "t6"."n_nationkey" AS "n_nationkey", - "t6"."n_name" AS "n_name", - "t6"."n_regionkey" AS "n_regionkey", - "t6"."n_comment" AS "n_comment" - FROM ( - SELECT - "t0"."S_SUPPKEY" AS "s_suppkey", - "t0"."S_NAME" AS "s_name", - "t0"."S_ADDRESS" AS "s_address", - "t0"."S_NATIONKEY" AS "s_nationkey", - "t0"."S_PHONE" AS "s_phone", - "t0"."S_ACCTBAL" AS "s_acctbal", - "t0"."S_COMMENT" AS "s_comment" - FROM "SUPPLIER" AS "t0" - ) AS "t5" - INNER JOIN ( - SELECT - "t1"."N_NATIONKEY" AS "n_nationkey", - "t1"."N_NAME" AS "n_name", - "t1"."N_REGIONKEY" AS "n_regionkey", - "t1"."N_COMMENT" AS "n_comment" - FROM "NATION" AS "t1" - ) AS "t6" - ON "t5"."s_nationkey" = "t6"."n_nationkey" - ) AS "t13" + "t0"."S_SUPPKEY" AS "s_suppkey", + "t0"."S_NAME" AS "s_name", + "t0"."S_ADDRESS" AS "s_address", + "t0"."S_NATIONKEY" AS "s_nationkey", + "t0"."S_PHONE" AS "s_phone", + "t0"."S_ACCTBAL" AS "s_acctbal", + "t0"."S_COMMENT" AS "s_comment" + FROM "SUPPLIER" AS "t0" + ) AS "t5" + INNER JOIN ( + SELECT + "t2"."N_NATIONKEY" AS "n_nationkey", + "t2"."N_NAME" AS "n_name", + "t2"."N_REGIONKEY" AS "n_regionkey", + "t2"."N_COMMENT" AS "n_comment" + FROM "NATION" AS "t2" + ) AS "t7" + ON "t5"."s_nationkey" = "t7"."n_nationkey" +) AS "t12" +WHERE + "t12"."n_name" = 'CANADA' + AND "t12"."s_suppkey" IN (( + SELECT + "t1"."PS_SUPPKEY" AS "ps_suppkey" + FROM "PARTSUPP" AS "t1" WHERE - ( - "t13"."n_name" = 'CANADA' - ) - AND "t13"."s_suppkey" IN (( + "t1"."PS_PARTKEY" IN (( SELECT - "t16"."ps_suppkey" AS "ps_suppkey" - FROM ( + "t3"."P_PARTKEY" AS "p_partkey" + FROM "PART" AS "t3" + WHERE + "t3"."P_NAME" LIKE 'forest%' + )) + AND "t1"."PS_AVAILQTY" > ( + ( SELECT - * + SUM("t9"."l_quantity") AS "Sum(l_quantity)" FROM ( SELECT - "t2"."PS_PARTKEY" AS "ps_partkey", - "t2"."PS_SUPPKEY" AS "ps_suppkey", - "t2"."PS_AVAILQTY" AS "ps_availqty", - "t2"."PS_SUPPLYCOST" AS "ps_supplycost", - "t2"."PS_COMMENT" AS "ps_comment" - FROM "PARTSUPP" AS "t2" - ) AS "t7" - WHERE - "t7"."ps_partkey" IN (( - SELECT - "t11"."p_partkey" AS "p_partkey" - FROM ( - SELECT - * - FROM ( - SELECT - "t3"."P_PARTKEY" AS "p_partkey", - "t3"."P_NAME" AS "p_name", - "t3"."P_MFGR" AS "p_mfgr", - "t3"."P_BRAND" AS "p_brand", - "t3"."P_TYPE" AS "p_type", - "t3"."P_SIZE" AS "p_size", - "t3"."P_CONTAINER" AS "p_container", - "t3"."P_RETAILPRICE" AS "p_retailprice", - "t3"."P_COMMENT" AS "p_comment" - FROM "PART" AS "t3" - ) AS "t8" - WHERE - "t8"."p_name" LIKE 'forest%' - ) AS "t11" - )) - AND ( - "t7"."ps_availqty" > ( - ( - SELECT - SUM("t12"."l_quantity") AS "Sum(l_quantity)" - FROM ( - SELECT - * - FROM ( - SELECT - "t4"."L_ORDERKEY" AS "l_orderkey", - "t4"."L_PARTKEY" AS "l_partkey", - "t4"."L_SUPPKEY" AS "l_suppkey", - "t4"."L_LINENUMBER" AS "l_linenumber", - "t4"."L_QUANTITY" AS "l_quantity", - "t4"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t4"."L_DISCOUNT" AS "l_discount", - "t4"."L_TAX" AS "l_tax", - "t4"."L_RETURNFLAG" AS "l_returnflag", - "t4"."L_LINESTATUS" AS "l_linestatus", - "t4"."L_SHIPDATE" AS "l_shipdate", - "t4"."L_COMMITDATE" AS "l_commitdate", - "t4"."L_RECEIPTDATE" AS "l_receiptdate", - "t4"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t4"."L_SHIPMODE" AS "l_shipmode", - "t4"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t4" - ) AS "t9" - WHERE - ( - "t9"."l_partkey" = "t7"."ps_partkey" - ) - AND ( - "t9"."l_suppkey" = "t7"."ps_suppkey" - ) - AND ( - "t9"."l_shipdate" >= DATEFROMPARTS(1994, 1, 1) - ) - AND ( - "t9"."l_shipdate" < DATEFROMPARTS(1995, 1, 1) - ) - ) AS "t12" - ) * 0.5 - ) - ) - ) AS "t16" - )) - ) AS "t18" -) AS "t19" + "t4"."L_ORDERKEY" AS "l_orderkey", + "t4"."L_PARTKEY" AS "l_partkey", + "t4"."L_SUPPKEY" AS "l_suppkey", + "t4"."L_LINENUMBER" AS "l_linenumber", + "t4"."L_QUANTITY" AS "l_quantity", + "t4"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t4"."L_DISCOUNT" AS "l_discount", + "t4"."L_TAX" AS "l_tax", + "t4"."L_RETURNFLAG" AS "l_returnflag", + "t4"."L_LINESTATUS" AS "l_linestatus", + "t4"."L_SHIPDATE" AS "l_shipdate", + "t4"."L_COMMITDATE" AS "l_commitdate", + "t4"."L_RECEIPTDATE" AS "l_receiptdate", + "t4"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t4"."L_SHIPMODE" AS "l_shipmode", + "t4"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t4" + WHERE + "t4"."L_PARTKEY" = "t1"."PS_PARTKEY" + AND "t4"."L_SUPPKEY" = "t1"."PS_SUPPKEY" + AND "t4"."L_SHIPDATE" >= DATEFROMPARTS(1994, 1, 1) + AND "t4"."L_SHIPDATE" < DATEFROMPARTS(1995, 1, 1) + ) AS "t9" + ) * 0.5 + ) + )) ORDER BY - "t19"."s_name" ASC \ No newline at end of file + "t12"."s_name" ASC \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h21/test_tpc_h21/snowflake/h21.sql b/ibis/backends/tests/tpch/snapshots/test_h21/test_tpc_h21/snowflake/h21.sql index 439cc353ca670..89f5d7d5071c6 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h21/test_tpc_h21/snowflake/h21.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h21/test_tpc_h21/snowflake/h21.sql @@ -1,21 +1,28 @@ SELECT - * + "t20"."s_name" AS "s_name", + "t20"."numwait" AS "numwait" FROM ( SELECT - "t17"."s_name" AS "s_name", + "t19"."s_name" AS "s_name", COUNT(*) AS "numwait" FROM ( SELECT - * + "t16"."l1_orderkey" AS "l1_orderkey", + "t16"."o_orderstatus" AS "o_orderstatus", + "t16"."l_receiptdate" AS "l_receiptdate", + "t16"."l_commitdate" AS "l_commitdate", + "t16"."l1_suppkey" AS "l1_suppkey", + "t16"."s_name" AS "s_name", + "t16"."n_name" AS "n_name" FROM ( SELECT - "t5"."l_orderkey" AS "l1_orderkey", - "t6"."o_orderstatus" AS "o_orderstatus", - "t5"."l_receiptdate" AS "l_receiptdate", - "t5"."l_commitdate" AS "l_commitdate", - "t5"."l_suppkey" AS "l1_suppkey", + "t8"."l_orderkey" AS "l1_orderkey", + "t11"."o_orderstatus" AS "o_orderstatus", + "t8"."l_receiptdate" AS "l_receiptdate", + "t8"."l_commitdate" AS "l_commitdate", + "t8"."l_suppkey" AS "l1_suppkey", "t4"."s_name" AS "s_name", - "t7"."n_name" AS "n_name" + "t12"."n_name" AS "n_name" FROM ( SELECT "t0"."S_SUPPKEY" AS "s_suppkey", @@ -46,8 +53,8 @@ FROM ( "t1"."L_SHIPMODE" AS "l_shipmode", "t1"."L_COMMENT" AS "l_comment" FROM "LINEITEM" AS "t1" - ) AS "t5" - ON "t4"."s_suppkey" = "t5"."l_suppkey" + ) AS "t8" + ON "t4"."s_suppkey" = "t8"."l_suppkey" INNER JOIN ( SELECT "t2"."O_ORDERKEY" AS "o_orderkey", @@ -60,8 +67,8 @@ FROM ( "t2"."O_SHIPPRIORITY" AS "o_shippriority", "t2"."O_COMMENT" AS "o_comment" FROM "ORDERS" AS "t2" - ) AS "t6" - ON "t6"."o_orderkey" = "t5"."l_orderkey" + ) AS "t11" + ON "t11"."o_orderkey" = "t8"."l_orderkey" INNER JOIN ( SELECT "t3"."N_NATIONKEY" AS "n_nationkey", @@ -69,26 +76,51 @@ FROM ( "t3"."N_REGIONKEY" AS "n_regionkey", "t3"."N_COMMENT" AS "n_comment" FROM "NATION" AS "t3" - ) AS "t7" - ON "t4"."s_nationkey" = "t7"."n_nationkey" - ) AS "t12" + ) AS "t12" + ON "t4"."s_nationkey" = "t12"."n_nationkey" + ) AS "t16" WHERE - ( - "t12"."o_orderstatus" = 'F' - ) - AND ( - "t12"."l_receiptdate" > "t12"."l_commitdate" - ) - AND ( - "t12"."n_name" = 'SAUDI ARABIA' - ) + "t16"."o_orderstatus" = 'F' + AND "t16"."l_receiptdate" > "t16"."l_commitdate" + AND "t16"."n_name" = 'SAUDI ARABIA' AND EXISTS( ( SELECT 1 AS "1" FROM ( SELECT - * + "t1"."L_ORDERKEY" AS "l_orderkey", + "t1"."L_PARTKEY" AS "l_partkey", + "t1"."L_SUPPKEY" AS "l_suppkey", + "t1"."L_LINENUMBER" AS "l_linenumber", + "t1"."L_QUANTITY" AS "l_quantity", + "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", + "t1"."L_DISCOUNT" AS "l_discount", + "t1"."L_TAX" AS "l_tax", + "t1"."L_RETURNFLAG" AS "l_returnflag", + "t1"."L_LINESTATUS" AS "l_linestatus", + "t1"."L_SHIPDATE" AS "l_shipdate", + "t1"."L_COMMITDATE" AS "l_commitdate", + "t1"."L_RECEIPTDATE" AS "l_receiptdate", + "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", + "t1"."L_SHIPMODE" AS "l_shipmode", + "t1"."L_COMMENT" AS "l_comment" + FROM "LINEITEM" AS "t1" + ) AS "t9" + WHERE + ( + "t9"."l_orderkey" = "t16"."l1_orderkey" + ) + AND ( + "t9"."l_suppkey" <> "t16"."l1_suppkey" + ) + ) + ) + AND NOT ( + EXISTS( + ( + SELECT + 1 AS "1" FROM ( SELECT "t1"."L_ORDERKEY" AS "l_orderkey", @@ -108,70 +140,27 @@ FROM ( "t1"."L_SHIPMODE" AS "l_shipmode", "t1"."L_COMMENT" AS "l_comment" FROM "LINEITEM" AS "t1" - ) AS "t8" + ) AS "t10" WHERE ( ( - "t8"."l_orderkey" = "t12"."l1_orderkey" + "t10"."l_orderkey" = "t16"."l1_orderkey" ) AND ( - "t8"."l_suppkey" <> "t12"."l1_suppkey" + "t10"."l_suppkey" <> "t16"."l1_suppkey" ) ) - ) AS "t13" - ) - ) - AND NOT ( - EXISTS( - ( - SELECT - 1 AS "1" - FROM ( - SELECT - * - FROM ( - SELECT - "t1"."L_ORDERKEY" AS "l_orderkey", - "t1"."L_PARTKEY" AS "l_partkey", - "t1"."L_SUPPKEY" AS "l_suppkey", - "t1"."L_LINENUMBER" AS "l_linenumber", - "t1"."L_QUANTITY" AS "l_quantity", - "t1"."L_EXTENDEDPRICE" AS "l_extendedprice", - "t1"."L_DISCOUNT" AS "l_discount", - "t1"."L_TAX" AS "l_tax", - "t1"."L_RETURNFLAG" AS "l_returnflag", - "t1"."L_LINESTATUS" AS "l_linestatus", - "t1"."L_SHIPDATE" AS "l_shipdate", - "t1"."L_COMMITDATE" AS "l_commitdate", - "t1"."L_RECEIPTDATE" AS "l_receiptdate", - "t1"."L_SHIPINSTRUCT" AS "l_shipinstruct", - "t1"."L_SHIPMODE" AS "l_shipmode", - "t1"."L_COMMENT" AS "l_comment" - FROM "LINEITEM" AS "t1" - ) AS "t8" - WHERE - ( - ( - ( - "t8"."l_orderkey" = "t12"."l1_orderkey" - ) - AND ( - "t8"."l_suppkey" <> "t12"."l1_suppkey" - ) - ) - AND ( - "t8"."l_receiptdate" > "t8"."l_commitdate" - ) - ) - ) AS "t15" + AND ( + "t10"."l_receiptdate" > "t10"."l_commitdate" + ) ) ) ) - ) AS "t17" + ) AS "t19" GROUP BY 1 -) AS "t18" +) AS "t20" ORDER BY - "t18"."numwait" DESC NULLS LAST, - "t18"."s_name" ASC + "t20"."numwait" DESC NULLS LAST, + "t20"."s_name" ASC LIMIT 100 \ No newline at end of file diff --git a/ibis/backends/tests/tpch/snapshots/test_h22/test_tpc_h22/snowflake/h22.sql b/ibis/backends/tests/tpch/snapshots/test_h22/test_tpc_h22/snowflake/h22.sql index f3074f91e2f65..a8e109a092080 100644 --- a/ibis/backends/tests/tpch/snapshots/test_h22/test_tpc_h22/snowflake/h22.sql +++ b/ibis/backends/tests/tpch/snapshots/test_h22/test_tpc_h22/snowflake/h22.sql @@ -1,91 +1,52 @@ SELECT - * + "t6"."cntrycode" AS "cntrycode", + "t6"."numcust" AS "numcust", + "t6"."totacctbal" AS "totacctbal" FROM ( SELECT - "t9"."cntrycode" AS "cntrycode", + "t5"."cntrycode" AS "cntrycode", COUNT(*) AS "numcust", - SUM("t9"."c_acctbal") AS "totacctbal" + SUM("t5"."c_acctbal") AS "totacctbal" FROM ( SELECT - IFF(0 >= 0, SUBSTRING("t8"."c_phone", 0 + 1, 2), SUBSTRING("t8"."c_phone", 0, 2)) AS "cntrycode", - "t8"."c_acctbal" AS "c_acctbal" - FROM ( - SELECT - * - FROM ( + IFF(0 >= 0, SUBSTRING("t0"."C_PHONE", 0 + 1, 2), SUBSTRING("t0"."C_PHONE", 0, 2)) AS "cntrycode", + "t0"."C_ACCTBAL" AS "c_acctbal" + FROM "CUSTOMER" AS "t0" + WHERE + IFF(0 >= 0, SUBSTRING("t0"."C_PHONE", 0 + 1, 2), SUBSTRING("t0"."C_PHONE", 0, 2)) IN ('13', '31', '23', '29', '30', '18', '17') + AND "t0"."C_ACCTBAL" > ( 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" - FROM "CUSTOMER" AS "t0" - ) AS "t2" - WHERE - IFF(0 >= 0, SUBSTRING("t2"."c_phone", 0 + 1, 2), SUBSTRING("t2"."c_phone", 0, 2)) IN ('13', '31', '23', '29', '30', '18', '17') - AND ( - "t2"."c_acctbal" > ( + AVG("t3"."c_acctbal") AS "Mean(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" + FROM "CUSTOMER" AS "t0" + WHERE + "t0"."C_ACCTBAL" > 0.0 + AND IFF(0 >= 0, SUBSTRING("t0"."C_PHONE", 0 + 1, 2), SUBSTRING("t0"."C_PHONE", 0, 2)) IN ('13', '31', '23', '29', '30', '18', '17') + ) AS "t3" + ) + AND NOT ( + EXISTS( + ( SELECT - AVG("t5"."c_acctbal") AS "Mean(c_acctbal)" - FROM ( - SELECT - * - 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" - FROM "CUSTOMER" AS "t0" - ) AS "t2" - WHERE - ( - "t2"."c_acctbal" > 0.0 - ) - AND IFF(0 >= 0, SUBSTRING("t2"."c_phone", 0 + 1, 2), SUBSTRING("t2"."c_phone", 0, 2)) IN ('13', '31', '23', '29', '30', '18', '17') - ) AS "t5" + 1 AS "1" + FROM "ORDERS" AS "t1" + WHERE + "t1"."O_CUSTKEY" = "t0"."C_CUSTKEY" ) ) - AND NOT ( - EXISTS( - ( - SELECT - 1 AS "1" - FROM ( - SELECT - * - FROM ( - SELECT - "t1"."O_ORDERKEY" AS "o_orderkey", - "t1"."O_CUSTKEY" AS "o_custkey", - "t1"."O_ORDERSTATUS" AS "o_orderstatus", - "t1"."O_TOTALPRICE" AS "o_totalprice", - "t1"."O_ORDERDATE" AS "o_orderdate", - "t1"."O_ORDERPRIORITY" AS "o_orderpriority", - "t1"."O_CLERK" AS "o_clerk", - "t1"."O_SHIPPRIORITY" AS "o_shippriority", - "t1"."O_COMMENT" AS "o_comment" - FROM "ORDERS" AS "t1" - ) AS "t3" - WHERE - ( - "t3"."o_custkey" = "t2"."c_custkey" - ) - ) AS "t4" - ) - ) - ) - ) AS "t8" - ) AS "t9" + ) + ) AS "t5" GROUP BY 1 -) AS "t10" +) AS "t6" ORDER BY - "t10"."cntrycode" ASC \ No newline at end of file + "t6"."cntrycode" ASC \ No newline at end of file