Skip to content

Commit 73bbcf8

Browse files
theoryserprex
authored andcommitted
Execute the fully-pushed down query
Demonstrate that it fails due to improper table aliasing.
1 parent f8cbe6b commit 73bbcf8

3 files changed

Lines changed: 40 additions & 4 deletions

File tree

test/expected/subquery_eq.out

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ CREATE SCHEMA sub_eq_test;
194194
IMPORT FOREIGN SCHEMA sub_eq_test FROM SERVER sub_eq_svr INTO sub_eq_test;
195195
SET SESSION search_path = sub_eq_test,public;
196196
-- Execute query 2.
197-
EXPLAIN (VERBOSE, COSTS OFF)
197+
SELECT $$
198198
select
199199
s_acctbal,
200200
s_name,
@@ -239,6 +239,8 @@ order by
239239
s_name,
240240
p_partkey
241241
LIMIT 100;
242+
$$ AS query2 \gset
243+
EXPLAIN (VERBOSE, COSTS OFF) :query2
242244
QUERY PLAN
243245
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
244246
Foreign Scan
@@ -247,6 +249,20 @@ LIMIT 100;
247249
Remote SQL: SELECT r2.s_acctbal, r2.s_name, r4.n_name, r1.p_partkey, r1.p_mfgr, r2.s_address, r2.s_phone, r2.s_comment FROM sub_eq_test.part r1 ALL INNER JOIN sub_eq_test.partsupp r3 ON (((r1.p_partkey = r3.ps_partkey))) ALL INNER JOIN sub_eq_test.supplier r2 ON (((r2.s_suppkey = r3.ps_suppkey))) ALL INNER JOIN sub_eq_test.nation r4 ON (((r2.s_nationkey = r4.n_nationkey))) ALL INNER JOIN sub_eq_test.region r5 ON (((r4.n_regionkey = r5.r_regionkey))) WHERE ((r5.r_name = 'EUROPE')) AND (((SELECT min(r1.ps_supplycost) FROM sub_eq_test.partsupp r1, sub_eq_test.supplier r2, sub_eq_test.nation r3, sub_eq_test.region r4 WHERE ((r1.p_partkey = r1.ps_partkey) AND (r2.s_suppkey = r1.ps_suppkey) AND (r2.s_nationkey = r3.n_nationkey) AND (r3.n_regionkey = r4.r_regionkey) AND (r4.r_name = 'EUROPE'))) = r3.ps_supplycost)) AND ((r1.p_type LIKE '%BRASS')) AND ((r1.p_size = 15)) ORDER BY r2.s_acctbal DESC NULLS FIRST, r4.n_name ASC NULLS LAST, r2.s_name ASC NULLS LAST, r1.p_partkey ASC NULLS LAST LIMIT 100
248250
(4 rows)
249251

252+
:query2
253+
:query2
254+
s_acctbal | s_name | n_name | p_partkey | p_mfgr | s_address | s_phone | s_comment
255+
-----------+--------------------+---------+-----------+----------------+------------------------------------------+-----------------+----------------------------------------------------------------------------------------
256+
686.50 | Supplier#000001731 | GERMANY | 109220 | Manufacturer#4 | Dqy8LQtY5i8GygrdOC1lt,OVsIgrGoL8Z3PMs | 17-115-638-8685 | lar requests. final, final platelets around the carefully even deposit
257+
686.50 | Supplier#000001731 | GERMANY | 186694 | Manufacturer#4 | Dqy8LQtY5i8GygrdOC1lt,OVsIgrGoL8Z3PMs | 17-115-638-8685 | lar requests. final, final platelets around the carefully even deposit
258+
555.18 | Supplier#000002931 | GERMANY | 20428 | Manufacturer#4 | aUivhoesqMqv0FmJcPBMxBSl8DJvXBGj | 17-905-318-3455 | t the fluffily ironic packages wake furiously
259+
60.50 | Supplier#000003497 | GERMANY | 170979 | Manufacturer#4 | k,,DNvZ8XHvkepAky ,22QHj4MAoxhd | 17-762-516-4410 | s breach accounts. express dolphins along the quickly ironic deposits hinder furiously
260+
-63.88 | Supplier#000003937 | GERMANY | 73936 | Manufacturer#4 | kqEOwdVW,qJsJdcv6PwDJ6ii14mugDK3OgZN ngI | 17-621-453-7063 | y pending asymptotes. foxes are. deposits sleep quickly b
261+
-271.69 | Supplier#000009733 | GERMANY | 89732 | Manufacturer#4 | XIkUGlZFKq4IiZsAIRxFwzVBw7D | 17-789-292-3060 | ions. boldly regular requests play furiously. furiously busy
262+
-604.88 | Supplier#000003113 | GERMANY | 105582 | Manufacturer#4 | HjX8M2Bjlz7pAcLzpyKT9 wNb | 17-164-471-2650 | he ruthlessly final requests. express requests cajole quick
263+
-752.27 | Supplier#000005299 | GERMANY | 70284 | Manufacturer#4 | m7Y2G8Pg,kl5AoMPK | 17-904-495-9057 | . carefully close foxes x-ray. carefully even package
264+
(8 rows)
265+
250266
-- Cleanup
251267
SELECT clickhouse_raw_query('DROP DATABASE sub_eq_test');
252268
clickhouse_raw_query

