@Test public void testTableSampleSystem() { int total = computeActual("SELECT orderkey FROM orders").getMaterializedRows().size(); boolean sampleSizeFound = false; for (int i = 0; i < 100; i++) { int sampleSize = computeActual("SELECT orderkey FROM ORDERS TABLESAMPLE SYSTEM (50)").getMaterializedRows().size(); if (sampleSize > 0 && sampleSize < total) { sampleSizeFound = true; break; } } assertTrue(sampleSizeFound, "Table sample returned unexpected number of rows"); } }
@Test public void testTooManyStages() { @Language("SQL") String query = "WITH\n" + " t1 AS (SELECT nationkey AS x FROM nation where name='UNITED STATES'),\n" + " t2 AS (SELECT a.x+b.x+c.x+d.x AS x FROM t1 a, t1 b, t1 c, t1 d),\n" + " t3 AS (SELECT a.x+b.x+c.x+d.x AS x FROM t2 a, t2 b, t2 c, t2 d),\n" + " t4 AS (SELECT a.x+b.x+c.x+d.x AS x FROM t3 a, t3 b, t3 c, t3 d),\n" + " t5 AS (SELECT a.x+b.x+c.x+d.x AS x FROM t4 a, t4 b, t4 c, t4 d)\n" + "SELECT x FROM t5\n"; assertQueryFails(query, "Number of stages in the query \\([0-9]+\\) exceeds the allowed maximum \\([0-9]+\\).*"); }
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "EXPLAIN ANALYZE not yet implemented") public void testExplainAnalyzeDDL() { computeActual("EXPLAIN ANALYZE DROP TABLE orders"); } }
@Test public void testTooManyStages() { @Language("SQL") String query = "WITH\n" + " t1 AS (SELECT nationkey AS x FROM nation where name='UNITED STATES'),\n" + " t2 AS (SELECT a.x+b.x+c.x+d.x AS x FROM t1 a, t1 b, t1 c, t1 d),\n" + " t3 AS (SELECT a.x+b.x+c.x+d.x AS x FROM t2 a, t2 b, t2 c, t2 d),\n" + " t4 AS (SELECT a.x+b.x+c.x+d.x AS x FROM t3 a, t3 b, t3 c, t3 d),\n" + " t5 AS (SELECT a.x+b.x+c.x+d.x AS x FROM t4 a, t4 b, t4 c, t4 d)\n" + "SELECT x FROM t5\n"; assertQueryFails(query, "Number of stages in the query \\([0-9]+\\) exceeds the allowed maximum \\([0-9]+\\).*"); }
@Test(expectedExceptions = RuntimeException.class, expectedExceptionsMessageRegExp = "EXPLAIN ANALYZE not yet implemented") public void testExplainAnalyze() { computeActual("EXPLAIN ANALYZE SELECT * FROM orders"); }
@Test public void testTableSampleSystem() { int total = computeActual("SELECT orderkey FROM orders").getMaterializedRows().size(); boolean sampleSizeFound = false; for (int i = 0; i < 100; i++) { int sampleSize = computeActual("SELECT orderkey FROM ORDERS TABLESAMPLE SYSTEM (50)").getMaterializedRows().size(); if (sampleSize > 0 && sampleSize < total) { sampleSizeFound = true; break; } } assertTrue(sampleSizeFound, "Table sample returned unexpected number of rows"); } }