Enze Liu created CALCITE-4721:
---------------------------------

             Summary: SqlSelect's setOperand method cannot set `hints`, failed 
with AssertionError
                 Key: CALCITE-4721
                 URL: https://issues.apache.org/jira/browse/CALCITE-4721
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.27.0
            Reporter: Enze Liu


in SqlSelect, 

getOperandList() returns with 
{code:java}
return ImmutableNullableList.of(keywordList, selectList, from, where,
 groupBy, having, windowDecls, orderBy, offset, fetch, hints);
{code}
while we trying to setOperand() by the returned list, we have AssertionError.

seems the setOperand only set the first ten operands. 
{code:java}
  @Override public void setOperand(int i, @Nullable SqlNode operand) {
    switch (i) {
    case 0:
      keywordList = requireNonNull((SqlNodeList) operand);
      break;
    case 1:
      selectList = requireNonNull((SqlNodeList) operand);
      break;
    case 2:
      from = operand;
      break;
    case 3:
      where = operand;
      break;
    case 4:
      groupBy = (SqlNodeList) operand;
      break;
    case 5:
      having = operand;
      break;
    case 6:
      windowDecls = requireNonNull((SqlNodeList) operand);
      break;
    case 7:
      orderBy = (SqlNodeList) operand;
      break;
    case 8:
      offset = operand;
      break;
    case 9:
      fetch = operand;
      break;
    default:
      throw new AssertionError(i);
    }
  }
{code}
 

a minor modification could be:
{code:java}
  @Override public void setOperand(int i, @Nullable SqlNode operand) {
    switch (i) {
    case 0:
      keywordList = requireNonNull((SqlNodeList) operand);
      break;
    case 1:
      selectList = requireNonNull((SqlNodeList) operand);
      break;
    case 2:
      from = operand;
      break;
    case 3:
      where = operand;
      break;
    case 4:
      groupBy = (SqlNodeList) operand;
      break;
    case 5:
      having = operand;
      break;
    case 6:
      windowDecls = requireNonNull((SqlNodeList) operand);
      break;
    case 7:
      orderBy = (SqlNodeList) operand;
      break;
    case 8:
      offset = operand;
      break;
    case 9:
      fetch = operand;
      break;
    case 10: 
      hints = operand; 
      break;
    default:
      throw new AssertionError(i);
    }
  }

{code}
  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to