Fang-Yu Rao created IMPALA-15822:
------------------------------------
Summary: IllegalArgumentException thrown when a column is involved
in COUNT(*) OVER
Key: IMPALA-15822
URL: https://issues.apache.org/jira/browse/IMPALA-15822
Project: IMPALA
Issue Type: Bug
Components: Frontend
Reporter: Fang-Yu Rao
The following is not currently supported by the Calcite planner in Impala. This
is a query involving a window function. Not very sure if we opened a ticket to
keep track of this. The query could be found at
https://github.com/apache/impala/blob/bb5e81d/testdata/workloads/functional-query/queries/QueryTest/ranger_row_filtering.test#L178-L204.
I could reproduce the issue even when authorization is NOT enabled.
{code:sql}
SELECT id, count(*) over (partition by
case
when id > (select max(id) from functional.alltypestiny) then id
else id + 5
end) as x
from functional.alltypes t2
order by id
limit 10;
{code}
The stack trace is as follows.
{code}
I20261117 09:50:22.870277 1443295 LogUtil.java:47]
6c462a5b87cda7fa:8ab80bd500000000] [Plan after conversion from Abstract Syntax
Tree]
LogicalSort(sort0=[$0], dir0=[ASC], fetch=[10:TINYINT]), id = 241
LogicalProject(ID=[$0], X=[COUNT() OVER (PARTITION BY CASE(>($0,
$SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[MAX($0)])
LogicalProject(id=[$0])
LogicalTableScan(table=[[functional, alltypestiny]])
})), CAST($0):BIGINT, +($0, 5:TINYINT)))]), id = 240
LogicalTableScan(table=[[functional, alltypes]]), id = 233
I20261117 09:50:22.871526 1443295 Frontend.java:2571]
6c462a5b87cda7fa:8ab80bd500000000] CalcitePlanner planner failed: class
java.lang.IllegalArgumentException
I20261117 09:50:22.874279 1443295 jni-util.cc:335]
6c462a5b87cda7fa:8ab80bd500000000] java.lang.RuntimeException:
java.lang.IllegalArgumentException: not found: $SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[MAX($0)])
LogicalProject(id=[$0])
LogicalTableScan(table=[[functional, alltypestiny]])
})
at
org.apache.impala.service.Frontend.getTExecRequestWithFallback(Frontend.java:2587)
at
org.apache.impala.service.Frontend.createExecRequest(Frontend.java:2215)
at
org.apache.impala.service.JniFrontend.createExecRequest(JniFrontend.java:201)
Caused by: java.lang.IllegalArgumentException: not found: $SCALAR_QUERY({
LogicalAggregate(group=[{}], EXPR$0=[MAX($0)])
LogicalProject(id=[$0])
LogicalTableScan(table=[[functional, alltypestiny]])
})
at org.apache.calcite.rex.LogicVisitor.find(LogicVisitor.java:69)
at
org.apache.calcite.rel.rules.SubQueryRemoveRule.matchProject(SubQueryRemoveRule.java:970)
at
org.apache.calcite.rel.rules.SubQueryRemoveRule.access$400(SubQueryRemoveRule.java:82)
at
org.apache.calcite.rel.rules.SubQueryRemoveRule$Config.lambda$static$0(SubQueryRemoveRule.java:1351)
at
org.apache.calcite.rel.rules.SubQueryRemoveRule.onMatch(SubQueryRemoveRule.java:93)
at
org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:380)
at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:682)
at
org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:539)
at
org.apache.calcite.plan.hep.HepPlanner.executeRuleCollection(HepPlanner.java:398)
at
org.apache.calcite.plan.hep.HepInstruction$RuleCollection$State.execute(HepInstruction.java:105)
at
org.apache.calcite.plan.hep.HepPlanner.lambda$executeProgram$0(HepPlanner.java:323)
at
com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
at
org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:322)
at
org.apache.calcite.plan.hep.HepProgram$State.execute(HepProgram.java:118)
at
org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:317)
at
org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:288)
at
org.apache.impala.calcite.service.CalciteRelNodeConverter.runProgram(CalciteRelNodeConverter.java:245)
at
org.apache.impala.calcite.service.CalciteRelNodeConverter.convert(CalciteRelNodeConverter.java:132)
at
org.apache.impala.calcite.service.CalciteSingleNodePlanner.createSingleNodePlan(CalciteSingleNodePlanner.java:71)
at
org.apache.impala.planner.Planner.createPlanFragments(Planner.java:147)
at org.apache.impala.planner.Planner.createPlans(Planner.java:554)
at
org.apache.impala.service.Frontend.createExecRequest(Frontend.java:2148)
at
org.apache.impala.service.Frontend.getPlannedExecRequest(Frontend.java:3674)
at
org.apache.impala.service.Frontend.doCreateExecRequest(Frontend.java:3342)
at
org.apache.impala.service.Frontend.getTExecRequest(Frontend.java:2719)
at
org.apache.impala.service.Frontend.getTExecRequestWithFallback(Frontend.java:2561)
... 2 more
{code}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)