Skip to content

Commit

Permalink
test: regen sql and decompiled.pys
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Dec 22, 2023
1 parent 2ceb7f5 commit 76f516a
Show file tree
Hide file tree
Showing 42 changed files with 682 additions and 620 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@


lit = ibis.timestamp("2018-01-01 00:00:00")
t = ibis.table(name="t", schema={"a": "int64", "b": "string", "c": "timestamp"})
s = ibis.table(name="s", schema={"b": "string"})
t = ibis.table(name="t", schema={"a": "int64", "b": "string", "c": "timestamp"})
f = t.filter(t.c == lit)
p = f.select(f.a, f.b, lit.name("the_date"))
joinchain = p.inner_join(s, p.b == s.b)
joinchain = f.select(f.a, f.b, lit.name("the_date")).inner_join(
s, f.select(f.a, f.b, lit.name("the_date")).b == s.b
)

result = joinchain.filter(joinchain.a < 1.0)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SELECT
t5.a AS a
t6.a AS a
FROM (
SELECT
t3.a AS a
t4.a AS a
FROM (
SELECT
t0.a AS a,
Expand All @@ -11,9 +11,9 @@ FROM (
FROM t AS t0
WHERE
t0.c = MAKE_TIMESTAMP(2018, 1, 1, 0, 0, 0.0)
) AS t3
) AS t4
INNER JOIN s AS t2
ON t3.b = t2.b
) AS t5
ON t4.b = t2.b
) AS t6
WHERE
t5.a < CAST(1.0 AS DOUBLE)
t6.a < CAST(1.0 AS DOUBLE)
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
import ibis


tpch_region = ibis.table(
name="tpch_region",
schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"},
)

result = tpch_region.inner_join(
result = (
ibis.table(
name="tpch_nation",
schema={
"n_nationkey": "int16",
"n_name": "string",
"n_regionkey": "int16",
"n_comment": "string",
},
),
tpch_region.r_regionkey
== ibis.table(
name="tpch_nation",
schema={
"n_nationkey": "int16",
"n_name": "string",
"n_regionkey": "int16",
"n_comment": "string",
},
).n_regionkey,
).count()
name="tpch_region",
schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"},
)
.inner_join(
ibis.table(
name="tpch_nation",
schema={
"n_nationkey": "int16",
"n_name": "string",
"n_regionkey": "int16",
"n_comment": "string",
},
),
ibis.table(
name="tpch_region",
schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"},
).r_regionkey
== ibis.table(
name="tpch_nation",
schema={
"n_nationkey": "int16",
"n_name": "string",
"n_regionkey": "int16",
"n_comment": "string",
},
).n_regionkey,
)
.count()
)
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
SELECT
t4.foo_id AS foo_id,
SUM(t4.value1) AS total
t5.foo_id AS foo_id,
SUM(t5.value1) AS total
FROM (
SELECT
t0.c AS c,
t0.f AS f,
t0.foo_id AS foo_id,
t0.bar_id AS bar_id,
t2.value1 AS value1
FROM star1 AS t0
INNER JOIN star2 AS t2
ON t0.foo_id = t2.foo_id
) AS t4
t2.c AS c,
t2.f AS f,
t2.foo_id AS foo_id,
t2.bar_id AS bar_id,
t3.value1 AS value1
FROM star1 AS t2
INNER JOIN star2 AS t3
ON t2.foo_id = t3.foo_id
) AS t5
GROUP BY
1
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import ibis


