[
https://issues.apache.org/jira/browse/CALCITE-6402?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Zhen Chen resolved CALCITE-6402.
--------------------------------
Resolution: Fixed
This Jira is fixed via CALCITE-7134. I mark this as resolved.
> Aggregates implied in grouping sets have a wrong nullability at validation
> stage
> --------------------------------------------------------------------------------
>
> Key: CALCITE-6402
> URL: https://issues.apache.org/jira/browse/CALCITE-6402
> Project: Calcite
> Issue Type: Bug
> Components: core
> Affects Versions: 1.36.0
> Reporter: Claude Brisson
> Priority: Major
>
> As long as the empty set is present among the grouping sets, which is always
> the case for CUBE and ROLLAP, the (unfiltered) result will contain a row with
> the global aggregate. And on such a row, most standard aggregate functions
> are nullable (even on a non-null column, for the empty rowset).
> But the SUM function, for instance, has the following return type inference:
> {code}
> public static final SqlReturnTypeInference AGG_SUM = opBinding -> {
> final RelDataTypeFactory typeFactory = opBinding.getTypeFactory();
> final RelDataType type = typeFactory.getTypeSystem()
> .deriveSumType(typeFactory, opBinding.getOperandType(0));
> if (opBinding.getGroupCount() == 0 || opBinding.hasFilter()) {
> return typeFactory.createTypeWithNullability(type, true);
> } else {
> return type;
> }
> };
> {code}
> If the operand is not nullable, since the group count will be non-zero for a
> rollup, a cube or a grouping sets containing the empty set.
> It seems to me that the group count itself is not a sufficient information to
> determine the nullability, we may be lacking a boolean stating whether the
> empty group is implied, or the complete list of groups instead of the groups
> count.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)