Vladimir Sitnikov created CALCITE-6018:
------------------------------------------

             Summary: Support nullable parameters in UDFs
                 Key: CALCITE-6018
                 URL: https://issues.apache.org/jira/browse/CALCITE-6018
             Project: Calcite
          Issue Type: Improvement
          Components: core
            Reporter: Vladimir Sitnikov


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)

Reply via email to