star1 = ibis.table(
result = ibis.table(
name="star1",
schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"},
)

result = star1.anti_join(
).anti_join(
ibis.table(
name="star2",
schema={"foo_id": "string", "value1": "float64", "value3": "float64"},
),
star1.foo_id
ibis.table(
name="star1",
schema={"c": "int32", "f": "float64", "foo_id": "string", "bar_id": "string"},
).foo_id
== ibis.table(
name="star2",
schema={"foo_id": "string", "value1": "float64", "value3": "float64"},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SELECT
t0.c AS c,
t0.f AS f,
t0.foo_id AS foo_id,
t0.bar_id AS bar_id
FROM star1 AS t0
ANTI JOIN star2 AS t2
ON t0.foo_id = t2.foo_id
t2.c AS c,
t2.f AS f,
t2.foo_id AS foo_id,
t2.bar_id AS bar_id
FROM star1 AS t2
ANTI JOIN star2 AS t3
ON t2.foo_id = t3.foo_id
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SELECT
t2.region AS region,
t2.total - t4.total AS diff
t4.region AS region,
t4.total - t5.total AS diff
FROM (
SELECT
t1.region AS region,
Expand All @@ -18,7 +18,7 @@ FROM (
) AS t1
WHERE
t1.kind = 'foo'
) AS t2
) AS t4
INNER JOIN (
SELECT
t1.region AS region,
Expand All @@ -36,5 +36,5 @@ INNER JOIN (
) AS t1
WHERE
t1.kind = 'bar'
) AS t4
ON t2.region = t4.region
) AS t5
ON t4.region = t5.region
Original file line number Diff line number Diff line change
@@ -1,52 +1,70 @@
import ibis


tpch_nation = ibis.table(
name="tpch_nation",
schema={
"n_nationkey": "int16",
"n_name": "string",
"n_regionkey": "int16",
"n_comment": "string",
},
)

result = tpch_nation.inner_join(
ibis.table(
name="tpch_region",
schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"},
),
tpch_nation.n_regionkey
== ibis.table(
name="tpch_region",
schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"},
).r_regionkey,
).inner_join(
result = (
ibis.table(
name="tpch_customer",
schema={
"c_custkey": "int64",
"c_name": "string",
"c_address": "string",
"c_nationkey": "int16",
"c_phone": "string",
"c_acctbal": "decimal",
"c_mktsegment": "string",
"c_comment": "string",
},
),
tpch_nation.n_nationkey
== ibis.table(
name="tpch_customer",
name="tpch_nation",
schema={
"c_custkey": "int64",
"c_name": "string",
"c_address": "string",
"c_nationkey": "int16",
"c_phone": "string",
"c_acctbal": "decimal",
"c_mktsegment": "string",
"c_comment": "string",
"n_nationkey": "int16",
"n_name": "string",
"n_regionkey": "int16",
"n_comment": "string",
},
).c_nationkey,
)
.inner_join(
ibis.table(
name="tpch_region",
schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"},
),
ibis.table(
name="tpch_nation",
schema={
"n_nationkey": "int16",
"n_name": "string",
"n_regionkey": "int16",
"n_comment": "string",
},
).n_regionkey
== ibis.table(
name="tpch_region",
schema={"r_regionkey": "int16", "r_name": "string", "r_comment": "string"},
).r_regionkey,
)
.inner_join(
ibis.table(
name="tpch_customer",
schema={
"c_custkey": "int64",
"c_name": "string",
"c_address": "string",
"c_nationkey": "int16",
"c_phone": "string",
"c_acctbal": "decimal",
"c_mktsegment": "string",
"c_comment": "string",
},
),
ibis.table(
name="tpch_nation",
schema={
"n_nationkey": "int16",
"n_name": "string",
"n_regionkey": "int16",
"n_comment": "string",
},
).n_nationkey
== ibis.table(
name="tpch_customer",
schema={
"c_custkey": "int64",
"c_name": "string",
"c_address": "string",
"c_nationkey": "int16",
"c_phone": "string",
"c_acctbal": "decimal",
"c_mktsegment": "string",
"c_comment": "string",
},
).c_nationkey,
)
)
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
SELECT
t0.n_nationkey AS n_nationkey,
t0.n_name AS n_name,
t0.n_regionkey AS n_regionkey,
t0.n_comment AS n_comment,
t3.r_regionkey AS r_regionkey,
t3.r_name AS r_name,
t3.r_comment AS r_comment,
t4.c_custkey AS c_custkey,
t4.c_name AS c_name,
t4.c_address AS c_address,
t4.c_nationkey AS c_nationkey,
t4.c_phone AS c_phone,
t4.c_acctbal AS c_acctbal,
t4.c_mktsegment AS c_mktsegment,
t4.c_comment AS c_comment
FROM tpch_nation AS t0
INNER JOIN tpch_region AS t3
ON t0.n_regionkey = t3.r_regionkey
INNER JOIN tpch_customer AS t4
ON t0.n_nationkey = t4.c_nationkey
t3.n_nationkey AS n_nationkey,
t3.n_name AS n_name,
t3.n_regionkey AS n_regionkey,
t3.n_comment AS n_comment,
t4.r_regionkey AS r_regionkey,
t4.r_name AS r_name,
t4.r_comment AS r_comment,
t5.c_custkey AS c_custkey,
t5.c_name AS c_name,
t5.c_address AS c_address,
t5.c_nationkey AS c_nationkey,
t5.c_phone AS c_phone,
t5.c_acctbal AS c_acctbal,
t5.c_mktsegment AS c_mktsegment,
t5.c_comment AS c_comment
FROM tpch_nation AS t3
INNER JOIN tpch_region AS t4
ON t3.n_regionkey = t4.r_regionkey
INNER JOIN tpch_customer AS t5
ON t3.n_nationkey = t5.c_nationkey
Loading

0 comments on commit 76f516a

Please sign in to comment.