Vladimir Sitnikov created CALCITE-6019:
------------------------------------------
Summary: Excessive cast when UDF receives nullable JavaType
Key: CALCITE-6019
URL: https://issues.apache.org/jira/browse/CALCITE-6019
Project: Calcite
Issue Type: Bug
Components: core
Reporter: Vladimir Sitnikov
See CALCITE-6018, however, CALCITE-6018 is about the "ability to declare
nullable, non-optional parameter" while this issue is about the excessive NOT
NULL cast.
Just in case, adding {{@Strict}} to {{retainedSize}} does not make CAST go away.
It causes weird "cast(... NOT NULL)" even though my {{retainedSize}} function
processes null just fine.
{noformat}
expr#4=[TO_HEAP_REFERENCE($t3)],
expr#5=[CAST($t4):JavaType(class java.lang.Object) NOT NULL],
expr#6=[retainedSize($t5)],
{noformat}
{{TO_HEAP_REFERENCE}} returns nullable {{HeapReference}} (Java class):
[https://github.com/vlsi/mat-calcite-plugin/blob/4d4aa2284eeec69bc51da0c2e769ded06ef9ab97/MatCalcitePlugin/src/com/github/vlsi/mat/calcite/schema/objects/HeapOperatorTable.java#L27-L28]
{{retainedSize}} receives a single (nullable) {{Object}} parameter, and it is
declared as
[https://github.com/vlsi/mat-calcite-plugin/blob/4d4aa2284eeec69bc51da0c2e769ded06ef9ab97/MatCalcitePlugin/src/com/github/vlsi/mat/calcite/functions/HeapFunctions.java#L129]
I tried adding {{@Parameter(optional=true)}} to {{{}retainedSize{}}}, and it
does not eliminate {{NOT NULL}} part of the cast.
My expectation is that NOT NULL must not be there as both return type and the
parameter type are nullable. It might be cast should not be there as well.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)