[
https://issues.apache.org/jira/browse/CALCITE-6018?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Vladimir Sitnikov updated CALCITE-6018:
---
Description:
Currently Calcite treats almost all the parameters as non-nullable. There's
{{@Parameter(optional=true)}}, however, it mixes "optionality" vs "nullability".
In other words, I would like to have nullable, non-optional parameters in UDFs.
For instance, Calcite could pick up nullness information from annotations (e.g.
`@Nullable`). For instance, Kotlin compiler generates the annotations
automatically, so I think supporting more-or-less standard tools like jspecify
and checkerframework should be preferred over Calcite-only annotations.
---
Sample usage: {{retainedSize}} is declared as
https://github.com/vlsi/mat-calcite-plugin/blob/4d4aa2284eeec69bc51da0c2e769ded06ef9ab97/MatCalcitePlugin/src/com/github/vlsi/mat/calcite/functions/HeapFunctions.java#L129,
and I want to declare that {{retainedSize}} is fine to receive {{null}}
parameter.
was:
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.
> 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".
> In other words, I would like to have nullable, non-optional parameters in
> UDFs.
> For instance, Calcite could pick up nullness information from annotations
> (e.g. `@Nullable`). For instance, Kotlin compiler generates the annotations
> automatically, so I think supporting more-or-less standard tools like
> jspecify and checkerframework should be preferred over Calcite-only
> annotations.
> ---
> Sample usage: {{retainedSize}} is declared as
> https://github.com/vlsi/mat-calcite-plugin/blob/4d4aa2284eeec69bc51da0c2e769ded06ef9ab97/MatCalcitePlugin/src/com/github/vlsi/mat/calcite/functions/HeapFunctions.java#L129,
> and I want to declare that {{retainedSize}} is fine to receive {{null}}
> parameter.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)