Steven Talbot created CALCITE-5856:
--------------------------------------

             Summary: ARG0_NULLABLE_IF_EMPTY should consider GROUPING SETS (.., 
())
                 Key: CALCITE-5856
                 URL: https://issues.apache.org/jira/browse/CALCITE-5856
             Project: Calcite
          Issue Type: Bug
            Reporter: Steven Talbot


Currently, the rule switches off getGroupCount to determine if an aggregation 
is empty. However, "select sum(1) as s from empty group by grouping sets((a), 
())" will return null, but getGroupCount() will return non-zero, so the return 
type for an operator using ARG0_NULLABLE_IF_EMPTY will incorrectly be marked as 
non-nullable (if the input was non-nullable).

 

As a practical matter, this mostly matters if you try to rewrite GROUPING SETS 
to some kind of UNION, at which point the branch of the UNION on the "()" 
grouping set _will_ infer nullable using this strategy, and the type of your 
rewritten RelNode will no longer match.



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

Reply via email to