[ 
https://issues.apache.org/jira/browse/CALCITE-5969?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-5969:
---------------------------------
    Description: 
{{LITERAL_AGG}} was introduced in CALCITE-4334 and seems not correctly 
serialized (see 
[discussion|https://lists.apache.org/thread/hhzw05b1h7y8ht3qpccth4yld3q2zc2o]).

Briefly, serialization call for 
{{toJson(org.apache.calcite.rel.core.AggregateCall)}} not stores 
{{org.apache.calcite.rel.core.AggregateCall#rexList}} which need for further 
correct assembly:
{code:java}
RelJsonReader#toAggCall(Map<String, Object> jsonAggCall) {
    ... cut ...
    return AggregateCall.create(aggregation, distinct, false, false,
        ImmutableList.of(), <-- empty list
        operands,
        filterOperand == null ? -1 : filterOperand,
        null, RelCollations.EMPTY, type, name);
}
{code}
So assertion is raised :
{code:java}
  private static RelDataType inferReturnType(SqlOperatorBinding opBinding) {
    // LITERAL_AGG takes one pre-operand and zero (post-)operands.
    if (opBinding.getPreOperandCount() != 1
        || opBinding.getOperandCount() != 1) {
      throw new AssertionError(); <-- brings this assertion
    }
    return opBinding.getOperandType(0);
  }
{code}

  was:
LITERAL_AGG was introduced in [1] and seems not correctly serialized, 
discussion [2]
Briefly:
serialization call for :
toJson(org.apache.calcite.rel.core.AggregateCall) not stores 
org.apache.calcite.rel.core.AggregateCall#rexList which need for further 
correct assembly:

{code:java}
RelJsonReader#toAggCall(Map<String, Object> jsonAggCall) {
    ... cut ...
    return AggregateCall.create(aggregation, distinct, false, false,
        ImmutableList.of(), <-- empty list
        operands,
        filterOperand == null ? -1 : filterOperand,
        null, RelCollations.EMPTY, type, name);
}
{code}

So assertion is raised :

{code:java}
  private static RelDataType inferReturnType(SqlOperatorBinding opBinding) {
    // LITERAL_AGG takes one pre-operand and zero (post-)operands.
    if (opBinding.getPreOperandCount() != 1
        || opBinding.getOperandCount() != 1) {
      throw new AssertionError(); <-- brings this assertion
    }
    return opBinding.getOperandType(0);
  }
{code}


[1] https://issues.apache.org/jira/browse/CALCITE-4334
[2] https://lists.apache.org/thread/hhzw05b1h7y8ht3qpccth4yld3q2zc2o


> LITERAL_AGG erroneously assembled after deserialization
> -------------------------------------------------------
>
>                 Key: CALCITE-5969
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5969
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: Evgeny Stanilovsky
>            Priority: Major
>
> {{LITERAL_AGG}} was introduced in CALCITE-4334 and seems not correctly 
> serialized (see 
> [discussion|https://lists.apache.org/thread/hhzw05b1h7y8ht3qpccth4yld3q2zc2o]).
> Briefly, serialization call for 
> {{toJson(org.apache.calcite.rel.core.AggregateCall)}} not stores 
> {{org.apache.calcite.rel.core.AggregateCall#rexList}} which need for further 
> correct assembly:
> {code:java}
> RelJsonReader#toAggCall(Map<String, Object> jsonAggCall) {
>     ... cut ...
>     return AggregateCall.create(aggregation, distinct, false, false,
>         ImmutableList.of(), <-- empty list
>         operands,
>         filterOperand == null ? -1 : filterOperand,
>         null, RelCollations.EMPTY, type, name);
> }
> {code}
> So assertion is raised :
> {code:java}
>   private static RelDataType inferReturnType(SqlOperatorBinding opBinding) {
>     // LITERAL_AGG takes one pre-operand and zero (post-)operands.
>     if (opBinding.getPreOperandCount() != 1
>         || opBinding.getOperandCount() != 1) {
>       throw new AssertionError(); <-- brings this assertion
>     }
>     return opBinding.getOperandType(0);
>   }
> {code}



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

Reply via email to