Skip to content

Commit 7b5096b

Browse files
pdabre12Pratik Joseph Dabre
authored andcommitted
Add more test cases for mixed connectors
1 parent ca894f3 commit 7b5096b

File tree

1 file changed

+134
-29
lines changed

1 file changed

+134
-29
lines changed

presto-flight-shim/src/test/java/com/facebook/presto/flightshim/TestArrowFederationNativeQueriesMixedConnectors.java

Lines changed: 134 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,9 @@ public void testBasicSanityTests()
136136
assertQuery("select * from mysql.tpch.customer");
137137
assertQuery("select * from postgresql.tpch.orders");
138138
assertQuery("select orderkey, custkey from postgresql.tpch.orders");
139-
assertQuery("select extendedprice, discount from mysql.tpch.lineitem");
139+
assertQuery("select extendedprice * quantity from postgresql.tpch.lineitem");
140140
assertQuery("select name from mysql.tpch.part where name like '%steel%'");
141+
assertQuery("select name from mysql.tpch.part where LENGTH(name) > 10");
141142
}
142143

143144
@Test
@@ -146,8 +147,7 @@ public void testJoins()
146147
assertQuery("SELECT c.custkey, o.orderkey " +
147148
"FROM mysql.tpch.customer c " +
148149
"JOIN postgresql.tpch.orders o ON c.custkey = o.custkey " +
149-
"ORDER BY c.custkey, o.orderkey " +
150-
"LIMIT 100");
150+
"WHERE c.custkey BETWEEN 100 AND 200");
151151
assertQuery("SELECT p.partkey, ps.suppkey " +
152152
"FROM postgresql.tpch.part p " +
153153
"JOIN mysql.tpch.partsupp ps ON p.partkey = ps.partkey " +
@@ -156,42 +156,147 @@ public void testJoins()
156156
"LIMIT 100");
157157
assertQuery(
158158
"SELECT c.custkey, n.regionkey, o.orderkey, l.quantity " +
159-
"FROM mysql.tpch.customer c " +
160-
"JOIN postgresql.tpch.orders o ON c.custkey = o.custkey " +
161-
"JOIN mysql.tpch.nation n ON c.nationkey = n.nationkey " +
162-
"JOIN postgresql.tpch.lineitem l ON o.orderkey = l.orderkey");
159+
"FROM mysql.tpch.customer c " +
160+
"JOIN postgresql.tpch.orders o ON c.custkey = o.custkey " +
161+
"JOIN mysql.tpch.nation n ON c.nationkey = n.nationkey " +
162+
"JOIN postgresql.tpch.lineitem l ON o.orderkey = l.orderkey");
163+
assertQuery(
164+
"SELECT c.custkey " +
165+
"FROM mysql.tpch.customer c " +
166+
"WHERE NOT EXISTS ( " +
167+
" SELECT 1 " +
168+
" FROM postgresql.tpch.orders o " +
169+
" WHERE o.custkey = c.custkey)");
170+
assertQuery(
171+
"SELECT DISTINCT c.custkey " +
172+
"FROM mysql.tpch.customer c " +
173+
"WHERE c.custkey IN ( " +
174+
" SELECT custkey " +
175+
" FROM postgresql.tpch.orders o)");
176+
177+
// wide JOIN
178+
assertQuery("SELECT * " +
179+
"FROM mysql.tpch.lineitem l " +
180+
"JOIN postgresql.tpch.orders o ON l.orderkey = o.orderkey " +
181+
"ORDER BY l.orderkey, o.orderkey");
163182
}
164-
183+
165184
@Test
166185
public void testLargeQueries()
167186
{
168187
// tpch q3
169188
assertQuery(
170189
"SELECT l.orderkey, sum(l.extendedprice * (1 - l.discount)) as revenue, o.orderdate, o.shippriority " +
171-
"FROM " +
172-
"mysql.tpch.customer as c," +
173-
"postgresql.tpch.orders as o," +
174-
"mysql.tpch.lineitem as l " +
175-
"WHERE " +
176-
"c.mktsegment = 'BUILDING' " +
177-
"AND c.custkey = o.custkey " +
178-
"AND l.orderkey = o.orderkey " +
179-
"AND o.orderdate < DATE '1995-03-15' " +
180-
"AND l.shipdate > DATE '1995-03-15' " +
181-
"GROUP BY l.orderkey,o.orderdate, o.shippriority " +
182-
"ORDER BY revenue desc, o.orderdate " +
183-
"LIMIT 10");
190+
"FROM " +
191+
"mysql.tpch.customer as c," +
192+
"postgresql.tpch.orders as o," +
193+
"mysql.tpch.lineitem as l " +
194+
"WHERE " +
195+
"c.mktsegment = 'BUILDING' " +
196+
"AND c.custkey = o.custkey " +
197+
"AND l.orderkey = o.orderkey " +
198+
"AND o.orderdate < DATE '1995-03-15' " +
199+
"AND l.shipdate > DATE '1995-03-15' " +
200+
"GROUP BY l.orderkey,o.orderdate, o.shippriority " +
201+
"ORDER BY revenue desc, o.orderdate " +
202+
"LIMIT 10");
184203