test/expected/subquery_eq_1.out

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ CREATE SCHEMA sub_eq_test;
194194
IMPORT FOREIGN SCHEMA sub_eq_test FROM SERVER sub_eq_svr INTO sub_eq_test;
195195
SET SESSION search_path = sub_eq_test,public;
196196
-- Execute query 2.
197-
EXPLAIN (VERBOSE, COSTS OFF)
197+
SELECT $$
198198
select
199199
s_acctbal,
200200
s_name,
@@ -239,14 +239,30 @@ order by
239239
s_name,
240240
p_partkey
241241
LIMIT 100;
242+
$$ AS query2 \gset
243+
EXPLAIN (VERBOSE, COSTS OFF) :query2
242244
QUERY PLAN
243245
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
244246
Foreign Scan
245247
Output: supplier.s_acctbal, supplier.s_name, nation.n_name, part.p_partkey, part.p_mfgr, supplier.s_address, supplier.s_phone, supplier.s_comment
246248
Relations: ((((part) INNER JOIN (partsupp)) INNER JOIN (supplier)) INNER JOIN (nation)) INNER JOIN (region)
247-
Remote SQL: SELECT r2.s_acctbal, r2.s_name, r4.n_name, r1.p_partkey, r1.p_mfgr, r2.s_address, r2.s_phone, r2.s_comment FROM sub_eq_test.part r1 ALL INNER JOIN sub_eq_test.partsupp r3 ON (((r1.p_partkey = r3.ps_partkey))) ALL INNER JOIN sub_eq_test.supplier r2 ON (((r3.ps_suppkey = r2.s_suppkey))) ALL INNER JOIN sub_eq_test.nation r4 ON (((r2.s_nationkey = r4.n_nationkey))) ALL INNER JOIN sub_eq_test.region r5 ON (((r4.n_regionkey = r5.r_regionkey))) WHERE ((r5.r_name = 'EUROPE')) AND (((SELECT min(r1.ps_supplycost) FROM sub_eq_test.partsupp r1, sub_eq_test.supplier r2, sub_eq_test.nation r3, sub_eq_test.region r4 WHERE ((r1.p_partkey = r1.ps_partkey) AND (r2.s_suppkey = r1.ps_suppkey) AND (r2.s_nationkey = r3.n_nationkey) AND (r3.n_regionkey = r4.r_regionkey) AND (r4.r_name = 'EUROPE'))) = r3.ps_supplycost)) AND ((r1.p_type LIKE '%BRASS')) AND ((r1.p_size = 15)) ORDER BY r2.s_acctbal DESC NULLS FIRST, r4.n_name ASC NULLS LAST, r2.s_name ASC NULLS LAST, r1.p_partkey ASC NULLS LAST LIMIT 100
249+
Remote SQL: SELECT r2.s_acctbal, r2.s_name, r4.n_name, r1.p_partkey, r1.p_mfgr, r2.s_address, r2.s_phone, r2.s_comment FROM sub_eq_test.part r1 ALL INNER JOIN sub_eq_test.partsupp r3 ON (((r1.p_partkey = r3.ps_partkey))) ALL INNER JOIN sub_eq_test.supplier r2 ON (((r2.s_suppkey = r3.ps_suppkey))) ALL INNER JOIN sub_eq_test.nation r4 ON (((r2.s_nationkey = r4.n_nationkey))) ALL INNER JOIN sub_eq_test.region r5 ON (((r4.n_regionkey = r5.r_regionkey))) WHERE ((r5.r_name = 'EUROPE')) AND (((SELECT min(r1.ps_supplycost) FROM sub_eq_test.partsupp r1, sub_eq_test.supplier r2, sub_eq_test.nation r3, sub_eq_test.region r4 WHERE ((r1.p_partkey = r1.ps_partkey) AND (r2.s_suppkey = r1.ps_suppkey) AND (r2.s_nationkey = r3.n_nationkey) AND (r3.n_regionkey = r4.r_regionkey) AND (r4.r_name = 'EUROPE'))) = r3.ps_supplycost)) AND ((r1.p_type LIKE '%BRASS')) AND ((r1.p_size = 15)) ORDER BY r2.s_acctbal DESC NULLS FIRST, r4.n_name ASC NULLS LAST, r2.s_name ASC NULLS LAST, r1.p_partkey ASC NULLS LAST LIMIT 100
248250
(4 rows)
249251

