Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-7396

Exception when trying to access last element of an array with repeated_count

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.16.0
    • None
    • Functions - Drill
    • None

    Description

      Use of array in drill is not friendly

      SELECT (split('a,b,c',','))[0]; /*NOK */
      Error: SYSTEM ERROR: ClassCastException: org.apache.drill.common.expression.FunctionCall cannot be cast to org.apache.drill.common.expression.SchemaPath
      
      /* outer SELECT needed*/
      SELECT x[0] FROM (SELECT split('a,b,c',',') x); /* OK */
      

      And access last element of an array is worse

      SELECT x[repeated_count(x) - 1] AS lasteltidx FROM (SELECT split('a,b,c',',') x);
      Error: SYSTEM ERROR: ClassCastException: org.apache.calcite.rex.RexCall cannot be cast to org.apache.calcite.rex.RexLiteral
      
      /* while */
      SELECT x[2] lastelt, (repeated_count(x) - 1) AS lasteltidx FROM (SELECT split('a,b,c',',') x);
      +---------+------------+
      | lastelt | lasteltidx |
      +---------+------------+
      | c       | 2          |
      +---------+------------+
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            benj641 benj
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: