Zoltán Borók-Nagy created IMPALA-15738:
------------------------------------------
Summary: Calcite planner: AssertionError on IN-list next to an
analytic function in the select list
Key: IMPALA-15738
URL: https://issues.apache.org/jira/browse/IMPALA-15738
Project: IMPALA
Issue Type: Bug
Components: Frontend
Affects Versions: Impala 5.0.0
Reporter: Zoltán Borók-Nagy
With PLANNER=CALCITE and FALLBACK_PLANNER=CALCITE, planning fails when the
select list has both an analytic function and a multi-value IN, OR or BETWEEN
on an integer or string column:
{code:sql}
SELECT sum(int_col) OVER (), int_col IN (1, 2) FROM functional.alltypes;
{code}
{noformat}
RuntimeException: java.lang.AssertionError: cannot convert SARG literal to
class java.math.BigDecimal
{noformat}
The original planner accepts the query.
It also fails with:
* any analytic function, e.g. {{count(1) OVER ()}} or {{row_number() OVER
(ORDER BY id)}}
* {{NOT IN}}, {{int_col = 1 OR int_col = 2}}, {{int_col BETWEEN 1 AND 2}}
* the predicate nested in another expression, e.g. {{CASE WHEN int_col IN (1,
2) THEN 1 ELSE 0 END}}
* a string column ({{string_col IN ('1', '2')}}), with "to class
java.lang.String" instead
It works with a single-value IN list, a DOUBLE column, the IN inside PARTITION
BY, or no analytic function.
Calcite simplifies these predicates to a SEARCH call with a Sarg literal.
{{ImpalaAnalyticRel.getOutputExprs()}} converts the output projects with
{{AnalyticRexVisitor}}, which does not expand SEARCH. The Sarg literal then
reaches {{RexLiteralConverter.getExpr()}}:
{noformat}
java.lang.AssertionError: cannot convert SARG literal to class
java.math.BigDecimal
at org.apache.calcite.rex.RexLiteral.getValueAs(RexLiteral.java:1244)
at
org.apache.impala.calcite.functions.RexLiteralConverter.getExpr(RexLiteralConverter.java:101)
at
org.apache.impala.calcite.rel.node.ImpalaAnalyticRel$AnalyticRexVisitor.visitLiteral(ImpalaAnalyticRel.java:676)
at
org.apache.impala.calcite.rel.node.ImpalaAnalyticRel$AnalyticRexVisitor.visitCall(ImpalaAnalyticRel.java:663)
at
org.apache.impala.calcite.rel.node.ImpalaAnalyticRel.getOutputExprs(ImpalaAnalyticRel.java:355)
at
org.apache.impala.calcite.rel.node.ImpalaAnalyticRel.getPlanNode(ImpalaAnalyticRel.java:188)
{noformat}
{{CreateExprVisitor.getExpr()}} and {{ExprConjunctsConverter}} already call
{{ImpalaRexUtil.expandSearch()}} first. The analytic output path should do the
same.
Reproduced on master a06def027a.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)