[ 
https://issues.apache.org/jira/browse/CALCITE-6012?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-6012:
---------------------------------
    Affects Version/s: 1.35.0

> CAST($t4):JavaType(class java.lang.Object) NOT NULL causes NPE since 1.27
> -------------------------------------------------------------------------
>
>                 Key: CALCITE-6012
>                 URL: https://issues.apache.org/jira/browse/CALCITE-6012
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.27.0, 1.35.0
>            Reporter: Vladimir Sitnikov
>            Priority: Major
>
> The commit that introduced the regression is 
> https://github.com/apache/calcite/commit/e819b4611e883c54708a75f6856300462c92b8ae
> Here's UDF declaration:
> https://github.com/vlsi/mat-calcite-plugin/blob/4d4aa2284eeec69bc51da0c2e769ded06ef9ab97/MatCalcitePlugin/src/com/github/vlsi/mat/calcite/schema/objects/HeapOperatorTable.java#L24-L36
> Problematic stacktrace is below.
> Frankly speaking, it is strange to see scaleIntervalToNumber in the 
> stacktrace as the types have nothing to do with intervals.
> {noformat}
> Caused by: java.lang.IllegalStateException: Unable to implement 
> EnumerableAggregate(group=[{}], retained_size=[SUM($0)]): rowcount = 8.0, 
> cumulative cost = {169.10000038146973 rows, 721.0 cpu, 0.0 io}, id = 52
>   EnumerableCalc(expr#0=[{inputs}], expr#1=[0], expr#2=[GET_SNAPSHOT($t1)], 
> expr#3=[GET_IOBJECT($t2, $t0)], expr#4=[TO_HEAP_REFERENCE($t3)], 
> expr#5=[CAST($t4):JavaType(class java.lang.Object) NOT NULL], 
> expr#6=[retainedSize($t5)], $f0=[$t6]): rowcount = 80.0, cumulative cost = 
> {160.0 rows, 721.0 cpu, 0.0 io}, id = 54
>     EnumerableTableScan(table=[[HEAP, java, util, $ids$:HashMap]]): rowcount 
> = 80.0, cumulative cost = {80.0 rows, 81.0 cpu, 0.0 io}, id = 36
>       at 
> org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:111)
>       at 
> org.apache.calcite.adapter.enumerable.EnumerableInterpretable.toBindable(EnumerableInterpretable.java:112)
>       at 
> org.apache.calcite.prepare.CalcitePrepareImpl$CalcitePreparingStmt.implement(CalcitePrepareImpl.java:1124)
>       at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:311)
>       at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:208)
>       at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:642)
>       at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:508)
>       at 
> org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:478)
>       at 
> org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:231)
>       at 
> org.apache.calcite.jdbc.CalciteConnectionImpl.prepareStatement_(CalciteConnectionImpl.java:213)
>       ... 64 more
>       Suppressed: java.lang.NullPointerException
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.scaleIntervalToNumber(RexToLixTranslator.java:936)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateCast(RexToLixTranslator.java:592)
>               at 
> org.apache.calcite.adapter.enumerable.RexImpTable$CastImplementor.implementSafe(RexImpTable.java:2481)
>               at 
> org.apache.calcite.adapter.enumerable.RexImpTable$AbstractRexCallImplementor.genValueStatement(RexImpTable.java:2937)
>               at 
> org.apache.calcite.adapter.enumerable.RexImpTable$AbstractRexCallImplementor.implement(RexImpTable.java:2902)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:1134)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:90)
>               at org.apache.calcite.rex.RexCall.accept(RexCall.java:175)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitLocalRef(RexToLixTranslator.java:1018)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitLocalRef(RexToLixTranslator.java:90)
>               at 
> org.apache.calcite.rex.RexLocalRef.accept(RexLocalRef.java:75)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.implementCallOperand(RexToLixTranslator.java:1143)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:1130)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitCall(RexToLixTranslator.java:90)
>               at org.apache.calcite.rex.RexCall.accept(RexCall.java:175)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitLocalRef(RexToLixTranslator.java:1018)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.visitLocalRef(RexToLixTranslator.java:90)
>               at 
> org.apache.calcite.rex.RexLocalRef.accept(RexLocalRef.java:75)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:237)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.translate(RexToLixTranslator.java:231)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateList(RexToLixTranslator.java:861)
>               at 
> org.apache.calcite.adapter.enumerable.RexToLixTranslator.translateProjects(RexToLixTranslator.java:198)
>               at 
> org.apache.calcite.adapter.enumerable.EnumerableCalc.implement(EnumerableCalc.java:193)
>               at 
> org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.visitChild(EnumerableRelImplementor.java:101)
>               at 
> org.apache.calcite.adapter.enumerable.EnumerableAggregate.implement(EnumerableAggregate.java:97)
>               at 
> org.apache.calcite.adapter.enumerable.EnumerableRelImplementor.implementRoot(EnumerableRelImplementor.java:108)
> {noformat}



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

Reply via email to