Uploaded image for project: 'Tajo'
  1. Tajo
  2. TAJO-716

Using column names actually aliased in aggregation functions can cause planning error.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 0.8.0, 0.9.0
    • Fix Version/s: 0.8.0, 0.9.0
    • Component/s: Planner/Optimizer
    • Labels:
      None

      Description

      The below query can cause the following error.

      select
        nation.n_nationkey as n_nationkey,
        customer.c_name as c_name,
        count(nation.n_nationkey) as cnt
      from
        nation inner join customer on n_nationkey = c_nationkey
      group by
        nation.n_nationkey,
        customer.c_name
      order by
        n_nationkey, c_name;
      
      Stack Trace:
      org.apache.tajo.engine.planner.PlanningException: Cannot expect a referenced relation: n_nationkey (INT4)
      	at org.apache.tajo.engine.planner.logical.join.JoinGraph.guessRelationsFromJoinQual(JoinGraph.java:59)
      	at org.apache.tajo.engine.planner.logical.join.JoinGraph.addJoin(JoinGraph.java:92)
      	at org.apache.tajo.engine.planner.LogicalOptimizer$JoinGraphBuilder.visitJoin(LogicalOptimizer.java:165)
      	at org.apache.tajo.engine.planner.LogicalOptimizer$JoinGraphBuilder.visitJoin(LogicalOptimizer.java:133)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visit(BasicLogicalPlanVisitor.java:81)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visitGroupBy(BasicLogicalPlanVisitor.java:176)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visit(BasicLogicalPlanVisitor.java:75)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visitSort(BasicLogicalPlanVisitor.java:158)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visit(BasicLogicalPlanVisitor.java:69)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visitProjection(BasicLogicalPlanVisitor.java:140)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visit(BasicLogicalPlanVisitor.java:63)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visitRoot(BasicLogicalPlanVisitor.java:130)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visit(BasicLogicalPlanVisitor.java:58)
      	at org.apache.tajo.engine.planner.BasicLogicalPlanVisitor.visit(BasicLogicalPlanVisitor.java:45)
      	at org.apache.tajo.engine.planner.LogicalOptimizer$JoinGraphBuilder.buildJoinGraph(LogicalOptimizer.java:148)
      	at org.apache.tajo.engine.planner.LogicalOptimizer.optimizeJoinOrder(LogicalOptimizer.java:86)
      	at org.apache.tajo.engine.planner.LogicalOptimizer.optimize(LogicalOptimizer.java:71)
      	at org.apache.tajo.master.GlobalEngine.createLogicalPlan(GlobalEngine.java:260)
      	at org.apache.tajo.master.GlobalEngine.executeQuery(GlobalEngine.java:138)
      
      1. TAJO-716.patch
        15 kB
        Hyunsik Choi

        Activity

        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Tajo-0.8.0-build #43 (See https://builds.apache.org/job/Tajo-0.8.0-build/43/)
        TAJO-716: Using column names actually aliased in aggregation functions can cause planning error. (hyunsik: rev 9161f8e23ddab66f298546c273c00fca73f26e92)

        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java
        • tajo-core/tajo-core-backend/src/test/resources/queries/TestSortQuery/testSortWithAlias3.sql
        • tajo-core/tajo-core-backend/src/test/resources/queries/TestSortQuery/testSortWithAlias2.sql
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/ExprNormalizer.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java
        • tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAscDescKeys.result
        • CHANGES.txt
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
        • tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAlias3.result
        • tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSortQuery.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java
        • tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAlias2.result
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Tajo-0.8.0-build #43 (See https://builds.apache.org/job/Tajo-0.8.0-build/43/ ) TAJO-716 : Using column names actually aliased in aggregation functions can cause planning error. (hyunsik: rev 9161f8e23ddab66f298546c273c00fca73f26e92) tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java tajo-core/tajo-core-backend/src/test/resources/queries/TestSortQuery/testSortWithAlias3.sql tajo-core/tajo-core-backend/src/test/resources/queries/TestSortQuery/testSortWithAlias2.sql tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/ExprNormalizer.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAscDescKeys.result CHANGES.txt tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAlias3.result tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSortQuery.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAlias2.result
        Hide
        hudson Hudson added a comment -

        SUCCESS: Integrated in Tajo-master-build #137 (See https://builds.apache.org/job/Tajo-master-build/137/)
        TAJO-716: Using column names actually aliased in aggregation functions can cause planning error. (hyunsik: rev b1e0e3499e2459e58b2cede4f4268ad26d3ed7d4)

        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java
        • tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAlias2.result
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java
        • tajo-core/tajo-core-backend/src/test/resources/queries/TestSortQuery/testSortWithAlias3.sql
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/ExprNormalizer.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java
        • tajo-core/tajo-core-backend/src/test/resources/queries/TestSortQuery/testSortWithAlias2.sql
        • CHANGES.txt
        • tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAlias3.result
        • tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSortQuery.java
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java
        • tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAscDescKeys.result
        • tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
        Show
        hudson Hudson added a comment - SUCCESS: Integrated in Tajo-master-build #137 (See https://builds.apache.org/job/Tajo-master-build/137/ ) TAJO-716 : Using column names actually aliased in aggregation functions can cause planning error. (hyunsik: rev b1e0e3499e2459e58b2cede4f4268ad26d3ed7d4) tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/RelationNode.java tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAlias2.result tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/LogicalPlan.java tajo-core/tajo-core-backend/src/test/resources/queries/TestSortQuery/testSortWithAlias3.sql tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/ExprNormalizer.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/NamedExprsManager.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/join/JoinGraph.java tajo-core/tajo-core-backend/src/test/resources/queries/TestSortQuery/testSortWithAlias2.sql CHANGES.txt tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAlias3.result tajo-core/tajo-core-backend/src/test/java/org/apache/tajo/engine/query/TestSortQuery.java tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/ScanNode.java tajo-core/tajo-core-backend/src/test/resources/results/TestSortQuery/testSortWithAscDescKeys.result tajo-core/tajo-core-backend/src/main/java/org/apache/tajo/engine/planner/logical/TableSubQueryNode.java
        Hide
        hyunsik Hyunsik Choi added a comment -

        committed it to master and branch-0.8.0. Thanks you for quick review.

        Show
        hyunsik Hyunsik Choi added a comment - committed it to master and branch-0.8.0. Thanks you for quick review.
        Hide
        tajoqa Tajo QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12637054/TAJO-716.patch
        against master revision e06ffa9.

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 6 new or modified test files.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 javadoc. The applied patch does not increase the total number of javadoc warnings.

        +1 checkstyle. The patch generated 0 code style errors.

        -1 findbugs. The patch appears to introduce 195 new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed unit tests in tajo-core/tajo-core-backend.

        Test results: https://builds.apache.org/job/PreCommit-TAJO-Build/269//testReport/
        Findbugs warnings: https://builds.apache.org/job/PreCommit-TAJO-Build/269//artifact/incubator-tajo/patchprocess/newPatchFindbugsWarningstajo-core-backend.html
        Console output: https://builds.apache.org/job/PreCommit-TAJO-Build/269//console

        This message is automatically generated.

        Show
        tajoqa Tajo QA added a comment - -1 overall. Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12637054/TAJO-716.patch against master revision e06ffa9. +1 @author. The patch does not contain any @author tags. +1 tests included. The patch appears to include 6 new or modified test files. +1 javac. The applied patch does not increase the total number of javac compiler warnings. +1 javadoc. The applied patch does not increase the total number of javadoc warnings. +1 checkstyle. The patch generated 0 code style errors. -1 findbugs. The patch appears to introduce 195 new Findbugs (version 1.3.9) warnings. +1 release audit. The applied patch does not increase the total number of release audit warnings. +1 core tests. The patch passed unit tests in tajo-core/tajo-core-backend. Test results: https://builds.apache.org/job/PreCommit-TAJO-Build/269//testReport/ Findbugs warnings: https://builds.apache.org/job/PreCommit-TAJO-Build/269//artifact/incubator-tajo/patchprocess/newPatchFindbugsWarningstajo-core-backend.html Console output: https://builds.apache.org/job/PreCommit-TAJO-Build/269//console This message is automatically generated.
        Hide
        sirpkt Keuntae Park added a comment -

        +1
        it works well!

        Show
        sirpkt Keuntae Park added a comment - +1 it works well!

          People

          • Assignee:
            hyunsik Hyunsik Choi
            Reporter:
            hyunsik Hyunsik Choi
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development