Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-5967

UnsupportedOperationException while implementing a call that requires a special collator

    XMLWordPrintableJSON

Details

    Description

      Regression introduced by a minor change within CALCITE-5914, detected while testing a downstream project with the latest Calcite main.

      CALCITE-5914 (see 2a96512c) introduced this apparently innocuous change in RexImpTable#AbstractRexCallImplementor#unboxIfNecessary:

      // old
      argValueList.stream()
                  .map(AbstractRexCallImplementor::unboxExpression)
                  .collect(Collectors.toList());
      =>
      // new
      Util.transform(argValueList,
                  AbstractRexCallImplementor::unboxExpression);
      

      Both expressions seem equivalent, however there is a subtle difference: the old one returns an ArrayList (where we can add new elements); whereas the new one returns a TransformingList that extends AbstractList and that does not support List#add.

      After calling unboxIfNecessary, we might need to modify the argument list if we need a special collator to perform the operation:

          private ParameterExpression genValueStatement(...) {
            ...
            optimizedArgValueList = unboxIfNecessary(optimizedArgValueList);
      
            final Expression callValue =
                implementSafe(translator, call, optimizedArgValueList);
            ...
          }
      
          @Override Expression implementSafe(...) {
            ...
            final Expression fieldComparator =
                generateCollatorExpression(relDataType0.getCollation());
            if (fieldComparator != null) {
              argValueList.add(fieldComparator);  // <--- UnsupportedOperationException!
            }
            ...
      

      Attachments

        Issue Links

          Activity

            People

              rubenql Ruben Q L
              rubenql Ruben Q L
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: