TAJO-805: Multiple constant in selection emits some columns. (Hyoungjun Kim via hyunsik)
Project: http://git-wip-us.apache.org/repos/asf/tajo/repo Commit: http://git-wip-us.apache.org/repos/asf/tajo/commit/064f18c2 Tree: http://git-wip-us.apache.org/repos/asf/tajo/tree/064f18c2 Diff: http://git-wip-us.apache.org/repos/asf/tajo/diff/064f18c2 Branch: refs/heads/window_function Commit: 064f18c2d41905604086e3f29783169d7e3d2dda Parents: 0fb823b Author: Hyunsik Choi <[email protected]> Authored: Wed Apr 30 03:53:58 2014 +0900 Committer: Hyunsik Choi <[email protected]> Committed: Wed Apr 30 03:55:29 2014 +0900 ---------------------------------------------------------------------- CHANGES | 3 +++ .../org/apache/tajo/engine/planner/NamedExprsManager.java | 2 +- .../java/org/apache/tajo/engine/query/TestSelectQuery.java | 9 +++++++++ .../testSelectSameConstantsWithDifferentAliases2.sql | 1 + .../testSelectSameConstantsWithDifferentAliases2.result | 7 +++++++ 5 files changed, 21 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tajo/blob/064f18c2/CHANGES ---------------------------------------------------------------------- diff --git a/CHANGES b/CHANGES index cbfc292..689d93d 100644 --- a/CHANGES +++ b/CHANGES @@ -19,6 +19,9 @@ Release 0.9.0 - unreleased BUG FIXES + TAJO-805: Multiple constant in selection emits some columns. + (Hyoungjun Kim via hyunsik) + TAJO-799: Local query without FROM throws IllegalArgumentException in CLI. (Hyoungjun Kim via hyunsik) http://git-wip-us.apache.org/repos/asf/tajo/blob/064f18c2/tajo-core/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java ---------------------------------------------------------------------- diff --git a/tajo-core/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java b/tajo-core/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java index 2fcf3bc..710dad8 100644 --- a/tajo-core/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java +++ b/tajo-core/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java @@ -300,7 +300,7 @@ public class NamedExprsManager { // If the expression is already evaluated, it should use the FieldEval to access a field value. // But, if this reference name is not primary name, it cannot use the reference name. // It changes the given reference name to the primary name. - if (isEvaluated(normalized) && !isPrimaryName(refId, referenceName)) { + if (evalNode.getType() != EvalType.CONST && isEvaluated(normalized) && !isPrimaryName(refId, referenceName)) { return new Target(new FieldEval(getPrimaryName(refId),evalNode.getValueType()), referenceName); } http://git-wip-us.apache.org/repos/asf/tajo/blob/064f18c2/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 ca452b7..37a748c 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 @@ -113,6 +113,15 @@ public class TestSelectQuery extends QueryTestCaseBase { } @Test + public final void testSelectSameConstantsWithDifferentAliases2() throws Exception { + // select l_orderkey, '20130819' as date1, '20130819' as date2, '20130819' as date3, '20130819' as date4 + // from lineitem where l_orderkey > -1; + ResultSet res = executeQuery(); + assertResultSet(res); + cleanupQuery(res); + } + + @Test public final void testSelectSameExprsWithDifferentAliases() throws Exception { // select l_orderkey, l_partkey + 1 as plus1, l_partkey + 1 as plus2 from lineitem where l_orderkey > -1; ResultSet res = executeQuery(); http://git-wip-us.apache.org/repos/asf/tajo/blob/064f18c2/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectSameConstantsWithDifferentAliases2.sql ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectSameConstantsWithDifferentAliases2.sql b/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectSameConstantsWithDifferentAliases2.sql new file mode 100644 index 0000000..fecabd5 --- /dev/null +++ b/tajo-core/src/test/resources/queries/TestSelectQuery/testSelectSameConstantsWithDifferentAliases2.sql @@ -0,0 +1 @@ +select l_orderkey, '20130819' as date1, '20130819' as date2, '20130819' as date3, '20130819' as date4 from lineitem where l_orderkey > -1; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/tajo/blob/064f18c2/tajo-core/src/test/resources/results/TestSelectQuery/testSelectSameConstantsWithDifferentAliases2.result ---------------------------------------------------------------------- diff --git a/tajo-core/src/test/resources/results/TestSelectQuery/testSelectSameConstantsWithDifferentAliases2.result b/tajo-core/src/test/resources/results/TestSelectQuery/testSelectSameConstantsWithDifferentAliases2.result new file mode 100644 index 0000000..2e18463 --- /dev/null +++ b/tajo-core/src/test/resources/results/TestSelectQuery/testSelectSameConstantsWithDifferentAliases2.result @@ -0,0 +1,7 @@ +l_orderkey,date1,date2,date3,date4 +------------------------------- +1,20130819,20130819,20130819,20130819 +1,20130819,20130819,20130819,20130819 +2,20130819,20130819,20130819,20130819 +3,20130819,20130819,20130819,20130819 +3,20130819,20130819,20130819,20130819 \ No newline at end of file
