Skip to content

Commit

Permalink
test(snowflake): fix snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Apr 10, 2024
1 parent 2648498 commit 7f08bbc
Show file tree
Hide file tree
Showing 2 changed files with 166 additions and 133 deletions.
Original file line number Diff line number Diff line change
@@ -1,93 +1,115 @@
SELECT
"t12"."s_name",
"t12"."s_address"
"t16"."s_name",
"t16"."s_address"
FROM (
SELECT
"t8"."s_suppkey",
"t8"."s_name",
"t8"."s_address",
"t8"."s_nationkey",
"t8"."s_phone",
"t8"."s_acctbal",
"t8"."s_comment",
"t9"."n_nationkey",
"t9"."n_name",
"t9"."n_regionkey",
"t9"."n_comment"
"t12"."s_suppkey",
"t12"."s_name",
"t12"."s_address",
"t12"."s_nationkey",
"t12"."s_phone",
"t12"."s_acctbal",
"t12"."s_comment",
"t12"."n_nationkey",
"t12"."n_name",
"t12"."n_regionkey",
"t12"."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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."SUPPLIER" AS "t0"
) AS "t8"
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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."NATION" AS "t2"
) AS "t9"
ON "t8"."s_nationkey" = "t9"."n_nationkey"
) AS "t12"
WHERE
"t12"."n_name" = 'CANADA'
AND "t12"."s_suppkey" IN (
SELECT
"t6"."ps_suppkey"
"t8"."s_suppkey",
"t8"."s_name",
"t8"."s_address",
"t8"."s_nationkey",
"t8"."s_phone",
"t8"."s_acctbal",
"t8"."s_comment",
"t9"."n_nationkey",
"t9"."n_name",
"t9"."n_regionkey",
"t9"."n_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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."PARTSUPP" AS "t1"
) AS "t6"
WHERE
"t6"."ps_partkey" IN (
"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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."SUPPLIER" AS "t0"
) AS "t8"
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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."NATION" AS "t1"
) AS "t9"
ON "t8"."s_nationkey" = "t9"."n_nationkey"
) AS "t12"
WHERE
"t12"."n_name" = 'CANADA'
AND "t12"."s_suppkey" IN (
SELECT
"t14"."ps_suppkey"
FROM (
SELECT
"t3"."P_PARTKEY" AS "p_partkey"
FROM "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."PART" AS "t3"
WHERE
"t3"."P_NAME" LIKE 'forest%'
)
AND "t6"."ps_availqty" > (
(
"t7"."ps_partkey",
"t7"."ps_suppkey",
"t7"."ps_availqty",
"t7"."ps_supplycost",
"t7"."ps_comment"
FROM (
SELECT
SUM("t11"."l_quantity") AS "Sum(l_quantity)"
FROM (
"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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."PARTSUPP" AS "t2"
) AS "t7"
WHERE
"t7"."ps_partkey" IN (
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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."LINEITEM" AS "t4"
"t3"."P_PARTKEY" AS "p_partkey"
FROM "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."PART" AS "t3"
WHERE
"t4"."L_PARTKEY" = "t6"."ps_partkey"
AND "t4"."L_SUPPKEY" = "t6"."ps_suppkey"
AND "t4"."L_SHIPDATE" >= DATE_FROM_PARTS(1994, 1, 1)
AND "t4"."L_SHIPDATE" < DATE_FROM_PARTS(1995, 1, 1)
) AS "t11"
) * 0.5
)
)
"t3"."P_NAME" LIKE 'forest%'
)
AND "t7"."ps_availqty" > (
(
SELECT
SUM("t11"."l_quantity") AS "Sum(l_quantity)"
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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."LINEITEM" AS "t4"
WHERE
"t4"."L_PARTKEY" = "t7"."ps_partkey"
AND "t4"."L_SUPPKEY" = "t7"."ps_suppkey"
AND "t4"."L_SHIPDATE" >= DATE_FROM_PARTS(1994, 1, 1)
AND "t4"."L_SHIPDATE" < DATE_FROM_PARTS(1995, 1, 1)
) AS "t11"
) * 0.5
)
) AS "t14"
)
) AS "t16"
ORDER BY
"t12"."s_name" ASC
"t16"."s_name" ASC
Original file line number Diff line number Diff line change
@@ -1,67 +1,78 @@
SELECT
"t7"."cntrycode",
"t7"."numcust",
"t7"."totacctbal"
"t8"."cntrycode",
"t8"."numcust",
"t8"."totacctbal"
FROM (
SELECT
"t6"."cntrycode",
"t7"."cntrycode",
COUNT(*) AS "numcust",
SUM("t6"."c_acctbal") AS "totacctbal"
SUM("t7"."c_acctbal") AS "totacctbal"
FROM (
SELECT
SUBSTRING("t2"."c_phone", IFF((
SUBSTRING("t6"."c_phone", IFF((
0 + 1
) >= 1, 0 + 1, 0 + 1 + LENGTH("t2"."c_phone")), 2) AS "cntrycode",
"t2"."c_acctbal"
) >= 1, 0 + 1, 0 + 1 + LENGTH("t6"."c_phone")), 2) AS "cntrycode",
"t6"."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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."CUSTOMER" AS "t0"
) AS "t2"
WHERE
SUBSTRING("t2"."c_phone", IFF((
0 + 1
) >= 1, 0 + 1, 0 + 1 + LENGTH("t2"."c_phone")), 2) IN ('13', '31', '23', '29', '30', '18', '17')
AND "t2"."c_acctbal" > (
"t2"."c_custkey",
"t2"."c_name",
"t2"."c_address",
"t2"."c_nationkey",
"t2"."c_phone",
"t2"."c_acctbal",
"t2"."c_mktsegment",
"t2"."c_comment"
FROM (
SELECT
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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."CUSTOMER" AS "t0"
WHERE
"t0"."C_ACCTBAL" > 0.0
AND SUBSTRING("t0"."C_PHONE", IFF((
0 + 1
) >= 1, 0 + 1, 0 + 1 + LENGTH("t0"."C_PHONE")), 2) IN ('13', '31', '23', '29', '30', '18', '17')
) AS "t3"
)
AND NOT (
EXISTS(
"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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."CUSTOMER" AS "t0"
) AS "t2"
WHERE
SUBSTRING("t2"."c_phone", IFF((
0 + 1
) >= 1, 0 + 1, 0 + 1 + LENGTH("t2"."c_phone")), 2) IN ('13', '31', '23', '29', '30', '18', '17')
AND "t2"."c_acctbal" > (
SELECT
1
FROM "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."ORDERS" AS "t1"
WHERE
"t1"."O_CUSTKEY" = "t2"."c_custkey"
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 "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."CUSTOMER" AS "t0"
WHERE
"t0"."C_ACCTBAL" > 0.0
AND SUBSTRING("t0"."C_PHONE", IFF((
0 + 1
) >= 1, 0 + 1, 0 + 1 + LENGTH("t0"."C_PHONE")), 2) IN ('13', '31', '23', '29', '30', '18', '17')
) AS "t3"
)
AND NOT (
EXISTS(
SELECT
1
FROM "SNOWFLAKE_SAMPLE_DATA"."TPCH_SF1"."ORDERS" AS "t1"
WHERE
"t1"."O_CUSTKEY" = "t2"."c_custkey"
)
)
)
) AS "t6"
) AS "t6"
) AS "t7"
GROUP BY
1
) AS "t7"
) AS "t8"
ORDER BY
"t7"."cntrycode" ASC
"t8"."cntrycode" ASC

0 comments on commit 7f08bbc

Please sign in to comment.