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

COUNT DISTINCT with other aggregation function throws ClassCastException.

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.0
    • Component/s: None
    • Labels:
      None

      Description

      I tested with the following data and query.

      default> select * from table1;
      id,code,qty
      -------------------------------
      1,a,3
      1,a,4
      1,b,5
      2,a,1
      2,c,2
      2,d,3
      
      default> select id, count(distinct code), avg(qty) from table101 group by id;
      2014-06-05 21:29:56,960 ERROR: org.apache.tajo.worker.Task (run(390)) - org.apache.tajo.datum.NullDatum cannot be cast to org.apache.tajo.datum.ProtobufDatum
      java.lang.ClassCastException: org.apache.tajo.datum.NullDatum cannot be cast to org.apache.tajo.datum.ProtobufDatum
      	at org.apache.tajo.engine.function.builtin.AvgLong.merge(AvgLong.java:66)
      	at org.apache.tajo.engine.eval.AggregationFunctionCallEval.merge(AggregationFunctionCallEval.java:59)
      	at org.apache.tajo.engine.planner.physical.SortAggregateExec.next(SortAggregateExec.java:77)
      	at org.apache.tajo.engine.planner.physical.DistinctGroupbySortAggregationExec.next(DistinctGroupbySortAggregationExec.java:88)
      	at org.apache.tajo.engine.planner.physical.StoreTableExec.next(StoreTableExec.java:77)
      	at org.apache.tajo.worker.Task.run(Task.java:382)
      	at org.apache.tajo.worker.TaskRunner$1.run(TaskRunner.java:406)
      	at java.lang.Thread.run(Thread.java:744)
      

        Activity

        Hide
        githubbot ASF GitHub Bot added a comment -

        GitHub user babokim opened a pull request:

        https://github.com/apache/tajo/pull/36

        TAJO-866: COUNT DISTINCT with other aggregation function throws ClassCastException.

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/babokim/tajo TAJO-866

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/tajo/pull/36.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #36


        commit 1807176afefb6d1f3beff5d012328e743b83e031
        Author: 김형준 <babokim@babokim-macbook-pro.local>
        Date: 2014-06-07T05:30:42Z

        TAJO-866: COUNT DISTINCT with other aggregation function throws ClassCastException.

        commit b1d0045fc6c26f3abd682f2344f75e35baef2b34
        Author: 김형준 <babokim@babokim-macbook-pro.local>
        Date: 2014-06-07T05:31:32Z

        Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/tajo


        Show
        githubbot ASF GitHub Bot added a comment - GitHub user babokim opened a pull request: https://github.com/apache/tajo/pull/36 TAJO-866 : COUNT DISTINCT with other aggregation function throws ClassCastException. You can merge this pull request into a Git repository by running: $ git pull https://github.com/babokim/tajo TAJO-866 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/tajo/pull/36.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #36 commit 1807176afefb6d1f3beff5d012328e743b83e031 Author: 김형준 <babokim@babokim-macbook-pro.local> Date: 2014-06-07T05:30:42Z TAJO-866 : COUNT DISTINCT with other aggregation function throws ClassCastException. commit b1d0045fc6c26f3abd682f2344f75e35baef2b34 Author: 김형준 <babokim@babokim-macbook-pro.local> Date: 2014-06-07T05:31:32Z Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/tajo
        Hide
        hjkim Hyoungjun Kim added a comment -

        Pull requested via the github. Please review this patch.

        Show
        hjkim Hyoungjun Kim added a comment - Pull requested via the github. Please review this patch.
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user hyunsik commented on a diff in the pull request:

        https://github.com/apache/tajo/pull/36#discussion_r13666009

        — Diff: tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/AvgDouble.java —
        @@ -64,7 +65,11 @@ public void eval(FunctionContext ctx, Tuple params) {
        @Override
        public void merge(FunctionContext ctx, Tuple part) {
        AvgContext avgCtx = (AvgContext) ctx;

        • ProtobufDatum datum = (ProtobufDatum) part.get(0);
          + Datum d = part.get(0);
            • End diff –

        Does the case occur in AvgDouble? How about other avg functions like AvgLong or AvgFloat?

        Show
        githubbot ASF GitHub Bot added a comment - Github user hyunsik commented on a diff in the pull request: https://github.com/apache/tajo/pull/36#discussion_r13666009 — Diff: tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/AvgDouble.java — @@ -64,7 +65,11 @@ public void eval(FunctionContext ctx, Tuple params) { @Override public void merge(FunctionContext ctx, Tuple part) { AvgContext avgCtx = (AvgContext) ctx; ProtobufDatum datum = (ProtobufDatum) part.get(0); + Datum d = part.get(0); End diff – Does the case occur in AvgDouble? How about other avg functions like AvgLong or AvgFloat?
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user babokim commented on a diff in the pull request:

        https://github.com/apache/tajo/pull/36#discussion_r14172492

        — Diff: tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/AvgDouble.java —
        @@ -64,7 +65,11 @@ public void eval(FunctionContext ctx, Tuple params) {
        @Override
        public void merge(FunctionContext ctx, Tuple part) {
        AvgContext avgCtx = (AvgContext) ctx;

        • ProtobufDatum datum = (ProtobufDatum) part.get(0);
          + Datum d = part.get(0);
            • End diff –

        AvgFloat extends AvgDouble. AvgLong is changed in this patch.

        Show
        githubbot ASF GitHub Bot added a comment - Github user babokim commented on a diff in the pull request: https://github.com/apache/tajo/pull/36#discussion_r14172492 — Diff: tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/AvgDouble.java — @@ -64,7 +65,11 @@ public void eval(FunctionContext ctx, Tuple params) { @Override public void merge(FunctionContext ctx, Tuple part) { AvgContext avgCtx = (AvgContext) ctx; ProtobufDatum datum = (ProtobufDatum) part.get(0); + Datum d = part.get(0); End diff – AvgFloat extends AvgDouble. AvgLong is changed in this patch.
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user hyunsik commented on the pull request:

        https://github.com/apache/tajo/pull/36#issuecomment-47070182

        +1

        thank you for the comment. You are right. I missed those facts. I'll commit it shortly.

        Show
        githubbot ASF GitHub Bot added a comment - Github user hyunsik commented on the pull request: https://github.com/apache/tajo/pull/36#issuecomment-47070182 +1 thank you for the comment. You are right. I missed those facts. I'll commit it shortly.
        Hide
        githubbot ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/tajo/pull/36

        Show
        githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/tajo/pull/36
        Hide
        hyunsik Hyunsik Choi added a comment -

        committed it to master branch. Thanks!

        Show
        hyunsik Hyunsik Choi added a comment - committed it to master branch. Thanks!
        Hide
        hudson Hudson added a comment -

        FAILURE: Integrated in Tajo-master-build #262 (See https://builds.apache.org/job/Tajo-master-build/262/)
        TAJO-866: COUNT DISTINCT with other aggregation function throws ClassCastException. (Hyoungjun Kim via hyunsik) (hyunsik: rev 26265c0609324b52f8e22bf803fddfa1413cf3a4)

        • tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/AvgLong.java
        • tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java
        • tajo-core/src/test/resources/results/TestJoinQuery/testLeftOuterJoinWithEmptyTable5.result
        • tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/AvgDouble.java
        • tajo-core/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java
        • CHANGES
        • tajo-core/src/test/resources/queries/TestJoinQuery/testLeftOuterJoinWithEmptyTable5.sql
        Show
        hudson Hudson added a comment - FAILURE: Integrated in Tajo-master-build #262 (See https://builds.apache.org/job/Tajo-master-build/262/ ) TAJO-866 : COUNT DISTINCT with other aggregation function throws ClassCastException. (Hyoungjun Kim via hyunsik) (hyunsik: rev 26265c0609324b52f8e22bf803fddfa1413cf3a4) tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/AvgLong.java tajo-core/src/test/java/org/apache/tajo/engine/query/TestJoinQuery.java tajo-core/src/test/resources/results/TestJoinQuery/testLeftOuterJoinWithEmptyTable5.result tajo-core/src/main/java/org/apache/tajo/engine/function/builtin/AvgDouble.java tajo-core/src/test/java/org/apache/tajo/engine/query/TestGroupByQuery.java CHANGES tajo-core/src/test/resources/queries/TestJoinQuery/testLeftOuterJoinWithEmptyTable5.sql

          People

          • Assignee:
            hjkim Hyoungjun Kim
            Reporter:
            hjkim Hyoungjun Kim
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development