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

Scalar subquery in scalar subquery generates plan that will not compile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.32.0
    • None

    Description

      Scalar subquery in scalar subquery generates plan that will not compile. Example:

      > select (select (1, 2));
      Error: Error while executing SQL "select (select (1, 2))": Error while compiling generated Java code:
        ...
      
        public static class Record2_3 implements java.io.Serializable {
          public boolean f0;
          public Object[] f1;
          ...
        }
      
          java.util.List accumulatorAdders = new java.util.LinkedList();
          accumulatorAdders.add(new org.apache.calcite.linq4j.function.Function2() {
                                  public Record2_3 apply(Record2_3 acc, Record2_1 in) {
                                    if (acc.f0) {
                                      throw new IllegalStateException(
                                          "more than one value in agg SINGLE_VALUE");
                                    }
                                    acc.f0 = true;
                                    acc.f1 = in;
                                    return acc;
                                  }
                                  public Record2_3 apply(Object acc, Object in) {
                                    return apply(
                                        (Record2_3) acc,
                                        (Record2_1) in);
                                  }
                                }
          );
          ...
      

      Note the line acc.f1 = in; is attempting to assign a Record2_1 value to a Object[] field.

      Attachments

        Issue Links

          Activity

            People

              libenchao Benchao Li
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m