[ 
https://issues.apache.org/jira/browse/IMPALA-14222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18028430#comment-18028430
 ] 

Steve Carlin commented on IMPALA-14222:
---------------------------------------

The problem was triggered by the duplicate grouping set.  The resulting plan 
creates a LogicalUnion which has 2 different Aggregates.  One of the aggregates 
contained the group by statement with the singular duplicate grouping set, 
which did not represent all the groups in the group by. 

Fix was fairly straightforward, it just needs to handle the null value for the 
group.

One interesting finding is that the original Impala planner is producing 
incorrect results as declared by the SQL standard.  IMPALA-14483 has been filed 
for this.

> Calcite Planner: throw NullPointerException in 
> ImpalaAggRel.createMappedOutputExprs
> -----------------------------------------------------------------------------------
>
>                 Key: IMPALA-14222
>                 URL: https://issues.apache.org/jira/browse/IMPALA-14222
>             Project: IMPALA
>          Issue Type: Sub-task
>            Reporter: weihua zhang
>            Assignee: Steve Carlin
>            Priority: Major
>
> {code:sql}
> create database scott;
> use scott;
> CREATE TABLE dept(
>     deptno INT,    
>     dname string,
>     loc string
> );
> CREATE TABLE emp(
>     empno INT ,
>     ename string,
>     job string,
>     age INT,
>     mgr INT,
>     hiredate DATE,
>     sal double,    
>     comm double,
>     deptno INT,
>     email string,
>     create_datetime TIMESTAMP,  
>     upsert_time TIMESTAMP
> );
> select sum(sal) as s
> from emp
> group by grouping sets ((job, deptno, comm is null),
>   (job, deptno), (job, comm is null), (job, comm is null));
> {code}
> {noformat}
> I20250713 15:55:27.214679 784602 jni-util.cc:321] 
> c3448981f4ca7a24:e9b7764300000000] java.lang.NullPointerException
>       at 
> com.google.common.base.Preconditions.checkNotNull(Preconditions.java:903)
>       at 
> org.apache.impala.calcite.rel.node.ImpalaAggRel.createMappedOutputExprs(ImpalaAggRel.java:410)
>       at 
> org.apache.impala.calcite.rel.node.ImpalaAggRel.getPlanNode(ImpalaAggRel.java:135)
>       at 
> org.apache.impala.calcite.rel.node.ImpalaUnionRel.getChildrenPlanNodes(ImpalaUnionRel.java:80)
>       at 
> org.apache.impala.calcite.rel.node.ImpalaUnionRel.getPlanNode(ImpalaUnionRel.java:61)
>       at 
> org.apache.impala.calcite.rel.node.ImpalaProjectRel.getChildPlanNode(ImpalaProjectRel.java:140)
>       at 
> org.apache.impala.calcite.rel.node.ImpalaProjectRel.getPlanNode(ImpalaProjectRel.java:79)
>       at 
> org.apache.impala.calcite.service.CalcitePhysPlanCreator.create(CalcitePhysPlanCreator.java:71)
>       at 
> org.apache.impala.calcite.service.CalciteSingleNodePlanner.createSingleNodePlan(CalciteSingleNodePlanner.java:74)
>       at 
> org.apache.impala.planner.Planner.createPlanFragments(Planner.java:137)
>       at org.apache.impala.planner.Planner.createPlans(Planner.java:312)
>       at 
> org.apache.impala.service.Frontend.createExecRequest(Frontend.java:1994)
>       at 
> org.apache.impala.service.Frontend.getPlannedExecRequest(Frontend.java:3314)
>       at 
> org.apache.impala.service.Frontend.doCreateExecRequest(Frontend.java:3088)
>       at 
> org.apache.impala.service.Frontend.getTExecRequest(Frontend.java:2501)
>       at 
> org.apache.impala.service.Frontend.getTExecRequestWithFallback(Frontend.java:2356)
>       at 
> org.apache.impala.service.Frontend.createExecRequest(Frontend.java:2059)
>       at 
> org.apache.impala.service.JniFrontend.createExecRequest(JniFrontend.java:176)
> {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to