diff --git a/presto-memory/src/test/java/io/prestosql/plugin/memory/TestMemorySelection.java b/presto-memory/src/test/java/io/prestosql/plugin/memory/TestMemorySelection.java index a17a3d277..f2ad0a6b4 100644 --- a/presto-memory/src/test/java/io/prestosql/plugin/memory/TestMemorySelection.java +++ b/presto-memory/src/test/java/io/prestosql/plugin/memory/TestMemorySelection.java @@ -530,62 +530,86 @@ public class TestMemorySelection } @Test - public void testPartitionedTableColumnTypes() + public void testPartitionedTableColumnTypeString() { // test string column type - assertQuerySucceeds("CREATE TABLE test_orders WITH(async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - Pair resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where clerk = 'Clerk#000000828'"); - MaterializedResult resultWithoutPartition = resultPairWithoutPartition.getSecond(); - assertQuerySucceeds("DROP TABLE test_orders"); + synchronized (this) { + assertQuerySucceeds("CREATE TABLE test_orders WITH(async_processing=false) AS SELECT * FROM tpch.tiny.orders"); + assertQuerySucceeds("CREATE TABLE test_orders2 WITH (partitioned_by=array['clerk'], async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - assertQuerySucceeds("CREATE TABLE test_orders2 WITH (partitioned_by=array['clerk'], async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - Pair resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where clerk = 'Clerk#000000828'"); - MaterializedResult resultWithPartition = resultPairWithPartition.getSecond(); - assertQuerySucceeds("DROP TABLE test_orders2"); + Pair resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where clerk = 'Clerk#000000828'"); + Pair resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where clerk = 'Clerk#000000828'"); - assertTrue(verifyEqualResults(resultWithoutPartition, resultWithPartition), "The results should be equal"); + MaterializedResult resultWithoutPartition = resultPairWithoutPartition.getSecond(); + MaterializedResult resultWithPartition = resultPairWithPartition.getSecond(); - // test bigint column type - assertQuerySucceeds("CREATE TABLE test_orders WITH(async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where orderkey=34085"); - resultWithoutPartition = resultPairWithoutPartition.getSecond(); - assertQuerySucceeds("DROP TABLE test_orders"); - - assertQuerySucceeds("CREATE TABLE test_orders2 WITH (partitioned_by=array['orderkey'], async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where orderkey=34085"); - resultWithPartition = resultPairWithPartition.getSecond(); - assertQuerySucceeds("DROP TABLE test_orders2"); - - assertTrue(verifyEqualResults(resultWithoutPartition, resultWithPartition), "The results should be equal"); - - // test decimal column type - assertQuerySucceeds("CREATE TABLE test_orders WITH(async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where totalprice < 100000"); - resultWithoutPartition = resultPairWithoutPartition.getSecond(); - assertQuerySucceeds("DROP TABLE test_orders"); - - assertQuerySucceeds("CREATE TABLE test_orders2 WITH (partitioned_by=array['totalprice'], async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where totalprice < 100000"); - resultWithPartition = resultPairWithPartition.getSecond(); - assertQuerySucceeds("DROP TABLE test_orders2"); - - assertTrue(verifyEqualResults(resultWithoutPartition, resultWithPartition), "The results should be equal"); - - // test date column type - assertQuerySucceeds("CREATE TABLE test_orders WITH(async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where orderdate=date'1993-06-11'"); - resultWithoutPartition = resultPairWithoutPartition.getSecond(); - assertQuerySucceeds("DROP TABLE test_orders"); - - assertQuerySucceeds("CREATE TABLE test_orders2 WITH (partitioned_by=array['orderdate'], async_processing=false) AS SELECT * FROM tpch.tiny.orders"); - resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where orderdate=date'1993-06-11'"); - resultWithPartition = resultPairWithPartition.getSecond(); - assertQuerySucceeds("DROP TABLE test_orders2"); - - assertTrue(verifyEqualResults(resultWithoutPartition, resultWithPartition), "The results should be equal"); + assertTrue(verifyEqualResults(resultWithoutPartition, resultWithPartition), "The results should be equal"); + assertQuerySucceeds("DROP TABLE test_orders"); + assertQuerySucceeds("DROP TABLE test_orders2"); + } } - Pair getSplitAndMaterializedResult(String testerQuery) + @Test + public void testPartitionedTableColumnTypeInt() + { + // test bigint column type + synchronized (this) { + assertQuerySucceeds("CREATE TABLE test_orders WITH(async_processing=false) AS SELECT * FROM tpch.tiny.orders"); + assertQuerySucceeds("CREATE TABLE test_orders2 WITH (partitioned_by=array['orderkey'], async_processing=false) AS SELECT * FROM tpch.tiny.orders"); + + Pair resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where orderkey=34085"); + Pair resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where orderkey=34085"); + + MaterializedResult resultWithoutPartition = resultPairWithoutPartition.getSecond(); + MaterializedResult resultWithPartition = resultPairWithPartition.getSecond(); + + assertTrue(verifyEqualResults(resultWithoutPartition, resultWithPartition), "The results should be equal"); + assertQuerySucceeds("DROP TABLE test_orders"); + assertQuerySucceeds("DROP TABLE test_orders2"); + } + } + + @Test + public void testPartitionedTableColumnTypeDouble() + { + // test decimal column type + synchronized (this) { + assertQuerySucceeds("CREATE TABLE test_orders WITH(async_processing=false) AS SELECT * FROM tpch.tiny.orders"); + assertQuerySucceeds("CREATE TABLE test_orders2 WITH (partitioned_by=array['totalprice'], async_processing=false) AS SELECT * FROM tpch.tiny.orders"); + + Pair resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where totalprice < 1000"); + Pair resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where totalprice < 1000"); + + MaterializedResult resultWithoutPartition = resultPairWithoutPartition.getSecond(); + MaterializedResult resultWithPartition = resultPairWithPartition.getSecond(); + + assertTrue(verifyEqualResults(resultWithoutPartition, resultWithPartition), "The results should be equal"); + assertQuerySucceeds("DROP TABLE test_orders"); + assertQuerySucceeds("DROP TABLE test_orders2"); + } + } + + @Test + public void testPartitionedTableColumnTypeDate() + { + // test date column type + synchronized (this) { + assertQuerySucceeds("CREATE TABLE test_orders WITH(async_processing=false) AS SELECT * FROM tpch.tiny.orders"); + assertQuerySucceeds("CREATE TABLE test_orders2 WITH (partitioned_by=array['orderdate'], async_processing=false) AS SELECT * FROM tpch.tiny.orders"); + + Pair resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where orderdate=date'1993-06-11'"); + Pair resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where orderdate=date'1993-06-11'"); + + MaterializedResult resultWithoutPartition = resultPairWithoutPartition.getSecond(); + MaterializedResult resultWithPartition = resultPairWithPartition.getSecond(); + + assertTrue(verifyEqualResults(resultWithoutPartition, resultWithPartition), "The results should be equal"); + assertQuerySucceeds("DROP TABLE test_orders"); + assertQuerySucceeds("DROP TABLE test_orders2"); + } + } + + synchronized Pair getSplitAndMaterializedResult(String testerQuery) { // Select the entry with specifics MaterializedResult queryResult = computeActual(testerQuery);