Skip to content

Commit

Permalink
refactor(test_sqlalchemy.py): move to snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Feb 16, 2023
1 parent a794ace commit 96998f0
Show file tree
Hide file tree
Showing 65 changed files with 771 additions and 678 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
SELECT t0.foo_id, sum(t0.f) AS total
FROM star1 AS t0 GROUP BY 1
HAVING count(*) > 100
SELECT
t0.foo_id,
SUM(t0.f) AS total
FROM star1 AS t0
GROUP BY
1
HAVING
COUNT(*) > 100
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
SELECT t0.foo_id, sum(t0.f) AS total
FROM star1 AS t0 GROUP BY 1
HAVING sum(t0.f) > 10
SELECT
t0.foo_id,
SUM(t0.f) AS total
FROM star1 AS t0
GROUP BY
1
HAVING
SUM(t0.f) > 10
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SELECT
t0.foo_id,
SUM(t0.f) AS total
FROM star1 AS t0
GROUP BY
1

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
t0.foo_id,
t0.bar_id,
SUM(t0.f) AS total
FROM star1 AS t0
GROUP BY
1,
2

This file was deleted.

3 changes: 3 additions & 0 deletions ibis/tests/sql/snapshots/test_sqlalchemy/test_between/out.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col BETWEEN 5 AND 10 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col > 0 AND t0.double_col < 5 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col < 0 OR t0.double_col > 5 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SELECT
COALESCE(
CASE WHEN (
t0.double_col > 30
) THEN t0.double_col ELSE NULL END,
NULL,
t0.float_col
) AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col = 5 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col >= 5 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col > 5 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col <= 5 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col < 5 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col <> 5 AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
WITH t0 AS
(SELECT t2.g AS g, sum(t2.f) AS metric
FROM alltypes AS t2 GROUP BY 1)
SELECT t0.g, t0.metric
FROM t0 JOIN t0 AS t1 ON t0.g = t1.g
WITH t0 AS (
SELECT
t2.g AS g,
SUM(t2.f) AS metric
FROM alltypes AS t2
GROUP BY
1
)
SELECT
t0.g,
t0.metric
FROM t0
JOIN t0 AS t1
ON t0.g = t1.g
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT count(DISTINCT t0.int_col) AS nunique
SELECT
COUNT(DISTINCT t0.int_col) AS nunique
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
SELECT t0.string_col, count(DISTINCT t0.int_col) AS nunique
FROM functional_alltypes AS t0 GROUP BY 1
SELECT
t0.string_col,
COUNT(DISTINCT t0.int_col) AS nunique
FROM functional_alltypes AS t0
GROUP BY
1
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
SELECT DISTINCT t0.string_col, t0.int_col
SELECT DISTINCT
t0.string_col,
t0.int_col
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
SELECT DISTINCT t0.string_col
SELECT DISTINCT
t0.string_col
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -1,2 +1,15 @@
SELECT DISTINCT t0.id, t0.bool_col, t0.tinyint_col, t0.smallint_col, t0.int_col, t0.bigint_col, t0.float_col, t0.double_col, t0.date_string_col, t0.string_col, t0.timestamp_col, t0.year, t0.month
SELECT DISTINCT
t0.id,
t0.bool_col,
t0.tinyint_col,
t0.smallint_col,
t0.int_col,
t0.bigint_col,
t0.float_col,
t0.double_col,
t0.date_string_col,
t0.string_col,
t0.timestamp_col,
t0.year,
t0.month
FROM functional_alltypes AS t0
18 changes: 13 additions & 5 deletions ibis/tests/sql/snapshots/test_sqlalchemy/test_exists/e1.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
SELECT t0.key1, t0.key2, t0.value1
FROM foo_t AS t0
WHERE EXISTS (SELECT 1 AS anon_1
FROM bar_t AS t1
WHERE t0.key1 = t1.key1)
SELECT
t0.key1,
t0.key2,
t0.value1
FROM foo_t AS t0
WHERE
EXISTS(
SELECT
1 AS anon_1
FROM bar_t AS t1
WHERE
t0.key1 = t1.key1
)
18 changes: 13 additions & 5 deletions ibis/tests/sql/snapshots/test_sqlalchemy/test_exists/e2.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
SELECT t0.key1, t0.key2, t0.value1
FROM foo_t AS t0
WHERE EXISTS (SELECT 1 AS anon_1
FROM bar_t AS t1
WHERE t0.key1 = t1.key1 AND t1.key2 = 'foo')
SELECT
t0.key1,
t0.key2,
t0.value1
FROM foo_t AS t0
WHERE
EXISTS(
SELECT
1 AS anon_1
FROM bar_t AS t1
WHERE
t0.key1 = t1.key1 AND t1.key2 = 'foo'
)
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
SELECT t0.int_col, t0.bigint_col
FROM (SELECT t1.int_col AS int_col, sum(t1.bigint_col) AS bigint_col
FROM t AS t1 GROUP BY 1) AS t0
WHERE t0.bigint_col = 60
SELECT
t0.int_col,
t0.bigint_col
FROM (
SELECT
t1.int_col AS int_col,
SUM(t1.bigint_col) AS bigint_col
FROM t AS t1
GROUP BY
1
) AS t0
WHERE
t0.bigint_col = 60
40 changes: 40 additions & 0 deletions ibis/tests/sql/snapshots/test_sqlalchemy/test_gh_1045/out.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
SELECT
t0.t1_id1,
t0.t1_val1,
t1.dt,
t1.id3,
t1.t3_val2,
t1.id2a,
t1.id2b,
t1.val2
FROM (
SELECT
t2.id1 AS t1_id1,
t2.val1 AS t1_val1
FROM test1 AS t2
) AS t0
LEFT OUTER JOIN (
SELECT
t2.dt AS dt,
t2.id3 AS id3,
t2.t3_val2 AS t3_val2,
t3.id2a AS id2a,
t3.id2b AS id2b,
t3.val2 AS val2
FROM (
SELECT
t4.dt AS dt,
t4.id3 AS id3,
t4.id3 AS t3_val2
FROM (
SELECT
t5.val2 AS val2,
t5.dt AS dt,
CAST(t5.id3 AS BIGINT) AS id3
FROM test3 AS t5
) AS t4
) AS t2
JOIN test2 AS t3
ON t3.id2b = t2.id3
) AS t1
ON t0.t1_id1 = t1.id2a
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
t0.double_col IS NULL AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SELECT
NOT t0.double_col IS NULL AS tmp
FROM functional_alltypes AS t0
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
SELECT
t0.n_nationkey,
t0.n_name,
t0.n_regionkey,
t0.n_comment,
t1.r_regionkey,
t1.r_name,
t1.r_comment,
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 tpch_nation AS t0
JOIN tpch_region AS t1
ON t0.n_regionkey = t1.r_regionkey
JOIN tpch_customer AS t2
ON t0.n_nationkey = t2.c_nationkey
11 changes: 11 additions & 0 deletions ibis/tests/sql/snapshots/test_sqlalchemy/test_joins/inner/out.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SELECT
t0.r_regionkey,
t0.r_name,
t0.r_comment,
t1.n_nationkey,
t1.n_name,
t1.n_regionkey,
t1.n_comment
FROM tpch_region AS t0
JOIN tpch_nation AS t1
ON t0.r_regionkey = t1.n_regionkey
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
t1.n_nationkey,
t1.n_name,
t1.n_regionkey,
t1.n_comment
FROM tpch_region AS t0
JOIN tpch_nation AS t1
ON t0.r_regionkey = t1.n_regionkey
11 changes: 11 additions & 0 deletions ibis/tests/sql/snapshots/test_sqlalchemy/test_joins/left/out.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SELECT
t0.r_regionkey,
t0.r_name,
t0.r_comment,
t1.n_nationkey,
t1.n_name,
t1.n_regionkey,
t1.n_comment
FROM tpch_region AS t0
LEFT OUTER JOIN tpch_nation AS t1
ON t0.r_regionkey = t1.n_regionkey
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
t1.n_nationkey,
t1.n_name,
t1.n_regionkey,
t1.n_comment
FROM tpch_region AS t0
LEFT OUTER JOIN tpch_nation AS t1
ON t0.r_regionkey = t1.n_regionkey
11 changes: 11 additions & 0 deletions ibis/tests/sql/snapshots/test_sqlalchemy/test_joins/outer/out.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SELECT
t0.r_regionkey,
t0.r_name,
t0.r_comment,
t1.n_nationkey,
t1.n_name,
t1.n_regionkey,
t1.n_comment
FROM tpch_region AS t0
FULL OUTER JOIN tpch_nation AS t1
ON t0.r_regionkey = t1.n_regionkey
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
SELECT
t1.n_nationkey,
t1.n_name,
t1.n_regionkey,
t1.n_comment
FROM tpch_region AS t0
FULL OUTER JOIN tpch_nation AS t1
ON t0.r_regionkey = t1.n_regionkey
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
SELECT
t0.c,
t0.f,
t0.foo_id,
t0.bar_id
FROM star1 AS t0
LIMIT 10
Loading

0 comments on commit 96998f0

Please sign in to comment.