185204
assertQuery(
186205
"SELECT n.name, sum(l.extendedprice * (1 - l.discount)) as revenue " +
187-
"FROM mysql.tpch.customer c " +
188-
"JOIN mysql.tpch.orders o ON c.custkey = o.custkey " +
189-
"JOIN postgresql.tpch.lineitem l ON o.orderkey = l.orderkey " +
190-
"JOIN postgresql.tpch.supplier s ON l.suppkey = s.suppkey " +
191-
"JOIN mysql.tpch.nation n ON c.nationkey = n.nationkey " +
192-
"GROUP BY 1 " +
193-
"ORDER BY revenue DESC " +
194-
"LIMIT 20");
206+
"FROM mysql.tpch.customer c " +
207+
"JOIN mysql.tpch.orders o ON c.custkey = o.custkey " +
208+
"JOIN postgresql.tpch.lineitem l ON o.orderkey = l.orderkey " +
209+
"JOIN postgresql.tpch.supplier s ON l.suppkey = s.suppkey " +
210+
"JOIN mysql.tpch.nation n ON c.nationkey = n.nationkey " +
211+
"GROUP BY 1 " +
212+
"ORDER BY revenue DESC " +
213+
"LIMIT 20");
214+
}
215+
216+
@Test
217+
public void testGroupByHaving()
218+
{
219+
assertQuery(
220+
"SELECT o.custkey, COUNT(*) AS cnt " +
221+
"FROM postgresql.tpch.orders o " +
222+
"JOIN mysql.tpch.lineitem l ON o.orderkey = l.orderkey " +
223+
"GROUP BY o.custkey " +
224+
"HAVING COUNT(*) > 10 " +
225+
"ORDER BY cnt DESC");
226+
}
227+
228+
@Test
229+
public void testMultiAggregation()
230+
{
231+
assertQuery(
232+
"SELECT c.nationkey, COUNT(*) as orders, SUM(l.quantity) as qty, AVG(l.discount) as avg " +
233+
"FROM mysql.tpch.customer c " +
234+
"JOIN postgresql.tpch.orders o ON c.custkey = o.custkey " +
235+
"JOIN mysql.tpch.lineitem l ON o.orderkey = l.orderkey " +
236+
"GROUP BY 1");
237+
}
238+
239+
@Test
240+
public void testWindowFunctions()
241+
{
242+
assertQuery(
243+
"SELECT o.orderkey, c.custkey, " +
244+
"RANK() OVER (PARTITION BY c.custkey ORDER BY o.totalprice DESC) AS rnk " +
245+
"FROM mysql.tpch.customer c " +
246+
"JOIN postgresql.tpch.orders o ON c.custkey = o.custkey " +
247+
"ORDER BY o.orderkey, c.custkey " +
248+
"LIMIT 100");
249+
assertQuery(
250+
"SELECT c.nationkey, l.orderkey, " +
251+
"SUM(l.quantity) OVER (PARTITION BY c.nationkey ORDER BY l.orderkey) AS qty " +
252+
"FROM mysql.tpch.customer c " +
253+
"JOIN postgresql.tpch.orders o ON c.custkey = o.custkey " +
254+
"JOIN mysql.tpch.lineitem l ON o.orderkey = l.orderkey");
255+
assertQuery("SELECT l.orderkey, l.quantity, " +
256+
"DENSE_RANK() OVER (ORDER BY l.quantity DESC) AS dr " +
257+
"FROM postgresql.tpch.lineitem l");
258+
}
259+
260+
@Test
261+
public void testNullCases()
262+
{
263+
assertQuery(
264+
"SELECT * FROM mysql.tpch.part p " +
265+
"LEFT JOIN postgresql.tpch.partsupp s ON p.partkey = s.partkey " +
266+
"WHERE s.suppkey is NULL");
267+
assertQuery(
268+
"SELECT COALESCE(c.name, 'UNKNOWN') AS customer_name, o.orderkey " +
269+
"FROM mysql.tpch.customer c " +
270+
"JOIN postgresql.tpch.orders o ON c.custkey = o.custkey " +
271+
"ORDER BY o.orderkey, customer_name");
272+
}
273+
274+
@Test
275+
public void testSetOperators()
276+
{
277+
assertQuery(
278+
"SELECT nationkey FROM mysql.tpch.nation " +
279+
"UNION ALL " +
280+
"SELECT nationkey FROM postgresql.tpch.nation");
281+
assertQuery(
282+
"SELECT orderkey FROM mysql.tpch.orders " +
283+
"INTERSECT " +
284+
"SELECT orderkey FROM postgresql.tpch.orders");
285+
assertQuery(
286+
"SELECT custkey FROM mysql.tpch.customer " +
287+
"EXCEPT " +
288+
"SELECT custkey FROM postgresql.tpch.customer");
289+
}
290+
291+
@Test(timeOut = 30_000)
292+
public void testRepeatedJoins()
293+
{
294+
for (int i = 0; i < 20; i++) {
295+
assertQuery(
296+
"SELECT COUNT(*) " +
297+
"FROM mysql.tpch.lineitem l " +
298+
"JOIN postgresql.tpch.orders o ON l.orderkey = o.orderkey");
299+
}
195300
}
196301

197302
private static void installPlugins(QueryRunner queryRunner, String postgresJdbcUrl, String mySqlJdbcUrl)

0 commit comments

Comments
 (0)