You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Claude Brisson (Jira)" <ji...@apache.org> on 2024/10/08 22:11:00 UTC
[jira] [Created] (CALCITE-6621) RexBuilder.makeOver() should not try to nullify a null result
Claude Brisson created CALCITE-6621:
---------------------------------------
Summary: RexBuilder.makeOver() should not try to nullify a null result
Key: CALCITE-6621
URL: https://issues.apache.org/jira/browse/CALCITE-6621
Project: Calcite
Issue Type: Bug
Components: core
Affects Versions: 1.38.0
Reporter: Claude Brisson
This is probably linked to CALCITE-6020.
In a window function that uses the nullable {{SUM}} aggregation operator, {{RexBuilder.makeOver()}} will produce the following construct:
{code:java}
CASE((COUNT($0) OVER (...), 0), SUM($0) OVER (...), null:BIGINT) {code}
which is both useless and inefficient.
Using this construct should only be done for non-nullable aggregation operators like {{SUM0}} (that's the only one I can think of).
The workaround is to inherit {{RexBuilder}} and override {{makeOver() }}as follow:
{code:java}
public RexNode makeOver(
RelDataType type,
SqlAggFunction operator,
List<RexNode> exprs,
List<RexNode> partitionKeys,
ImmutableList<RexFieldCollation> orderKeys,
RexWindowBound lowerBound,
RexWindowBound upperBound,
RexWindowExclusion exclude,
boolean rows,
boolean allowPartial,
boolean nullWhenCountZero,
boolean distinct,
boolean ignoreNulls) {
return super.makeOver(
type,
operator,
exprs,
partitionKeys,
orderKeys,
lowerBound,
upperBound,
exclude,
rows,
allowPartial,
nullWhenCountZero && operator.getKind() == SqlKind.SUM0,
distinct,
ignoreNulls
);
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)