From 53797b74f5a0b31425f3bb5a18d336a057f7d5ac Mon Sep 17 00:00:00 2001 From: Hyunsik Choi Date: Thu, 5 Jun 2014 11:27:25 -0700 Subject: [PATCH 1/3] TAJO-868: TestDateTimeFunctions unit test is occasionally failed. --- CHANGES | 2 ++ .../apache/tajo/engine/function/TestDateTimeFunctions.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 7316e4df47..212e6aa74d 100644 --- a/CHANGES +++ b/CHANGES @@ -58,6 +58,8 @@ Release 0.9.0 - unreleased BUG FIXES + TAJO-868: TestDateTimeFunctions unit test is occasionally failed. (hyunsik) + TAJO-851: Timestamp type test of TestSQLExpression::testCastFromTable fails in jenkins CI test. (Hyoungjun Kim via hyunsik) diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java b/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java index 1c59770e82..ef691f7216 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/function/TestDateTimeFunctions.java @@ -391,7 +391,7 @@ public void testDateTimeNow() throws IOException { testSimpleEval("select current_date();", new String[]{dateFormat(expectedDate, "yyyy-MM-dd")}); testSimpleEval("select cast(extract(hour from current_time()) as INT4);", - new String[]{dateFormat(expectedDate, "HH")}); + new String[]{String.valueOf(Integer.parseInt(dateFormat(expectedDate, "HH")))}); } finally { TajoConf.setCurrentTimeZone(originTimeZone); TimeZone.setDefault(systemOriginTimeZone); @@ -413,7 +413,7 @@ public void testTimeValueKeyword() throws IOException { testSimpleEval("select current_date;", new String[]{dateFormat(expectedDate, "yyyy-MM-dd")}); testSimpleEval("select cast(extract(hour from current_time) as INT4);", - new String[]{dateFormat(expectedDate, "HH")}); + new String[]{String.valueOf(Integer.parseInt(dateFormat(expectedDate, "HH")))}); } finally { TajoConf.setCurrentTimeZone(originTimeZone); TimeZone.setDefault(systemOriginTimeZone); From 82b39e03a773f407d525116bb7c90a5ded708412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=95=EC=A4=80?= Date: Fri, 6 Jun 2014 21:44:48 +0900 Subject: [PATCH 2/3] TAJO-867: OUTER JOIN with empty result subquery produces a wrong result. --- .../java/org/apache/tajo/conf/TajoConf.java | 5 +- .../master/querymaster/Repartitioner.java | 54 +++++-- .../tajo/master/querymaster/SubQuery.java | 4 + .../org/apache/tajo/QueryTestCaseBase.java | 17 +- .../org/apache/tajo/TajoTestingCluster.java | 50 ++++++ .../tajo/engine/query/TestJoinQuery.java | 146 +++++++++++++++++- 6 files changed, 253 insertions(+), 23 deletions(-) diff --git a/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java b/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java index 3f2b16fd3c..fc96a15fa3 100644 --- a/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java +++ b/tajo-common/src/main/java/org/apache/tajo/conf/TajoConf.java @@ -338,7 +338,10 @@ public static enum ConfVars { CSVFILE_NULL("tajo.csvfile.null", "\\\\N"), // DEBUG OPTION - TAJO_DEBUG("tajo.debug", false) + TAJO_DEBUG("tajo.debug", false), + + // ONLY FOR TESTCASE + TESTCASE_MIN_TASK_NUM("tajo.testcase.min.task.num", -1) ; public final String varname; diff --git a/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java b/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java index 3a2e79f5f5..c74452fd51 100644 --- a/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java +++ b/tajo-core/src/main/java/org/apache/tajo/master/querymaster/Repartitioner.java @@ -88,12 +88,9 @@ public static void scheduleFragmentsForJoinQuery(TaskSchedulerContext schedulerC TableDesc tableDesc = masterContext.getTableDescMap().get(scans[i].getCanonicalName()); if (tableDesc == null) { // if it is a real table stored on storage // TODO - to be fixed (wrong directory) - ExecutionBlock [] childBlocks = new ExecutionBlock[2]; - childBlocks[0] = masterPlan.getChild(execBlock.getId(), 0); - childBlocks[1] = masterPlan.getChild(execBlock.getId(), 1); - tablePath = storageManager.getTablePath(scans[i].getTableName()); - stats[i] = masterContext.getSubQuery(childBlocks[i].getId()).getResultStats().getNumBytes(); + ExecutionBlockId scanEBId = TajoIdUtils.createExecutionBlockId(scans[i].getTableName()); + stats[i] = masterContext.getSubQuery(scanEBId).getResultStats().getNumBytes(); fragments[i] = new FileFragment(scans[i].getCanonicalName(), tablePath, 0, 0, new String[]{UNKNOWN_HOST}); } else { tablePath = tableDesc.getPath(); @@ -115,11 +112,10 @@ public static void scheduleFragmentsForJoinQuery(TaskSchedulerContext schedulerC } } - // If one of inner join tables has no input data, - // it should return zero rows. + // If one of inner join tables has no input data, it should return zero rows. JoinNode joinNode = PlannerUtil.findMostBottomNode(execBlock.getPlan(), NodeType.JOIN); if (joinNode != null) { - if ( (joinNode.getJoinType().equals(JoinType.INNER))) { + if ( (joinNode.getJoinType() == JoinType.INNER)) { for (int i = 0; i < stats.length; i++) { if (stats[i] == 0) { return; @@ -128,6 +124,36 @@ public static void scheduleFragmentsForJoinQuery(TaskSchedulerContext schedulerC } } + // If node is outer join and a preserved relation is empty, it should return zero rows. + joinNode = PlannerUtil.findTopNode(execBlock.getPlan(), NodeType.JOIN); + if (joinNode != null) { + // find left top scan node + ScanNode leftScanNode = PlannerUtil.findTopNode(joinNode.getLeftChild(), NodeType.SCAN); + ScanNode rightScanNode = PlannerUtil.findTopNode(joinNode.getRightChild(), NodeType.SCAN); + + long leftStats = -1; + long rightStats = -1; + if (stats.length == 2) { + for (int i = 0; i < stats.length; i++) { + if (scans[i].equals(leftScanNode)) { + leftStats = stats[i]; + } else if (scans[i].equals(rightScanNode)) { + rightStats = stats[i]; + } + } + if (joinNode.getJoinType() == JoinType.LEFT_OUTER) { + if (leftStats == 0) { + return; + } + } + if (joinNode.getJoinType() == JoinType.RIGHT_OUTER) { + if (rightStats == 0) { + return; + } + } + } + } + // Assigning either fragments or fetch urls to query units boolean isAllBroadcastTable = true; int baseScanIdx = -1; @@ -285,14 +311,16 @@ private static void addJoinShuffle(SubQuery subQuery, int partitionId, Map> grouppedPartitions) { Map> fetches = new HashMap>(); for (ExecutionBlock execBlock : subQuery.getMasterPlan().getChilds(subQuery.getId())) { - Collection requests; if (grouppedPartitions.containsKey(execBlock.getId().toString())) { - requests = mergeShuffleRequest(execBlock.getId(), partitionId, HASH_SHUFFLE, + Collection requests = mergeShuffleRequest(execBlock.getId(), partitionId, HASH_SHUFFLE, grouppedPartitions.get(execBlock.getId().toString())); - } else { - return; + fetches.put(execBlock.getId().toString(), Lists.newArrayList(requests)); } - fetches.put(execBlock.getId().toString(), Lists.newArrayList(requests)); + } + + if (fetches.isEmpty()) { + LOG.info(subQuery.getId() + "'s " + partitionId + " partition has empty result."); + return; } SubQuery.scheduleFetches(subQuery, fetches); } diff --git a/tajo-core/src/main/java/org/apache/tajo/master/querymaster/SubQuery.java b/tajo-core/src/main/java/org/apache/tajo/master/querymaster/SubQuery.java index 22817bd080..300aaf4c8b 100644 --- a/tajo-core/src/main/java/org/apache/tajo/master/querymaster/SubQuery.java +++ b/tajo-core/src/main/java/org/apache/tajo/master/querymaster/SubQuery.java @@ -749,6 +749,10 @@ public static int calculateShuffleOutputNum(SubQuery subQuery, DataChannel chann // determine the number of task taskNum = Math.min(taskNum, slots); + if (conf.getIntVar(ConfVars.TESTCASE_MIN_TASK_NUM) > 0) { + taskNum = conf.getIntVar(ConfVars.TESTCASE_MIN_TASK_NUM); + LOG.warn("!!!!! TESTCASE MODE !!!!!"); + } LOG.info(subQuery.getId() + ", The determined number of join partitions is " + taskNum); // The shuffle output numbers of join may be inconsistent by execution block order. diff --git a/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java b/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java index 1d7d0ff6c9..70c73f9cda 100644 --- a/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java +++ b/tajo-core/src/test/java/org/apache/tajo/QueryTestCaseBase.java @@ -236,11 +236,20 @@ protected ResultSet executeString(String sql) throws Exception { * @return ResultSet of query execution. */ public ResultSet executeQuery() throws Exception { - return executeFile(name.getMethodName() + ".sql"); + return executeFile(getMethodName() + ".sql"); + } + + private String getMethodName() { + String methodName = name.getMethodName(); + // In the case of parameter execution name's pattern is methodName[0] + if (methodName.endsWith("]")) { + methodName = methodName.substring(0, methodName.length() - 3); + } + return methodName; } public ResultSet executeJsonQuery() throws Exception { - return executeJsonFile(name.getMethodName() + ".json"); + return executeJsonFile(getMethodName() + ".json"); } /** @@ -281,7 +290,7 @@ public ResultSet executeJsonFile(String jsonFileName) throws Exception { * @param result Query result to be compared. */ public final void assertResultSet(ResultSet result) throws IOException { - assertResultSet("Result Verification", result, name.getMethodName() + ".result"); + assertResultSet("Result Verification", result, getMethodName() + ".result"); } /** @@ -314,7 +323,7 @@ public final void assertResultSet(String message, ResultSet result, String resul } public final void assertStrings(String actual) throws IOException { - assertStrings(actual, name.getMethodName() + ".result"); + assertStrings(actual, getMethodName() + ".result"); } public final void assertStrings(String actual, String resultFileName) throws IOException { diff --git a/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java b/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java index 06d2bab2d4..f5c68f991d 100644 --- a/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java +++ b/tajo-core/src/test/java/org/apache/tajo/TajoTestingCluster.java @@ -595,6 +595,56 @@ public static ResultSet run(String[] names, return res; } + public static void createTable(String tableName, Schema schema, + KeyValueSet tableOption, String[] tableDatas) throws Exception { + createTable(tableName, schema, tableOption, tableDatas, 1); + } + + public static void createTable(String tableName, Schema schema, + KeyValueSet tableOption, String[] tableDatas, int numDataFiles) throws Exception { + TpchTestBase instance = TpchTestBase.getInstance(); + TajoTestingCluster util = instance.getTestingCluster(); + while(true) { + if(util.getMaster().isMasterRunning()) { + break; + } + Thread.sleep(1000); + } + TajoConf conf = util.getConfiguration(); + TajoClient client = new TajoClient(conf); + + FileSystem fs = util.getDefaultFileSystem(); + Path rootDir = util.getMaster(). + getStorageManager().getWarehouseDir(); + if (!fs.exists(rootDir)) { + fs.mkdirs(rootDir); + } + Path tablePath = new Path(rootDir, tableName); + fs.mkdirs(tablePath); + if (tableDatas.length > 0) { + int recordPerFile = tableDatas.length / numDataFiles; + if (recordPerFile == 0) { + recordPerFile = 1; + } + FSDataOutputStream out = null; + for (int j = 0; j < tableDatas.length; j++) { + if (out == null || j % recordPerFile == 0) { + if (out != null) { + out.close(); + } + Path dfsPath = new Path(tablePath, tableName + j + ".tbl"); + out = fs.create(dfsPath); + } + out.write((tableDatas[j] + "\n").getBytes()); + } + if (out != null) { + out.close(); + } + } + TableMeta meta = CatalogUtil.newTableMeta(CatalogProtos.StoreType.CSV, tableOption); + client.createExternalTable(tableName, schema, tablePath, meta); + } + /** * Write lines to a file. * diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java index 11cf344fb9..c4ad17a751 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java @@ -21,16 +21,80 @@ import org.apache.tajo.IntegrationTest; import org.apache.tajo.QueryTestCaseBase; import org.apache.tajo.TajoConstants; +import org.apache.tajo.TajoTestingCluster; +import org.apache.tajo.catalog.Schema; +import org.apache.tajo.common.TajoDataTypes.Type; +import org.apache.tajo.conf.TajoConf.ConfVars; +import org.apache.tajo.storage.StorageConstants; +import org.apache.tajo.util.KeyValueSet; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; import java.sql.ResultSet; +import java.util.Arrays; +import java.util.Collection; + +import static org.junit.Assert.assertEquals; @Category(IntegrationTest.class) +@RunWith(Parameterized.class) public class TestJoinQuery extends QueryTestCaseBase { - public TestJoinQuery() { +// public TestJoinQuery() { +// super(TajoConstants.DEFAULT_DATABASE_NAME); +// } + + public TestJoinQuery(String joinOption) { super(TajoConstants.DEFAULT_DATABASE_NAME); + + testingCluster.setAllTajoDaemonConfValue(ConfVars.DIST_QUERY_BROADCAST_JOIN_AUTO.varname, + ConfVars.DIST_QUERY_BROADCAST_JOIN_AUTO.defaultVal); + testingCluster.setAllTajoDaemonConfValue(ConfVars.DIST_QUERY_BROADCAST_JOIN_THRESHOLD.varname, + ConfVars.DIST_QUERY_BROADCAST_JOIN_THRESHOLD.defaultVal); + + testingCluster.setAllTajoDaemonConfValue( + ConfVars.EXECUTOR_INNER_JOIN_INMEMORY_HASH_THRESHOLD.varname, + ConfVars.EXECUTOR_INNER_JOIN_INMEMORY_HASH_THRESHOLD.defaultVal); + + testingCluster.setAllTajoDaemonConfValue(ConfVars.EXECUTOR_OUTER_JOIN_INMEMORY_HASH_THRESHOLD.varname, + ConfVars.EXECUTOR_OUTER_JOIN_INMEMORY_HASH_THRESHOLD.defaultVal); + testingCluster.setAllTajoDaemonConfValue(ConfVars.EXECUTOR_GROUPBY_INMEMORY_HASH_THRESHOLD.varname, + ConfVars.EXECUTOR_GROUPBY_INMEMORY_HASH_THRESHOLD.defaultVal); + + if (joinOption.indexOf("NoBroadcast") >= 0) { + testingCluster.setAllTajoDaemonConfValue(ConfVars.DIST_QUERY_BROADCAST_JOIN_AUTO.varname, "false"); + testingCluster.setAllTajoDaemonConfValue(ConfVars.DIST_QUERY_BROADCAST_JOIN_THRESHOLD.varname, "-1"); + } + + if (joinOption.indexOf("Hash") >= 0) { + testingCluster.setAllTajoDaemonConfValue( + ConfVars.EXECUTOR_INNER_JOIN_INMEMORY_HASH_THRESHOLD.varname, String.valueOf(256 * 1048576)); + testingCluster.setAllTajoDaemonConfValue(ConfVars.EXECUTOR_OUTER_JOIN_INMEMORY_HASH_THRESHOLD.varname, + String.valueOf(256 * 1048576)); + testingCluster.setAllTajoDaemonConfValue(ConfVars.EXECUTOR_GROUPBY_INMEMORY_HASH_THRESHOLD.varname, + String.valueOf(256 * 1048576)); + } + if (joinOption.indexOf("Sort") >= 0) { + testingCluster.setAllTajoDaemonConfValue( + ConfVars.EXECUTOR_INNER_JOIN_INMEMORY_HASH_THRESHOLD.varname, String.valueOf(1)); + testingCluster.setAllTajoDaemonConfValue(ConfVars.EXECUTOR_OUTER_JOIN_INMEMORY_HASH_THRESHOLD.varname, + String.valueOf(1)); + testingCluster.setAllTajoDaemonConfValue(ConfVars.EXECUTOR_GROUPBY_INMEMORY_HASH_THRESHOLD.varname, + String.valueOf(1)); + } + } + + @Parameters + public static Collection generateParameters() { + return Arrays.asList(new Object[][]{ + {"Hash_NoBroadcast"}, +// {"Sort_NoBroadcast"}, +// {"Hash"}, +// {"Sort"}, + }); } @Test @@ -297,10 +361,82 @@ public final void testRightOuterJoinWithEmptyTable1() throws Exception { } @Test - public final void testFullOuterJoinWithEmptyTable1() throws Exception { - ResultSet res = executeQuery(); - assertResultSet(res); - cleanupQuery(res); + public final void testLeftOuterJoinWithEmptySubquery1() throws Exception { + // Empty Null Supplying table + KeyValueSet tableOptions = new KeyValueSet(); + tableOptions.put(StorageConstants.CSVFILE_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER); + tableOptions.put(StorageConstants.CSVFILE_NULL, "\\\\N"); + + Schema schema = new Schema(); + schema.addColumn("id", Type.INT4); + schema.addColumn("name", Type.TEXT); + String[] data = new String[]{ "1|table11-1", "2|table11-2", "3|table11-3", "4|table11-4", "5|table11-5" }; + TajoTestingCluster.createTable("table11", schema, tableOptions, data, 2); + + data = new String[]{ "1|table11-1", "2|table11-2" }; + TajoTestingCluster.createTable("table12", schema, tableOptions, data, 2); + + try { + testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, "2"); + + ResultSet res = executeString("select a.id, b.id from table11 a " + +// "left outer join (select table12.id from table12 inner join lineitem on table12.id = lineitem.l_orderkey and table12.id > 10) b " + + "left outer join (select table12.id from table12 where table12.id > 10) b " + + "on a.id = b.id order by a.id"); + + String expected = "id,id\n" + + "-------------------------------\n" + + "1,null\n" + + "2,null\n" + + "3,null\n" + + "4,null\n" + + "5,null\n"; + + assertEquals(expected, resultSetToString(res)); + cleanupQuery(res); + } finally { + testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, + ConfVars.TESTCASE_MIN_TASK_NUM.defaultVal); + executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE table12 PURGE"); + } + } + + @Test + public final void testLeftOuterJoinWithEmptySubquery2() throws Exception { + //Empty Preserved Row table + KeyValueSet tableOptions = new KeyValueSet(); + tableOptions.put(StorageConstants.CSVFILE_DELIMITER, StorageConstants.DEFAULT_FIELD_DELIMITER); + tableOptions.put(StorageConstants.CSVFILE_NULL, "\\\\N"); + + Schema schema = new Schema(); + schema.addColumn("id", Type.INT4); + schema.addColumn("name", Type.TEXT); + String[] data = new String[]{ "1|table11-1", "2|table11-2", "3|table11-3", "4|table11-4", "5|table11-5" }; + TajoTestingCluster.createTable("table11", schema, tableOptions, data, 2); + + data = new String[]{ "1|table11-1", "2|table11-2" }; + TajoTestingCluster.createTable("table12", schema, tableOptions, data, 2); + + try { + testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, "2"); + + ResultSet res = executeString("select a.id, b.id from " + + "(select table12.id from table12 inner join lineitem on table12.id = lineitem.l_orderkey and table12.id > 10) a " + + "left outer join table11 b " + + "on a.id = b.id"); + + String expected = "id,id\n" + + "-------------------------------\n"; + + assertEquals(expected, resultSetToString(res)); + cleanupQuery(res); + } finally { + testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, + ConfVars.TESTCASE_MIN_TASK_NUM.defaultVal); + executeString("DROP TABLE table11 PURGE"); + executeString("DROP TABLE table12 PURGE"); + } } @Test From 144463b7772f1771564c9de66839fd979d3e38d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=98=95=EC=A4=80?= Date: Fri, 6 Jun 2014 23:08:48 +0900 Subject: [PATCH 3/3] TAJO-867: OUTER JOIN with empty result subquery produces a wrong result. add order by clause in some test query. --- .../planner/physical/JoinTupleComparator.java | 13 +++++++++-- .../tajo/engine/query/TestJoinQuery.java | 23 +++++++++---------- .../TestJoinQuery/testWhereClauseJoin1.sql | 3 ++- .../TestJoinQuery/testWhereClauseJoin2.sql | 3 ++- .../TestJoinQuery/testWhereClauseJoin3.sql | 3 ++- .../TestJoinQuery/testWhereClauseJoin4.sql | 3 ++- .../TestJoinQuery/testWhereClauseJoin1.result | 8 +++---- .../TestJoinQuery/testWhereClauseJoin2.result | 8 +++---- .../TestJoinQuery/testWhereClauseJoin3.result | 8 +++---- .../TestJoinQuery/testWhereClauseJoin4.result | 8 +++---- 10 files changed, 46 insertions(+), 34 deletions(-) diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/JoinTupleComparator.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/JoinTupleComparator.java index 0d4c47bdce..a59f8d9853 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/JoinTupleComparator.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/physical/JoinTupleComparator.java @@ -61,8 +61,17 @@ public JoinTupleComparator(Schema leftschema, Schema rightschema, SortSpec[][] s @Override public int compare(Tuple outerTuple, Tuple innerTuple) { for (int i = 0; i < numSortKey; i++) { - outer = outerTuple.get(outerSortKeyIds[i]); - inner = innerTuple.get(innerSortKeyIds[i]); + if (outerTuple == null) { + outer = NullDatum.get(); + } else { + outer = outerTuple.get(outerSortKeyIds[i]); + } + + if (innerTuple == null) { + inner = NullDatum.get(); + } else { + inner = innerTuple.get(innerSortKeyIds[i]); + } if (outer instanceof NullDatum || inner instanceof NullDatum) { if (!outer.equals(inner)) { diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java index c4ad17a751..f58ebb72c0 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java @@ -43,10 +43,6 @@ @RunWith(Parameterized.class) public class TestJoinQuery extends QueryTestCaseBase { -// public TestJoinQuery() { -// super(TajoConstants.DEFAULT_DATABASE_NAME); -// } - public TestJoinQuery(String joinOption) { super(TajoConstants.DEFAULT_DATABASE_NAME); @@ -91,9 +87,9 @@ public TestJoinQuery(String joinOption) { public static Collection generateParameters() { return Arrays.asList(new Object[][]{ {"Hash_NoBroadcast"}, -// {"Sort_NoBroadcast"}, -// {"Hash"}, -// {"Sort"}, + {"Sort_NoBroadcast"}, + {"Hash"}, + {"Sort"}, }); } @@ -272,6 +268,8 @@ public void testOuterJoinAndCaseWhen1() throws Exception { ResultSet res = executeQuery(); assertResultSet(res); cleanupQuery(res); + executeString("DROP TABLE table1").close(); + executeString("DROP TABLE table2").close(); } @Test @@ -380,8 +378,8 @@ public final void testLeftOuterJoinWithEmptySubquery1() throws Exception { testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, "2"); ResultSet res = executeString("select a.id, b.id from table11 a " + -// "left outer join (select table12.id from table12 inner join lineitem on table12.id = lineitem.l_orderkey and table12.id > 10) b " + - "left outer join (select table12.id from table12 where table12.id > 10) b " + + "left outer join (" + + "select table12.id from table12 inner join lineitem on table12.id = lineitem.l_orderkey and table12.id > 10) b " + "on a.id = b.id order by a.id"); String expected = "id,id\n" + @@ -397,8 +395,8 @@ public final void testLeftOuterJoinWithEmptySubquery1() throws Exception { } finally { testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, ConfVars.TESTCASE_MIN_TASK_NUM.defaultVal); - executeString("DROP TABLE table11 PURGE"); - executeString("DROP TABLE table12 PURGE"); + executeString("DROP TABLE table11 PURGE").close(); + executeString("DROP TABLE table12 PURGE").close(); } } @@ -422,7 +420,8 @@ public final void testLeftOuterJoinWithEmptySubquery2() throws Exception { testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, "2"); ResultSet res = executeString("select a.id, b.id from " + - "(select table12.id from table12 inner join lineitem on table12.id = lineitem.l_orderkey and table12.id > 10) a " + + "(select table12.id, table12.name, lineitem.l_shipdate " + + "from table12 inner join lineitem on table12.id = lineitem.l_orderkey and table12.id > 10) a " + "left outer join table11 b " + "on a.id = b.id"); diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin1.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin1.sql index 069be091f6..575456f22e 100644 --- a/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin1.sql +++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin1.sql @@ -7,4 +7,5 @@ from nation, region where - n_regionkey = r_regionkey; \ No newline at end of file + n_regionkey = r_regionkey +order by n_name; \ No newline at end of file diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin2.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin2.sql index 0c6539be68..efc07b33cb 100644 --- a/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin2.sql +++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin2.sql @@ -5,4 +5,5 @@ from nation, region where - n_regionkey = r_regionkey; \ No newline at end of file + n_regionkey = r_regionkey +order by n_name; \ No newline at end of file diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin3.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin3.sql index 64959581ea..04fd25b42c 100644 --- a/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin3.sql +++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin3.sql @@ -6,4 +6,5 @@ select from nation, region where - n_regionkey = r_regionkey; \ No newline at end of file + n_regionkey = r_regionkey +order by n_name; \ No newline at end of file diff --git a/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin4.sql b/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin4.sql index d8ee6150db..777de8a32c 100644 --- a/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin4.sql +++ b/tajo-core/src/test/resources/queries/TestJoinQuery/testWhereClauseJoin4.sql @@ -5,4 +5,5 @@ select from nation, region where - n_regionkey = r_regionkey; \ No newline at end of file + n_regionkey = r_regionkey +order by n_name; \ No newline at end of file diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin1.result b/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin1.result index 5c54325ce0..5691b5068d 100644 --- a/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin1.result +++ b/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin1.result @@ -4,6 +4,7 @@ ALGERIA,AFRICA,0,0 ARGENTINA,AMERICA,1,1 BRAZIL,AMERICA,1,1 CANADA,AMERICA,1,1 +CHINA,ASIA,2,2 EGYPT,MIDDLE EAST,4,4 ETHIOPIA,AFRICA,0,0 FRANCE,EUROPE,3,3 @@ -18,10 +19,9 @@ KENYA,AFRICA,0,0 MOROCCO,AFRICA,0,0 MOZAMBIQUE,AFRICA,0,0 PERU,AMERICA,1,1 -CHINA,ASIA,2,2 ROMANIA,EUROPE,3,3 -SAUDI ARABIA,MIDDLE EAST,4,4 -VIETNAM,ASIA,2,2 RUSSIA,EUROPE,3,3 +SAUDI ARABIA,MIDDLE EAST,4,4 UNITED KINGDOM,EUROPE,3,3 -UNITED STATES,AMERICA,1,1 \ No newline at end of file +UNITED STATES,AMERICA,1,1 +VIETNAM,ASIA,2,2 \ No newline at end of file diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin2.result b/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin2.result index 178ddd6db9..c83d6d6a9d 100644 --- a/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin2.result +++ b/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin2.result @@ -4,6 +4,7 @@ ALGERIA,AFRICA ARGENTINA,AMERICA BRAZIL,AMERICA CANADA,AMERICA +CHINA,ASIA EGYPT,MIDDLE EAST ETHIOPIA,AFRICA FRANCE,EUROPE @@ -18,10 +19,9 @@ KENYA,AFRICA MOROCCO,AFRICA MOZAMBIQUE,AFRICA PERU,AMERICA -CHINA,ASIA ROMANIA,EUROPE -SAUDI ARABIA,MIDDLE EAST -VIETNAM,ASIA RUSSIA,EUROPE +SAUDI ARABIA,MIDDLE EAST UNITED KINGDOM,EUROPE -UNITED STATES,AMERICA \ No newline at end of file +UNITED STATES,AMERICA +VIETNAM,ASIA \ No newline at end of file diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin3.result b/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin3.result index 9f3123aee5..e5598188ae 100644 --- a/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin3.result +++ b/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin3.result @@ -4,6 +4,7 @@ ALGERIA,AFRICA,1,1 ARGENTINA,AMERICA,2,2 BRAZIL,AMERICA,3,2 CANADA,AMERICA,4,2 +CHINA,ASIA,19,3 EGYPT,MIDDLE EAST,5,5 ETHIOPIA,AFRICA,6,1 FRANCE,EUROPE,7,4 @@ -18,10 +19,9 @@ KENYA,AFRICA,15,1 MOROCCO,AFRICA,16,1 MOZAMBIQUE,AFRICA,17,1 PERU,AMERICA,18,2 -CHINA,ASIA,19,3 ROMANIA,EUROPE,20,4 -SAUDI ARABIA,MIDDLE EAST,21,5 -VIETNAM,ASIA,22,3 RUSSIA,EUROPE,23,4 +SAUDI ARABIA,MIDDLE EAST,21,5 UNITED KINGDOM,EUROPE,24,4 -UNITED STATES,AMERICA,25,2 \ No newline at end of file +UNITED STATES,AMERICA,25,2 +VIETNAM,ASIA,22,3 \ No newline at end of file diff --git a/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin4.result b/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin4.result index b7f95a8db4..90df873cf4 100644 --- a/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin4.result +++ b/tajo-core/src/test/resources/results/TestJoinQuery/testWhereClauseJoin4.result @@ -4,6 +4,7 @@ ALGERIA,AFRICA,0 ARGENTINA,AMERICA,2 BRAZIL,AMERICA,3 CANADA,AMERICA,4 +CHINA,ASIA,20 EGYPT,MIDDLE EAST,8 ETHIOPIA,AFRICA,5 FRANCE,EUROPE,9 @@ -18,10 +19,9 @@ KENYA,AFRICA,14 MOROCCO,AFRICA,15 MOZAMBIQUE,AFRICA,16 PERU,AMERICA,18 -CHINA,ASIA,20 ROMANIA,EUROPE,22 -SAUDI ARABIA,MIDDLE EAST,24 -VIETNAM,ASIA,23 RUSSIA,EUROPE,25 +SAUDI ARABIA,MIDDLE EAST,24 UNITED KINGDOM,EUROPE,26 -UNITED STATES,AMERICA,25 \ No newline at end of file +UNITED STATES,AMERICA,25 +VIETNAM,ASIA,23 \ No newline at end of file