TAJO-899: Nested now() has different value for each task. (Hyoungjun Kim via hyunsik)
Closes #52 Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/0953d715 Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/0953d715 Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/0953d715 Branch: refs/heads/window_function Commit: 0953d7154753d2326ec1fb230d517e3a2aa83f69 Parents: f5e9999 Author: Hyunsik Choi <[email protected]> Authored: Thu Jul 3 22:36:09 2014 +0900 Committer: Hyunsik Choi <[email protected]> Committed: Thu Jul 3 22:36:38 2014 +0900 ---------------------------------------------------------------------- .../apache/tajo/engine/eval/AlgebraicUtil.java | 1 + .../tajo/engine/query/TestSelectQuery.java | 56 ++++++++++++++++++++ 2 files changed, 57 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/0953d715/tajo-core/src/main/java/org/apache/tajo/engine/eval/AlgebraicUtil.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/eval/AlgebraicUtil.java b/tajo-core/src/main/java/org/apache/tajo/engine/eval/AlgebraicUtil.java index c04e74f..d993b27 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/eval/AlgebraicUtil.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/eval/AlgebraicUtil.java @@ -175,6 +175,7 @@ public class AlgebraicUtil { constant = false; } else { for (EvalNode arg : evalNode.getArgs()) { + arg = visit(context, arg, stack); constant &= (arg.getType() == EvalType.CONST); } } http://git-wip-us.apache.org/repos/asf/tajo/blob/0953d715/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java index 372c595..639c3ef 100644 --- a/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java +++ b/tajo-core/src/test/java/org/apache/tajo/engine/query/TestSelectQuery.java @@ -24,10 +24,15 @@ import org.apache.tajo.TajoConstants; import org.apache.tajo.TajoProtos.QueryState; import org.apache.tajo.TajoTestingCluster; import org.apache.tajo.catalog.CatalogService; +import org.apache.tajo.catalog.Schema; import org.apache.tajo.catalog.TableDesc; import org.apache.tajo.client.QueryStatus; +import org.apache.tajo.common.TajoDataTypes.Type; +import org.apache.tajo.conf.TajoConf.ConfVars; import org.apache.tajo.engine.utils.test.ErrorInjectionRewriter; import org.apache.tajo.jdbc.TajoResultSet; +import org.apache.tajo.storage.StorageConstants; +import org.apache.tajo.util.KeyValueSet; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -387,4 +392,55 @@ public class TestSelectQuery extends QueryTestCaseBase { testingCluster.setAllWorkersConfValue("tajo.plan.rewriter.classes", ""); } } + + @Test + public final void testNowInMultipleTasks() throws Exception { + 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); + + try { + testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, "2"); + + ResultSet res = executeString("select concat(substr(to_char(now(),'yyyymmddhh24miss'), 1, 14), 'aaa'), sleep(1) from table11"); + + String nowValue = null; + int numRecords = 0; + while (res.next()) { + String currentNowValue = res.getString(1); + if (nowValue != null) { + assertTrue(nowValue.equals(currentNowValue)); + } + nowValue = currentNowValue; + numRecords++; + } + assertEquals(5, numRecords); + + res.close(); + + res = executeString("select concat(substr(to_char(current_timestamp,'yyyymmddhh24miss'), 1, 14), 'aaa'), sleep(1) from table11"); + + nowValue = null; + numRecords = 0; + while (res.next()) { + String currentNowValue = res.getString(1); + if (nowValue != null) { + assertTrue(nowValue.equals(currentNowValue)); + } + nowValue = currentNowValue; + numRecords++; + } + assertEquals(5, numRecords); + } finally { + testingCluster.setAllTajoDaemonConfValue(ConfVars.TESTCASE_MIN_TASK_NUM.varname, + ConfVars.TESTCASE_MIN_TASK_NUM.defaultVal); + executeString("DROP TABLE table11 PURGE"); + } + } } \ No newline at end of file
