Pre Merge pull request !1319 from peiwangdb/fix-I4GQ74

This commit is contained in:
peiwangdb 2022-06-23 06:58:41 +00:00 committed by Gitee
commit e0d20ae900
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 73 additions and 49 deletions

View File

@ -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<Integer, MaterializedResult> 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<Integer, MaterializedResult> resultPairWithPartition = getSplitAndMaterializedResult("select * from test_orders2 where clerk = 'Clerk#000000828'");
MaterializedResult resultWithPartition = resultPairWithPartition.getSecond();
assertQuerySucceeds("DROP TABLE test_orders2");
Pair<Integer, MaterializedResult> resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where clerk = 'Clerk#000000828'");
Pair<Integer, MaterializedResult> 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<Integer, MaterializedResult> 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<Integer, MaterializedResult> resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where orderkey=34085");
Pair<Integer, MaterializedResult> 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<Integer, MaterializedResult> resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where totalprice < 1000");
Pair<Integer, MaterializedResult> 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<Integer, MaterializedResult> resultPairWithoutPartition = getSplitAndMaterializedResult("select * from test_orders where orderdate=date'1993-06-11'");
Pair<Integer, MaterializedResult> 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<Integer, MaterializedResult> getSplitAndMaterializedResult(String testerQuery)
{
// Select the entry with specifics
MaterializedResult queryResult = computeActual(testerQuery);