[
https://issues.apache.org/jira/browse/CALCITE-6018?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767390#comment-17767390
]
Vladimir Sitnikov commented on CALCITE-6018:
--------------------------------------------
Just in case, {{@Parameter(optional=true}} does make
{{ScalarFunctionImpl.functions}} produce function with "nullable (and
optional)" parameter. So it looks like the artificial cast is yet another issue.
> Support nullable parameters in UDFs
> -----------------------------------
>
> Key: CALCITE-6018
> URL: https://issues.apache.org/jira/browse/CALCITE-6018
> Project: Calcite
> Issue Type: Improvement
> Components: core
> Affects Versions: 1.35.0
> Reporter: Vladimir Sitnikov
> Priority: Major
>
> Currently Calcite treats almost all the parameters as non-nullable. There's
> {{@Parameter(optional=true)}}, however, it mixes "optionality" vs
> "nullability".
> It causes weird "cast(... NOT NULL)" even though my function processes null
> just fine.
> See example in CALCITE-6012.
> {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}} 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 remove the cast. It does not eliminate {{NOT NULL}} part of the cast.
> ---
> In any case, I think it is not quite right to mix nullaness and optionally
> concepts, and Calcite should inter nullness from nullability annotations.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)