http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/test/java/org/apache/tajo/engine/function/TestBuiltinFunctions.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/function/TestBuiltinFunctions.java b/tajo-core/src/test/java/org/apache/tajo/engine/function/TestBuiltinFunctions.java index 6bec3ad..5dae452 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/function/TestBuiltinFunctions.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/function/TestBuiltinFunctions.java @@ -57,10 +57,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("id", TajoDataTypes.Type.INT4); schema.addColumn("value", TajoDataTypes.Type.INT8); String[] data = new String[]{ "1|-111", "2|\\N", "3|-333" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select max(value) as max_value from table11"); + ResultSet res = executeString("select max(value) as max_value from testbuiltin11"); String ascExpected = "max_value\n" + "-------------------------------\n" + "-111\n"; @@ -68,7 +68,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -82,10 +82,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { Schema schema = new Schema(); schema.addColumn("value", TajoDataTypes.Type.DATE); String[] data = new String[]{ "2014-01-02", "2014-12-01", "2015-01-01", "1999-08-09", "2000-03-01" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from table11"); + ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from testbuiltin11"); String ascExpected = "min_value,max_value\n" + "-------------------------------\n" + "1999-08-09,2015-01-01\n"; @@ -93,7 +93,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -106,10 +106,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { Schema schema = new Schema(); schema.addColumn("value", TajoDataTypes.Type.DATE); String[] data = new String[]{ "2014-01-02", "2014-12-01", "\\N", "\\N", "2000-03-01" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from table11"); + ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from testbuiltin11"); String ascExpected = "min_value,max_value\n" + "-------------------------------\n" + "2000-03-01,2014-12-01\n"; @@ -117,7 +117,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -130,10 +130,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { Schema schema = new Schema(); schema.addColumn("value", TajoDataTypes.Type.TIME); String[] data = new String[]{ "11:11:11", "23:12:50", "00:00:01", "09:59:59", "12:13:14" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from table11"); + ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from testbuiltin11"); String ascExpected = "min_value,max_value\n" + "-------------------------------\n" + "00:00:01,23:12:50\n"; @@ -141,7 +141,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -154,10 +154,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { Schema schema = new Schema(); schema.addColumn("value", TajoDataTypes.Type.TIME); String[] data = new String[]{ "11:11:11", "\\N", "\\N", "09:59:59", "12:13:14" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from table11"); + ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from testbuiltin11"); String ascExpected = "min_value,max_value\n" + "-------------------------------\n" + "09:59:59,12:13:14\n"; @@ -165,7 +165,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -179,10 +179,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("value", TajoDataTypes.Type.TIMESTAMP); String[] data = new String[]{ "1999-01-01 11:11:11", "2015-01-01 23:12:50", "2016-12-24 00:00:01", "1977-05-04 09:59:59", "2002-11-21 12:13:14" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from table11"); + ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from testbuiltin11"); String ascExpected = "min_value,max_value\n" + "-------------------------------\n" + "1977-05-04 09:59:59,2016-12-24 00:00:01\n"; @@ -190,7 +190,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -204,10 +204,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("value", TajoDataTypes.Type.TIMESTAMP); String[] data = new String[]{ "1999-01-01 11:11:11", "2015-01-01 23:12:50", "\\N", "\\N", "2002-11-21 12:13:14" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from table11"); + ResultSet res = executeString("select min(value) as min_value, max(value) as max_value from testbuiltin11"); String ascExpected = "min_value,max_value\n" + "-------------------------------\n" + "1999-01-01 11:11:11,2015-01-01 23:12:50\n"; @@ -215,7 +215,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -236,10 +236,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("id", TajoDataTypes.Type.INT4); schema.addColumn("value", TajoDataTypes.Type.INT8); String[] data = new String[]{ "1|111", "2|\\N", "3|333" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select min(value) as min_value from table11"); + ResultSet res = executeString("select min(value) as min_value from testbuiltin11"); String ascExpected = "min_value\n" + "-------------------------------\n" + "111\n"; @@ -247,7 +247,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -269,10 +269,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("id", TajoDataTypes.Type.INT4); schema.addColumn("name", TajoDataTypes.Type.TEXT); String[] data = new String[]{ "1|\\N", "2|\\N", "3|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select max(name) as max_name from table11"); + ResultSet res = executeString("select max(name) as max_name from testbuiltin11"); String ascExpected = "max_name\n" + "-------------------------------\n" + "null\n"; @@ -280,7 +280,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -302,10 +302,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("id", TajoDataTypes.Type.INT4); schema.addColumn("name", TajoDataTypes.Type.TEXT); String[] data = new String[]{ "1|def", "2|\\N", "3|abc" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select min(name) as min_name from table11"); + ResultSet res = executeString("select min(name) as min_name from testbuiltin11"); String ascExpected = "min_name\n" + "-------------------------------\n" + "abc\n"; @@ -313,7 +313,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -366,10 +366,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("value_float", TajoDataTypes.Type.FLOAT4); schema.addColumn("value_double", TajoDataTypes.Type.FLOAT8); String[] data = new String[]{ "1|\\N|-111|1.2|-50.5", "2|1|\\N|\\N|52.5", "3|2|-333|2.8|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select avg(value_int) as avg_int, avg(value_long) as avg_long, avg(value_float) as avg_float, avg(value_double) as avg_double from table11"); + ResultSet res = executeString("select avg(value_int) as avg_int, avg(value_long) as avg_long, avg(value_float) as avg_float, avg(value_double) as avg_double from testbuiltin11"); String ascExpected = "avg_int,avg_long,avg_float,avg_double\n" + "-------------------------------\n" + "1.5,-222.0,2.0,1.0\n"; @@ -377,7 +377,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -395,10 +395,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("value_float", TajoDataTypes.Type.FLOAT4); schema.addColumn("value_double", TajoDataTypes.Type.FLOAT8); String[] data = new String[]{ "1|\\N|\\N|\\N|\\N", "2|\\N|\\N|\\N|\\N", "3|\\N|\\N|\\N|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select avg(value_int) as avg_int, avg(value_long) as avg_long, avg(value_float) as avg_float, avg(value_double) as avg_double from table11"); + ResultSet res = executeString("select avg(value_int) as avg_int, avg(value_long) as avg_long, avg(value_float) as avg_float, avg(value_double) as avg_double from testbuiltin11"); String ascExpected = "avg_int,avg_long,avg_float,avg_double\n" + "-------------------------------\n" + "null,null,null,null\n"; @@ -406,7 +406,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -424,10 +424,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("value_float", TajoDataTypes.Type.FLOAT4); schema.addColumn("value_double", TajoDataTypes.Type.FLOAT8); String[] data = new String[]{ "1|\\N|-111|1.2|-50.5", "2|1|\\N|\\N|52.5", "3|2|-333|2.8|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select sum(value_int) as sum_int, sum(value_long) as sum_long, sum(value_float) as sum_float, sum(value_double) as sum_double from table11"); + ResultSet res = executeString("select sum(value_int) as sum_int, sum(value_long) as sum_long, sum(value_float) as sum_float, sum(value_double) as sum_double from testbuiltin11"); String ascExpected = "sum_int,sum_long,sum_float,sum_double\n" + "-------------------------------\n" + "3,-444,4.0,2.0\n"; @@ -435,7 +435,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -453,10 +453,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { schema.addColumn("value_float", TajoDataTypes.Type.FLOAT4); schema.addColumn("value_double", TajoDataTypes.Type.FLOAT8); String[] data = new String[]{ "1|\\N|\\N|\\N|\\N", "2|\\N|\\N|\\N|\\N", "3|\\N|\\N|\\N|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select sum(value_int) as sum_int, sum(value_long) as sum_long, sum(value_float) as sum_float, sum(value_double) as sum_double from table11"); + ResultSet res = executeString("select sum(value_int) as sum_int, sum(value_long) as sum_long, sum(value_float) as sum_float, sum(value_double) as sum_double from testbuiltin11"); String ascExpected = "sum_int,sum_long,sum_float,sum_double\n" + "-------------------------------\n" + "null,null,null,null\n"; @@ -464,7 +464,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -485,10 +485,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { "1|\\N|-111|1.2|-50.5", "2|1|\\N|\\N|52.5", "3|2|-333|2.8|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select stddev_samp(value_int) as sdsamp_int, stddev_samp(value_long) as sdsamp_long, stddev_samp(value_float) as sdsamp_float, stddev_samp(value_double) as sdsamp_double from table11"); + ResultSet res = executeString("select stddev_samp(value_int) as sdsamp_int, stddev_samp(value_long) as sdsamp_long, stddev_samp(value_float) as sdsamp_float, stddev_samp(value_double) as sdsamp_double from testbuiltin11"); String ascExpected = "sdsamp_int,sdsamp_long,sdsamp_float,sdsamp_double\n" + "-------------------------------\n" + "0.7071067811865476,156.97770542341354,1.1313707824635184,72.8319984622144\n"; @@ -496,7 +496,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -517,10 +517,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { "1|\\N|\\N|\\N|-50.5", "2|1|\\N|\\N|\\N", "3|\\N|\\N|\\N|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select stddev_samp(value_int) as sdsamp_int, stddev_samp(value_long) as sdsamp_long, stddev_samp(value_float) as sdsamp_float, stddev_samp(value_double) as sdsamp_double from table11"); + ResultSet res = executeString("select stddev_samp(value_int) as sdsamp_int, stddev_samp(value_long) as sdsamp_long, stddev_samp(value_float) as sdsamp_float, stddev_samp(value_double) as sdsamp_double from testbuiltin11"); String ascExpected = "sdsamp_int,sdsamp_long,sdsamp_float,sdsamp_double\n" + "-------------------------------\n" + "null,null,null,null\n"; @@ -528,7 +528,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -549,10 +549,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { "1|\\N|-111|1.2|-50.5", "2|1|\\N|\\N|52.5", "3|2|-333|2.8|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select stddev_pop(value_int) as sdpop_int, stddev_pop(value_long) as sdpop_long, stddev_pop(value_float) as sdpop_float, stddev_pop(value_double) as sdpop_double from table11"); + ResultSet res = executeString("select stddev_pop(value_int) as sdpop_int, stddev_pop(value_long) as sdpop_long, stddev_pop(value_float) as sdpop_float, stddev_pop(value_double) as sdpop_double from testbuiltin11"); String ascExpected = "sdpop_int,sdpop_long,sdpop_float,sdpop_double\n" + "-------------------------------\n" + "0.5,111.0,0.7999999523162842,51.5\n"; @@ -560,7 +560,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -581,10 +581,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { "1|\\N|\\N|\\N|-50.5", "2|1|\\N|\\N|\\N", "3|\\N|\\N|\\N|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select stddev_pop(value_int) as sdpop_int, stddev_pop(value_long) as sdpop_long, stddev_pop(value_float) as sdpop_float, stddev_pop(value_double) as sdpop_double from table11"); + ResultSet res = executeString("select stddev_pop(value_int) as sdpop_int, stddev_pop(value_long) as sdpop_long, stddev_pop(value_float) as sdpop_float, stddev_pop(value_double) as sdpop_double from testbuiltin11"); String ascExpected = "sdpop_int,sdpop_long,sdpop_float,sdpop_double\n" + "-------------------------------\n" + "0.0,null,null,0.0\n"; @@ -592,7 +592,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -613,10 +613,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { "1|\\N|-111|1.2|-50.5", "2|1|\\N|\\N|52.5", "3|2|-333|2.8|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select var_samp(value_int) as vs_int, var_samp(value_long) as vs_long, var_samp(value_float) as vs_float, var_samp(value_double) as vs_double from table11"); + ResultSet res = executeString("select var_samp(value_int) as vs_int, var_samp(value_long) as vs_long, var_samp(value_float) as vs_float, var_samp(value_double) as vs_double from testbuiltin11"); String ascExpected = "vs_int,vs_long,vs_float,vs_double\n" + "-------------------------------\n" + "0.5,24642.0,1.279999847412114,5304.5\n"; @@ -624,7 +624,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -644,10 +644,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { "1|\\N|\\N|\\N|-50.5", "2|1|\\N|\\N|\\N", "3|\\N|\\N|\\N|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select var_samp(value_int) as vsamp_int, var_samp(value_long) as vsamp_long, var_samp(value_float) as vsamp_float, var_samp(value_double) as vsamp_double from table11"); + ResultSet res = executeString("select var_samp(value_int) as vsamp_int, var_samp(value_long) as vsamp_long, var_samp(value_float) as vsamp_float, var_samp(value_double) as vsamp_double from testbuiltin11"); String ascExpected = "vsamp_int,vsamp_long,vsamp_float,vsamp_double\n" + "-------------------------------\n" + "null,null,null,null\n"; @@ -655,7 +655,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -675,10 +675,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { "1|\\N|-111|1.2|-50.5", "2|1|\\N|\\N|52.5", "3|2|-333|2.8|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select var_pop(value_int) as vpop_int, var_pop(value_long) as vpop_long, var_pop(value_float) as vpop_float, var_pop(value_double) as vpop_double from table11"); + ResultSet res = executeString("select var_pop(value_int) as vpop_int, var_pop(value_long) as vpop_long, var_pop(value_float) as vpop_float, var_pop(value_double) as vpop_double from testbuiltin11"); String ascExpected = "vpop_int,vpop_long,vpop_float,vpop_double\n" + "-------------------------------\n" + "0.25,12321.0,0.639999923706057,2652.25\n"; @@ -686,7 +686,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } } @@ -706,10 +706,10 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { "1|\\N|\\N|\\N|-50.5", "2|1|\\N|\\N|\\N", "3|\\N|\\N|\\N|\\N" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data, 1); + TajoTestingCluster.createTable("testbuiltin11", schema, tableOptions, data, 1); try { - ResultSet res = executeString("select var_pop(value_int) as vpop_int, var_pop(value_long) as vpop_long, var_pop(value_float) as vpop_float, var_pop(value_double) as vpop_double from table11"); + ResultSet res = executeString("select var_pop(value_int) as vpop_int, var_pop(value_long) as vpop_long, var_pop(value_float) as vpop_float, var_pop(value_double) as vpop_double from testbuiltin11"); String ascExpected = "vpop_int,vpop_long,vpop_float,vpop_double\n" + "-------------------------------\n" + "0.0,null,null,0.0\n"; @@ -717,7 +717,7 @@ public class TestBuiltinFunctions extends QueryTestCaseBase { assertEquals(ascExpected, resultSetToString(res)); res.close(); } finally { - executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE testbuiltin11 PURGE"); } }
http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/test/java/org/apache/tajo/engine/planner/global/TestBroadcastJoinPlan.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/planner/global/TestBroadcastJoinPlan.java b/tajo-core/src/test/java/org/apache/tajo/engine/planner/global/TestBroadcastJoinPlan.java deleted file mode 100644 index 44a22ae..0000000 --- a/tajo-core/src/test/java/org/apache/tajo/engine/planner/global/TestBroadcastJoinPlan.java +++ /dev/null @@ -1,1044 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.tajo.engine.planner.global; - -import junit.framework.TestCase; -import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.Path; -import org.apache.tajo.LocalTajoTestingUtility; -import org.apache.tajo.QueryId; -import org.apache.tajo.QueryIdFactory; -import org.apache.tajo.TajoTestingCluster; -import org.apache.tajo.algebra.Expr; -import org.apache.tajo.catalog.*; -import org.apache.tajo.catalog.statistics.TableStats; -import org.apache.tajo.common.TajoDataTypes; -import org.apache.tajo.conf.TajoConf; -import org.apache.tajo.datum.Datum; -import org.apache.tajo.datum.DatumFactory; -import org.apache.tajo.datum.TextDatum; -import org.apache.tajo.engine.function.FunctionLoader; -import org.apache.tajo.engine.parser.SQLAnalyzer; -import org.apache.tajo.plan.LogicalOptimizer; -import org.apache.tajo.plan.LogicalPlan; -import org.apache.tajo.plan.LogicalPlanner; -import org.apache.tajo.plan.PlanningException; -import org.apache.tajo.engine.query.QueryContext; -import org.apache.tajo.plan.logical.*; -import org.apache.tajo.storage.*; -import org.apache.tajo.util.CommonTestingUtil; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.io.IOException; -import java.util.Collection; - -import static junit.framework.Assert.assertNotNull; -import static org.apache.tajo.TajoConstants.DEFAULT_DATABASE_NAME; -import static org.apache.tajo.TajoConstants.DEFAULT_TABLESPACE_NAME; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class TestBroadcastJoinPlan { - private TajoConf conf; - private final String TEST_PATH = TajoTestingCluster.DEFAULT_TEST_DIRECTORY + "/TestBroadcastJoinPlan"; - private TajoTestingCluster util; - private CatalogService catalog; - private SQLAnalyzer analyzer; - private QueryContext defaultContext; - private Path testDir; - - private TableDesc smallTable1; - private TableDesc smallTable2; - private TableDesc smallTable3; - private TableDesc largeTable1; - private TableDesc largeTable2; - private TableDesc largeTable3; - - @Before - public void setUp() throws Exception { - util = new TajoTestingCluster(); - conf = util.getConfiguration(); - conf.setLongVar(TajoConf.ConfVars.$DIST_QUERY_BROADCAST_JOIN_THRESHOLD, 500 * 1024); - conf.setBoolVar(TajoConf.ConfVars.$TEST_BROADCAST_JOIN_ENABLED, true); - - testDir = CommonTestingUtil.getTestDir(TEST_PATH); - catalog = util.startCatalogCluster().getCatalog(); - catalog.createTablespace(DEFAULT_TABLESPACE_NAME, testDir.toUri().toString()); - catalog.createDatabase(DEFAULT_DATABASE_NAME, DEFAULT_TABLESPACE_NAME); - util.getMiniCatalogCluster().getCatalogServer().reloadBuiltinFunctions(FunctionLoader.findLegacyFunctions()); - - Schema smallTable1Schema = new Schema(); - smallTable1Schema.addColumn("small1_id", TajoDataTypes.Type.INT4); - smallTable1Schema.addColumn("small1_contents", TajoDataTypes.Type.TEXT); - smallTable1 = makeTestData("default.small1", smallTable1Schema, 10 * 1024); - - Schema smallTable2Schema = new Schema(); - smallTable2Schema.addColumn("small2_id", TajoDataTypes.Type.INT4); - smallTable2Schema.addColumn("small2_contents", TajoDataTypes.Type.TEXT); - smallTable2 = makeTestData("default.small2", smallTable2Schema, 10 * 1024); - - Schema smallTable3Schema = new Schema(); - smallTable3Schema.addColumn("small3_id", TajoDataTypes.Type.INT4); - smallTable3Schema.addColumn("small3_contents", TajoDataTypes.Type.TEXT); - smallTable3 = makeTestData("default.small3", smallTable3Schema, 10 * 1024); - - Schema largeTable1Schema = new Schema(); - largeTable1Schema.addColumn("large1_id", TajoDataTypes.Type.INT4); - largeTable1Schema.addColumn("large1_contents", TajoDataTypes.Type.TEXT); - largeTable1 = makeTestData("default.large1", largeTable1Schema, 1024 * 1024); //1M - - Schema largeTable2Schema = new Schema(); - largeTable2Schema.addColumn("large2_id", TajoDataTypes.Type.INT4); - largeTable2Schema.addColumn("large2_contents", TajoDataTypes.Type.TEXT); - largeTable2 = makeTestData("default.large2", largeTable2Schema, 1024 * 1024); //1M - - Schema largeTable3Schema = new Schema(); - largeTable3Schema.addColumn("large3_id", TajoDataTypes.Type.INT4); - largeTable3Schema.addColumn("large3_contents", TajoDataTypes.Type.TEXT); - largeTable3 = makeTestData("default.large3", largeTable3Schema, 1024 * 1024); //1M - - catalog.createTable(smallTable1); - catalog.createTable(smallTable2); - catalog.createTable(smallTable3); - catalog.createTable(largeTable1); - catalog.createTable(largeTable2); - catalog.createTable(largeTable3); - - analyzer = new SQLAnalyzer(); - defaultContext = LocalTajoTestingUtility.createDummyContext(conf); - } - - private TableDesc makeTestData(String tableName, Schema schema, int dataSize) throws Exception { - TableMeta tableMeta = CatalogUtil.newTableMeta("CSV"); - Path dataPath = new Path(testDir, tableName + ".csv"); - - String contentsData = ""; - for (int i = 0; i < 1000; i++) { - for (int j = 0; j < 10; j++) { - contentsData += j; - } - } - Appender appender = ((FileStorageManager) TableSpaceManager.getFileStorageManager(conf)) - .getAppender(tableMeta, schema, dataPath); - appender.init(); - Tuple tuple = new VTuple(schema.size()); - int writtenSize = 0; - int count = 0; - while (true) { - TextDatum textDatum = DatumFactory.createText(count + "_" + contentsData); - tuple.put(new Datum[] { - DatumFactory.createInt4(count), textDatum }); - appender.addTuple(tuple); - - writtenSize += textDatum.size(); - if (writtenSize >= dataSize) { - break; - } - } - - appender.flush(); - appender.close(); - - TableDesc tableDesc = CatalogUtil.newTableDesc(tableName, schema, tableMeta, dataPath); - TableStats tableStats = new TableStats(); - FileSystem fs = dataPath.getFileSystem(conf); - tableStats.setNumBytes(fs.getFileStatus(dataPath).getLen()); - - tableDesc.setStats(tableStats); - - return tableDesc; - } - - @After - public void tearDown() throws Exception { - util.shutdownCatalogCluster(); - } - - @Test - public final void testBroadcastJoin() throws IOException, PlanningException { - String query = "select count(*) from large1 " + - "join small1 on large1_id = small1_id " + - "join small2 on small1_id = small2_id"; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - /* - |-eb_1395714781593_0000_000005 (TERMINAL) - |-eb_1395714781593_0000_000004 (ROOT, GROUP BY for counting) - |-eb_1395714781593_0000_000003 (LEAF, broadcast join) - */ - - ExecutionBlock terminalEB = masterPlan.getRoot(); - assertEquals(1, masterPlan.getChildCount(terminalEB.getId())); - - ExecutionBlock rootEB = masterPlan.getChild(terminalEB.getId(), 0); - assertEquals(1, masterPlan.getChildCount(rootEB.getId())); - - ExecutionBlock leafEB = masterPlan.getChild(rootEB.getId(), 0); - assertNotNull(leafEB); - - assertEquals(0, masterPlan.getChildCount(leafEB.getId())); - Collection<String> broadcastTables = leafEB.getBroadcastTables(); - assertEquals(2, broadcastTables.size()); - - assertTrue(broadcastTables.contains("default.small1")); - assertTrue(broadcastTables.contains("default.small2")); - assertTrue(!broadcastTables.contains("default.large1")); - - LogicalNode leafNode = leafEB.getPlan(); - assertEquals(NodeType.GROUP_BY, leafNode.getType()); - - LogicalNode joinNode = ((GroupbyNode)leafNode).getChild(); - assertEquals(NodeType.JOIN, joinNode.getType()); - - LogicalNode leftNode = ((JoinNode)joinNode).getLeftChild(); - LogicalNode rightNode = ((JoinNode)joinNode).getRightChild(); - - assertEquals(NodeType.JOIN, leftNode.getType()); - assertEquals(NodeType.SCAN, rightNode.getType()); - - LogicalNode lastLeftNode = ((JoinNode)leftNode).getLeftChild(); - LogicalNode lastRightNode = ((JoinNode)leftNode).getRightChild(); - - assertEquals(NodeType.SCAN, lastLeftNode.getType()); - assertEquals(NodeType.SCAN, lastRightNode.getType()); - } - - @Test - public final void testBroadcastJoinAllSmallTables() throws IOException, PlanningException { - String query = "select count(*) from small1 " + - "join small2 on small1_id = small2_id " + - "join small3 on small1_id = small3_id"; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - /* - |-eb_1402500846700_0000_000005 - |-eb_1402500846700_0000_000004 - |-eb_1402500846700_0000_000003 (LEAF, broadcast join small1, small2, small3) - */ - - ExecutionBlock terminalEB = masterPlan.getRoot(); - assertEquals(1, masterPlan.getChildCount(terminalEB.getId())); - - ExecutionBlock rootEB = masterPlan.getChild(terminalEB.getId(), 0); - assertEquals(1, masterPlan.getChildCount(rootEB.getId())); - - ExecutionBlock leafEB = masterPlan.getChild(rootEB.getId(), 0); - assertNotNull(leafEB); - - assertEquals(0, masterPlan.getChildCount(leafEB.getId())); - Collection<String> broadcastTables = leafEB.getBroadcastTables(); - assertEquals(3, broadcastTables.size()); - - assertTrue(broadcastTables.contains("default.small2")); - assertTrue(broadcastTables.contains("default.small1")); - assertTrue(broadcastTables.contains("default.small3")); - - LogicalNode leafNode = leafEB.getPlan(); - assertEquals(NodeType.GROUP_BY, leafNode.getType()); - - LogicalNode joinNode = ((GroupbyNode)leafNode).getChild(); - assertEquals(NodeType.JOIN, joinNode.getType()); - - LogicalNode leftNode = ((JoinNode)joinNode).getLeftChild(); - LogicalNode rightNode = ((JoinNode)joinNode).getRightChild(); - - assertEquals(NodeType.JOIN, leftNode.getType()); - assertEquals(NodeType.SCAN, rightNode.getType()); - assertEquals("default.small3", ((ScanNode)rightNode).getCanonicalName()); - - LogicalNode lastLeftNode = ((JoinNode)leftNode).getLeftChild(); - LogicalNode lastRightNode = ((JoinNode)leftNode).getRightChild(); - - assertEquals(NodeType.SCAN, lastLeftNode.getType()); - assertEquals(NodeType.SCAN, lastRightNode.getType()); - assertEquals("default.small1", ((ScanNode)lastLeftNode).getCanonicalName()); - assertEquals("default.small2", ((ScanNode)lastRightNode).getCanonicalName()); - } - - @Test - public final void testNotBroadcastJoinTwoLargeTable() throws IOException, PlanningException { - // This query is not broadcast join - String query = "select count(*) from large1 " + - "join large2 on large1_id = large2_id "; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertTrue(broadcastTables == null || broadcastTables.isEmpty()); - } - } - - @Test - public final void testTwoBroadcastJoin() throws IOException, PlanningException { - String query = "select count(*) from large1 " + - "join small1 on large1_id = small1_id " + - "join large2 on large1_id = large2_id " + - "join small2 on large2_id = small2_id"; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - /* - |-eb_1395736346625_0000_000009 - |-eb_1395736346625_0000_000008 (GROUP-BY) - |-eb_1395736346625_0000_000007 (GROUP-BY, JOIN) - |-eb_1395736346625_0000_000006 (LEAF, JOIN) - |-eb_1395736346625_0000_000003 (LEAF, JOIN) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(1, broadcastTables.size()); - - assertTrue(!broadcastTables.contains("default.large1")); - assertTrue(broadcastTables.contains("default.small1")); - } else if(index == 1) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(1, broadcastTables.size()); - assertTrue(!broadcastTables.contains("default.large2")); - assertTrue(broadcastTables.contains("default.small2")); - } - index++; - } - - assertEquals(5, index); - } - - @Test - public final void testNotBroadcastJoinSubquery() throws IOException, PlanningException { - // This query is not broadcast join; - String query = "select count(*) from large1 " + - "join (select * from small1) a on large1_id = a.small1_id " + - "join small2 on a.small1_id = small2_id"; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - /* - |-eb_1395749810370_0000_000007 - |-eb_1395749810370_0000_000006 (GROUP-BY) - |-eb_1395749810370_0000_000005 (GROUP-BY, JOIN) - |-eb_1395749810370_0000_000004 (LEAF, SCAN, large1) - |-eb_1395749810370_0000_000003 (JOIN) - |-eb_1395749810370_0000_000002 (LEAF, SCAN, small2) - |-eb_1395749810370_0000_000001 (LEAF, TABLE_SUBQUERY, small1) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertTrue(broadcastTables == null || broadcastTables.isEmpty()); - index++; - } - - assertEquals(7, index); - } - - @Test - public final void testBroadcastJoinSubquery() throws IOException, PlanningException { - String query = "select count(*) from large1 " + - "join small2 on large1_id = small2_id " + - "join (select * from small1) a on large1_id = a.small1_id"; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - /* - |-eb_1395794091662_0000_000007 - |-eb_1395794091662_0000_000006 - |-eb_1395794091662_0000_000005 (JOIN) - |-eb_1395794091662_0000_000004 (LEAF, SUBQUERY) - |-eb_1395794091662_0000_000003 (LEAF, JOIN) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - //LEAF, JOIN - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(1, broadcastTables.size()); - - assertTrue(!broadcastTables.contains("default.large1")); - assertTrue(broadcastTables.contains("default.small2")); - } else if(index == 1) { - //LEAF, SUBQUERY - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertTrue(broadcastTables == null || broadcastTables.isEmpty()); - } else if(index == 2) { - //JOIN - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertTrue(broadcastTables == null || broadcastTables.isEmpty()); - } - index++; - } - - assertEquals(5, index); - } - - @Test - public final void testLeftOuterJoinCase1() throws IOException, PlanningException { - // small, small, small, large, large - String query = "select count(*) from small1 " + - "left outer join small2 on small1_id = small2_id " + - "left outer join small3 on small1_id = small3_id " + - "left outer join large1 on small1_id = large1_id " + - "left outer join large2 on small1_id = large2_id "; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - // ((((default.small1 â default.small2) â default.small3) â default.large1) â default.large2) - /* - |-eb_1406022243130_0000_000009 - |-eb_1406022243130_0000_000008 - |-eb_1406022243130_0000_000007 (join) - |-eb_1406022243130_0000_000006 (scan large2) - |-eb_1406022243130_0000_000005 (join) - |-eb_1406022243130_0000_000004 (scan large1) - |-eb_1406022243130_0000_000003 (scan small1, broadcast join small2, small3) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(2, broadcastTables.size()); - - assertTrue(!broadcastTables.contains("default.small1")); - assertTrue(broadcastTables.contains("default.small2")); - assertTrue(broadcastTables.contains("default.small3")); - } else if(index == 1 || index == 2 || index == 3) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(0, broadcastTables.size()); - } - index++; - } - - assertEquals(7, index); - } - - @Test - public final void testLeftOuterJoinCase2() throws IOException, PlanningException { - // large, large, small, small, small - String query = "select count(*) from large1 " + - "left outer join large2 on large1_id = large2_id " + - "left outer join small1 on large1_id = small1_id " + - "left outer join small2 on large1_id = small2_id " + - "left outer join small3 on large1_id = small3_id "; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - // ((((default.large1 â default.large2) â default.small1) â default.small2) â default.small3) - /* - |-eb_1404132555037_0000_000005 - |-eb_1404132555037_0000_000004 - |-eb_1404132555037_0000_000003 (JOIN, broadcast small1, small2, small3) - |-eb_1404132555037_0000_000002 (LEAF, Scan large2) - |-eb_1404132555037_0000_000001 (LEAF, Scan large1) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.SCAN, node.getType()); - assertEquals("default.large1", ((ScanNode) node).getCanonicalName()); - - assertEquals(0, eb.getBroadcastTables().size()); - } else if (index == 1) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.SCAN, node.getType()); - assertEquals("default.large2", ((ScanNode)node).getCanonicalName()); - - assertEquals(0, eb.getBroadcastTables().size()); - } else if(index == 2) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.GROUP_BY, node.getType()); - - JoinNode joinNode = ((GroupbyNode)node).getChild(); - JoinNode joinNode2 = joinNode.getLeftChild(); - ScanNode scanNode2 = joinNode.getRightChild(); - assertEquals("default.small3", scanNode2.getCanonicalName()); - - JoinNode joinNode3 = joinNode2.getLeftChild(); - ScanNode scanNode3 = joinNode2.getRightChild(); - assertEquals("default.small2", scanNode3.getCanonicalName()); - - JoinNode joinNode4 = joinNode3.getLeftChild(); - ScanNode scanNode4 = joinNode3.getRightChild(); - assertEquals("default.small1", scanNode4.getCanonicalName()); - - ScanNode scanNode5 = joinNode4.getLeftChild(); - ScanNode scanNode6 = joinNode4.getRightChild(); - assertTrue(scanNode5.getCanonicalName().indexOf("0000_000001") > 0); - assertTrue(scanNode6.getCanonicalName().indexOf("0000_000002") > 0); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(3, broadcastTables.size()); - - assertTrue(broadcastTables.contains("default.small1")); - assertTrue(broadcastTables.contains("default.small2")); - assertTrue(broadcastTables.contains("default.small3")); - } - index++; - } - - assertEquals(5, index); - } - - @Test - public final void testLeftOuterJoinCase3() throws IOException, PlanningException { - // large1, large2, small1, large3, small2, small3 - String query = "select count(*) from large1 " + - "left outer join large2 on large1_id = large2_id " + - "left outer join small1 on large2_id = small1_id " + - "left outer join large3 on large1_id = large3_id " + - "left outer join small2 on large3_id = small2_id " + - "left outer join small3 on large3_id = small3_id "; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - //(((((default.large1 â default.large2) â default.small1) â default.large3) â default.small2) â default.small3) - /* - |-eb_1402634570910_0000_000007 - |-eb_1402634570910_0000_000006 (GROUP BY) - |-eb_1402634570910_0000_000005 (JOIN, broadcast small2, small3) - |-eb_1402634570910_0000_000004 (LEAF, scan large3) - |-eb_1402634570910_0000_000003 (JOIN, broadcast small1) - |-eb_1402634570910_0000_000002 (LEAF, scan large2) - |-eb_1402634570910_0000_000001 (LEAF, scan large1) - */ - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.SCAN, node.getType()); - ScanNode scanNode = (ScanNode)node; - assertEquals("default.large1", scanNode.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(0, broadcastTables.size()); - } else if (index == 1) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.SCAN, node.getType()); - ScanNode scanNode = (ScanNode)node; - assertEquals("default.large2", scanNode.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(0, broadcastTables.size()); - } else if(index == 2) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.JOIN, node.getType()); - JoinNode joinNode = (JoinNode)node; - - ScanNode leftNode = ((JoinNode)joinNode.getLeftChild()).getLeftChild(); - ScanNode rightNode = ((JoinNode)joinNode.getLeftChild()).getRightChild(); - assertTrue(leftNode.getCanonicalName().indexOf("0000_000001") > 0); - assertTrue(rightNode.getCanonicalName().indexOf("0000_000002") > 0); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(1, broadcastTables.size()); - assertTrue(broadcastTables.contains("default.small1")); - } else if(index == 3) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.SCAN, node.getType()); - ScanNode scanNode = (ScanNode)node; - assertEquals("default.large3", scanNode.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(0, broadcastTables.size()); - } else if(index == 4) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(2, broadcastTables.size()); - assertTrue(broadcastTables.contains("default.small2")); - assertTrue(broadcastTables.contains("default.small3")); - } - index++; - } - - assertEquals(7, index); - } - - @Test - public final void testLeftOuterJoinCase4() throws IOException, PlanningException { - // small1, small2, small3 - String query = "select count(*) from small1 " + - "left outer join small2 on small1_id = small2_id " + - "left outer join small3 on small1_id = small3_id "; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - /* - |-eb_1406022971444_0000_000005 - |-eb_1406022971444_0000_000004 (group by) - |-eb_1406022971444_0000_000003 (scan small1, broadcast join small2, small3) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - GroupbyNode node = (GroupbyNode)eb.getPlan(); - JoinNode joinNode = node.getChild(); - - ScanNode scanNode = joinNode.getRightChild(); - assertEquals("default.small3", scanNode.getCanonicalName()); - - joinNode = joinNode.getLeftChild(); - scanNode = joinNode.getLeftChild(); - assertEquals("default.small1", scanNode.getCanonicalName()); - scanNode = joinNode.getRightChild(); - assertEquals("default.small2", scanNode.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(2, broadcastTables.size()); - - assertTrue(broadcastTables.contains("default.small2")); - assertTrue(broadcastTables.contains("default.small3")); - } else if(index == 1) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(0, broadcastTables.size()); - } - index++; - } - - assertEquals(3, index); - } - - @Test - public final void testLeftOuterJoinCase5() throws IOException, PlanningException { - // small, small, large, small - String query = "select count(*) from small1 " + - "left outer join small2 on small1_id = small2_id " + - "left outer join large1 on small1_id = large1_id " + - "left outer join small3 on small1_id = small3_id " ; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - //(((default.small1 â default.small2) â default.large1) â default.small3) - /* - |-eb_1406023347983_0000_000007 - |-eb_1406023347983_0000_000006 - |-eb_1406023347983_0000_000005 (join, broadcast small3) - |-eb_1406023347983_0000_000004 (scan large1) - |-eb_1406023347983_0000_000003 (scan small1, broadcast join small2) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(1, broadcastTables.size()); - assertTrue(broadcastTables.contains("default.small2")); - } else if (index == 2) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(1, broadcastTables.size()); - assertTrue(broadcastTables.contains("default.small3")); - } else if(index == 1 || index == 3) { - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(0, broadcastTables.size()); - } - index++; - } - - assertEquals(5, index); - } - - @Test - public final void testLeftOuterJoinCase6() throws IOException, PlanningException { - // small1, small2, large1, large2, small3 - String query = "select count(*) from small1 " + - "left outer join small2 on small1_id = small2_id " + - "left outer join large1 on small1_id = large1_id " + - "left outer join large2 on small1_id = large2_id " + - "left outer join small3 on small1_id = small3_id " ; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - // ((((default.small1 â default.small2) â default.large1) â default.large2) â default.small3) - - /* - |-eb_1406023537578_0000_000009 - |-eb_1406023537578_0000_000008 - |-eb_1406023537578_0000_000007 (join, broadcast small3) - |-eb_1406023537578_0000_000006 (scan large2) - |-eb_1406023537578_0000_000005 (join) - |-eb_1406023537578_0000_000004 (scan large1) - |-eb_1406023537578_0000_000003 (scan small1, broadcast join small2) - */ - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.JOIN, node.getType()); - JoinNode joinNode = (JoinNode)node; - - ScanNode scanNode1 = joinNode.getLeftChild(); - ScanNode scanNode2 = joinNode.getRightChild(); - assertEquals("default.small1", scanNode1.getCanonicalName()); - assertEquals("default.small2", scanNode2.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(1, broadcastTables.size()); - assertTrue(broadcastTables.contains("default.small2")); - } else if (index == 1) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.SCAN, node.getType()); - ScanNode scanNode = (ScanNode) node; - assertEquals("default.large1", scanNode.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(0, broadcastTables.size()); - } else if (index == 2) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.JOIN, node.getType()); - } else if (index == 3) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.SCAN, node.getType()); - ScanNode scanNode = (ScanNode) node; - assertEquals("default.large2", scanNode.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(0, broadcastTables.size()); - } else if(index == 4) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.GROUP_BY, node.getType()); - - JoinNode joinNode = ((GroupbyNode)node).getChild(); - - JoinNode joinNode1 = joinNode.getLeftChild(); - ScanNode scanNode1 = joinNode.getRightChild(); - assertEquals("default.small3", scanNode1.getCanonicalName()); - - ScanNode scanNode2 = joinNode1.getLeftChild(); - ScanNode scanNode3 = joinNode1.getRightChild(); - assertTrue(scanNode2.getCanonicalName().indexOf("0000_000005") > 0); - assertTrue(scanNode3.getCanonicalName().indexOf("0000_000006") > 0); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - assertEquals(1, broadcastTables.size()); - } - index++; - } - - assertEquals(7, index); - } - - @Test - public final void testInnerLeftOuterJoinCase1() throws IOException, PlanningException { - // small, small, large, small - String query = "select count(*) from small1 " + - "inner join small2 on small1_id = small2_id " + - "left outer join large1 on small1_id = large1_id " + - "left outer join small3 on small3_id = large1_id " ; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - // (((default.small1 âθ default.small2) â default.large1) â default.small3) - /* - |-eb_1404139312268_0000_000006 - |-eb_1404139312268_0000_000005 - |-eb_1404139312268_0000_000003 (LEAF scan large1, broadcast small1, small2, small3) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.GROUP_BY, node.getType()); - JoinNode joinNode = ((GroupbyNode)node).getChild(); - - JoinNode joinNode2 = joinNode.getLeftChild(); - ScanNode scanNode = joinNode.getRightChild(); - assertEquals("default.small3", scanNode.getCanonicalName()); - - JoinNode joinNode3 = joinNode2.getLeftChild(); - ScanNode scanNode2 = joinNode2.getRightChild(); - - assertEquals("default.large1", scanNode2.getCanonicalName()); - - ScanNode scanNode3 = joinNode3.getLeftChild(); - ScanNode scanNode4 = joinNode3.getRightChild(); - - assertEquals("default.small1", scanNode3.getCanonicalName()); - assertEquals("default.small2", scanNode4.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - - assertEquals(3, broadcastTables.size()); - assertTrue(broadcastTables.contains("default.small1")); - assertTrue(broadcastTables.contains("default.small2")); - assertTrue(broadcastTables.contains("default.small3")); - } - index++; - } - - assertEquals(3, index); - } - - @Test - public final void testBroadcastCasebyCase1() throws IOException, PlanningException { - // large, small, large, small - String query = "select count(*) from large1 " + - "inner join small1 on large1_id = small1_id " + - "left outer join large2 on large1_id = large2_id " + - "left outer join small2 on large1_id = small2_id " ; - - LogicalPlanner planner = new LogicalPlanner(catalog); - LogicalOptimizer optimizer = new LogicalOptimizer(conf); - Expr expr = analyzer.parse(query); - LogicalPlan plan = planner.createPlan(defaultContext, expr); - - optimizer.optimize(plan); - - QueryId queryId = QueryIdFactory.newQueryId(System.currentTimeMillis(), 0); - QueryContext queryContext = new QueryContext(conf); - MasterPlan masterPlan = new MasterPlan(queryId, queryContext, plan); - GlobalPlanner globalPlanner = new GlobalPlanner(conf, catalog); - globalPlanner.build(masterPlan); - - // (((default.large1 âθ default.small1) â default.large2) â default.small2) - /* - |-eb_1404871198908_0000_000007 - |-eb_1404871198908_0000_000006 - |-eb_1404871198908_0000_000005 (join eb3, eb3, broadcast small2) - |-eb_1404871198908_0000_000004 (scan large2) - |-eb_1404871198908_0000_000003 (scan large1, broadcast small1) - */ - - ExecutionBlockCursor ebCursor = new ExecutionBlockCursor(masterPlan); - int index = 0; - while (ebCursor.hasNext()) { - ExecutionBlock eb = ebCursor.nextBlock(); - if(index == 0) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.JOIN, node.getType()); - JoinNode joinNode = (JoinNode)node; - - ScanNode scanNode1 = joinNode.getLeftChild(); - ScanNode scanNode2 = joinNode.getRightChild(); - assertEquals("default.large1", scanNode1.getCanonicalName()); - assertEquals("default.small1", scanNode2.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - - assertEquals(1, broadcastTables.size()); - assertTrue(broadcastTables.contains("default.small1")); - } else if(index == 1) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.SCAN, node.getType()); - ScanNode scanNode = (ScanNode)node; - - assertEquals("default.large2", scanNode.getCanonicalName()); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - TestCase.assertEquals(0, broadcastTables.size()); - } else if(index == 2) { - LogicalNode node = eb.getPlan(); - assertEquals(NodeType.GROUP_BY, node.getType()); - JoinNode joinNode = ((GroupbyNode)node).getChild(); - - JoinNode joinNode2 = joinNode.getLeftChild(); - ScanNode scanNode = joinNode.getRightChild(); - assertEquals("default.small2", scanNode.getCanonicalName()); - - ScanNode scanNode2 = joinNode2.getLeftChild(); - ScanNode scanNode3 = joinNode2.getRightChild(); - - assertTrue(scanNode2.getCanonicalName().indexOf("000003") >= 0); - assertTrue(scanNode3.getCanonicalName().indexOf("000004") >= 0); - - Collection<String> broadcastTables = eb.getBroadcastTables(); - - TestCase.assertEquals(1, broadcastTables.size()); - TestCase.assertTrue(broadcastTables.contains("default.small2")); - } - index++; - } - - TestCase.assertEquals(5, index); - } -} http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java index 1da3ee9..4f90386 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java @@ -523,13 +523,13 @@ public class TestGroupByQuery extends QueryTestCaseBase { "a|\\N|" }; - TajoTestingCluster.createTable("table11", schema, tableOptions, data); + TajoTestingCluster.createTable("testDistinctAggregationCaseByCase4".toLowerCase(), schema, tableOptions, data); ResultSet res = executeQuery(); assertResultSet(res); cleanupQuery(res); - executeString("DROP TABLE table11 PURGE").close(); + executeString("DROP TABLE testDistinctAggregationCaseByCase4 PURGE").close(); } @Test @@ -612,62 +612,62 @@ public class TestGroupByQuery extends QueryTestCaseBase { @Test public final void testGroupByWithNullData5() throws Exception { - executeString("CREATE TABLE table1 (age INT4, point FLOAT4);").close(); - assertTableExists("table1"); + executeString("CREATE TABLE testGroupByWithNullData5 (age INT4, point FLOAT4);").close(); + assertTableExists("testGroupByWithNullData5".toLowerCase()); ResultSet res = executeQuery(); assertResultSet(res); cleanupQuery(res); - executeString("DROP TABLE table1"); + executeString("DROP TABLE testGroupByWithNullData5"); } @Test public final void testGroupByWithNullData6() throws Exception { - executeString("CREATE TABLE table1 (age INT4, point FLOAT4);").close(); - assertTableExists("table1"); + executeString("CREATE TABLE testGroupByWithNullData6 (age INT4, point FLOAT4);").close(); + assertTableExists("testGroupByWithNullData6".toLowerCase()); ResultSet res = executeQuery(); assertResultSet(res); cleanupQuery(res); - executeString("DROP TABLE table1"); + executeString("DROP TABLE testGroupByWithNullData6"); } @Test public final void testGroupByWithNullData7() throws Exception { - executeString("CREATE TABLE table1 (age INT4, point FLOAT4);").close(); - assertTableExists("table1"); + executeString("CREATE TABLE testGroupByWithNullData7 (age INT4, point FLOAT4);").close(); + assertTableExists("testGroupByWithNullData7".toLowerCase()); ResultSet res = executeQuery(); assertResultSet(res); cleanupQuery(res); - executeString("DROP TABLE table1"); + executeString("DROP TABLE testGroupByWithNullData7"); } @Test public final void testGroupByWithNullData8() throws Exception { - executeString("CREATE TABLE table1 (age INT4, point FLOAT4);").close(); - assertTableExists("table1"); + executeString("CREATE TABLE testGroupByWithNullData8 (age INT4, point FLOAT4);").close(); + assertTableExists("testGroupByWithNullData8".toLowerCase()); ResultSet res = executeQuery(); assertResultSet(res); cleanupQuery(res); - executeString("DROP TABLE table1"); + executeString("DROP TABLE testGroupByWithNullData8"); } @Test public final void testGroupByWithNullData9() throws Exception { - executeString("CREATE TABLE table1 (age INT4, point FLOAT4);").close(); - assertTableExists("table1"); + executeString("CREATE TABLE testGroupByWithNullData9 (age INT4, point FLOAT4);").close(); + assertTableExists("testGroupByWithNullData9".toLowerCase()); ResultSet res = executeQuery(); assertResultSet(res); cleanupQuery(res); - executeString("DROP TABLE table1"); + executeString("DROP TABLE testGroupByWithNullData9"); } @Test http://git-wip-us.apache.org/repos/asf/tajo/blob/4b1b7799/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInnerJoinQuery.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInnerJoinQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInnerJoinQuery.java new file mode 100644 index 0000000..6eedb42 --- /dev/null +++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestInnerJoinQuery.java @@ -0,0 +1,335 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.tajo.engine.query; + +import com.google.protobuf.ServiceException; +import org.apache.tajo.IntegrationTest; +import org.apache.tajo.NamedTest; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.sql.ResultSet; + +@Category(IntegrationTest.class) +@RunWith(Parameterized.class) +@NamedTest("TestJoinQuery") +public class TestInnerJoinQuery extends TestJoinQuery { + + public TestInnerJoinQuery(String joinOption) throws Exception { + super(joinOption); + } + + @BeforeClass + public static void setup() throws Exception { + TestJoinQuery.setup(); + } + + @AfterClass + public static void classTearDown() throws ServiceException { + TestJoinQuery.classTearDown(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest(queries = { + @QuerySpec("select n_name, r_name, n_regionkey, r_regionkey from nation, region order by n_name, r_name"), + // testCrossJoinWithAsterisk + @QuerySpec("select region.*, customer.* from region, customer"), + @QuerySpec("select region.*, customer.* from customer, region"), + @QuerySpec("select * from customer, region"), + @QuerySpec("select length(r_comment) as len, *, c_custkey*10 from customer, region order by len,r_regionkey,r_name") + }) + public final void testCrossJoin() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testCrossJoinWithThetaJoinConditionInWhere() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testInnerJoinWithThetaJoinConditionInWhere() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testWhereClauseJoin1() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testWhereClauseJoin2() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testWhereClauseJoin3() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testWhereClauseJoin4() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testWhereClauseJoin5() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testWhereClauseJoin6() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testTPCHQ2Join() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testJoinWithMultipleJoinQual1() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testJoinCoReferredEvals1() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testJoinCoReferredEvalsWithSameExprs1() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testJoinCoReferredEvalsWithSameExprs2() throws Exception { + // including grouping operator + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testInnerJoinAndCaseWhen() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testInnerJoinWithEmptyTable() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testCrossJoinWithEmptyTable1() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest(prepare = { + "CREATE DATABASE JOINS", + "CREATE TABLE JOINS.part_ as SELECT * FROM part", + "CREATE TABLE JOINS.supplier_ as SELECT * FROM supplier" + }, cleanup = { + "DROP TABLE JOINS.part_ PURGE", + "DROP TABLE JOINS.supplier_ PURGE", + "DROP DATABASE JOINS" + }) + public final void testJoinOnMultipleDatabases() throws Exception { + runSimpleTests(); + } + + @Test + public final void testJoinWithJson() throws Exception { + // select length(r_comment) as len, *, c_custkey*10 from customer, region order by len,r_regionkey,r_name + ResultSet res = executeJsonQuery(); + assertResultSet(res); + cleanupQuery(res); + } + + @Test + public final void testJoinOnMultipleDatabasesWithJson() throws Exception { + executeString("CREATE DATABASE JOINS"); + assertDatabaseExists("joins"); + executeString("CREATE TABLE JOINS.part_ as SELECT * FROM part"); + assertTableExists("joins.part_"); + executeString("CREATE TABLE JOINS.supplier_ as SELECT * FROM supplier"); + assertTableExists("joins.supplier_"); + + try { + ResultSet res = executeJsonQuery(); + assertResultSet(res); + cleanupQuery(res); + } finally { + executeString("DROP TABLE JOINS.part_ PURGE"); + executeString("DROP TABLE JOINS.supplier_ PURGE"); + executeString("DROP DATABASE JOINS"); + } + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testJoinAsterisk() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testDifferentTypesJoinCondition() throws Exception { + // select * from table20 t3 join table21 t4 on t3.id = t4.id; + executeDDL("table1_int8_ddl.sql", "table1", "table20"); + executeDDL("table1_int4_ddl.sql", "table1", "table21"); + try { + runSimpleTests(); + } finally { + executeString("DROP TABLE table20"); + executeString("DROP TABLE table21"); + } + } + + @Test + @SimpleTest + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + public void testComplexJoinCondition1() throws Exception { + // select n1.n_nationkey, n1.n_name, n2.n_name from nation n1 join nation n2 on n1.n_name = upper(n2.n_name); + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testComplexJoinCondition2() throws Exception { + // select n1.n_nationkey, n1.n_name, upper(n2.n_name) name from nation n1 join nation n2 + // on n1.n_name = upper(n2.n_name); + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testComplexJoinCondition3() throws Exception { + // select n1.n_nationkey, n1.n_name, n2.n_name from nation n1 join nation n2 on lower(n1.n_name) = lower(n2.n_name); + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testComplexJoinCondition4() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testJoinWithOrPredicates() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testNaturalJoin() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testCrossJoinAndCaseWhen() throws Exception { + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testCrossJoinWithAsterisk1() throws Exception { + // select region.*, customer.* from region, customer; + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testCrossJoinWithAsterisk2() throws Exception { + // select region.*, customer.* from customer, region; + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testCrossJoinWithAsterisk3() throws Exception { + // select * from customer, region + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public void testCrossJoinWithAsterisk4() throws Exception { + // select length(r_regionkey), *, c_custkey*10 from customer, region + runSimpleTests(); + } + + @Test + @Option(withExplain = true, withExplainGlobal = true, parameterized = true) + @SimpleTest() + public final void testBroadcastTwoPartJoin() throws Exception { + runSimpleTests(); + } +}