252+
:query2
253+
:query2
254+
s_acctbal | s_name | n_name | p_partkey | p_mfgr | s_address | s_phone | s_comment
255+
-----------+--------------------+---------+-----------+----------------+------------------------------------------+-----------------+----------------------------------------------------------------------------------------
256+
686.50 | Supplier#000001731 | GERMANY | 109220 | Manufacturer#4 | Dqy8LQtY5i8GygrdOC1lt,OVsIgrGoL8Z3PMs | 17-115-638-8685 | lar requests. final, final platelets around the carefully even deposit
257+
686.50 | Supplier#000001731 | GERMANY | 186694 | Manufacturer#4 | Dqy8LQtY5i8GygrdOC1lt,OVsIgrGoL8Z3PMs | 17-115-638-8685 | lar requests. final, final platelets around the carefully even deposit
258+
555.18 | Supplier#000002931 | GERMANY | 20428 | Manufacturer#4 | aUivhoesqMqv0FmJcPBMxBSl8DJvXBGj | 17-905-318-3455 | t the fluffily ironic packages wake furiously
259+
60.50 | Supplier#000003497 | GERMANY | 170979 | Manufacturer#4 | k,,DNvZ8XHvkepAky ,22QHj4MAoxhd | 17-762-516-4410 | s breach accounts. express dolphins along the quickly ironic deposits hinder furiously
260+
-63.88 | Supplier#000003937 | GERMANY | 73936 | Manufacturer#4 | kqEOwdVW,qJsJdcv6PwDJ6ii14mugDK3OgZN ngI | 17-621-453-7063 | y pending asymptotes. foxes are. deposits sleep quickly b
261+
-271.69 | Supplier#000009733 | GERMANY | 89732 | Manufacturer#4 | XIkUGlZFKq4IiZsAIRxFwzVBw7D | 17-789-292-3060 | ions. boldly regular requests play furiously. furiously busy
262+
-604.88 | Supplier#000003113 | GERMANY | 105582 | Manufacturer#4 | HjX8M2Bjlz7pAcLzpyKT9 wNb | 17-164-471-2650 | he ruthlessly final requests. express requests cajole quick
263+
-752.27 | Supplier#000005299 | GERMANY | 70284 | Manufacturer#4 | m7Y2G8Pg,kl5AoMPK | 17-904-495-9057 | . carefully close foxes x-ray. carefully even package
264+
(8 rows)
265+
250266
-- Cleanup
251267
SELECT clickhouse_raw_query('DROP DATABASE sub_eq_test');
252268
clickhouse_raw_query

test/sql/subquery_eq.sql

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,9 @@ CREATE SCHEMA sub_eq_test;
146146
IMPORT FOREIGN SCHEMA sub_eq_test FROM SERVER sub_eq_svr INTO sub_eq_test;
147147
SET SESSION search_path = sub_eq_test,public;
148148

149+
149150
-- Execute query 2.
150-
EXPLAIN (VERBOSE, COSTS OFF)
151+
SELECT $$
151152
select
152153
s_acctbal,
153154
s_name,
@@ -192,7 +193,10 @@ order by
192193
s_name,
193194
p_partkey
194195
LIMIT 100;
196+
$$ AS query2 \gset
195197

198+
EXPLAIN (VERBOSE, COSTS OFF) :query2
199+
:query2
196200

197201
-- Cleanup
198202
SELECT clickhouse_raw_query('DROP DATABASE sub_eq_test');

0 commit comments

Comments
 (0)