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

CTAS, order by and flatten of repeated list result in ExpandConversionRule error

    Details

      Description

      git.commit.id.abbrev=f066786

      The below query results in an error :

      create table dfs.ctas_flatten.`test` as select uid, flatten(lst_lst) lst, flatten(lst_lst[0]) from `data1.json` order by flatten(lst_lst[0]);
      Query failed: IndexOutOfBoundsException: index (2) must be less than size (2)
      
      Error: exception while executing query: Failure while executing query. (state=,code=0)
      

      The logs indicate an assertion error :

       Caused by: java.lang.AssertionError: Internal error: Error while applying rule ExpandConversionRule, args [rel#1757858:AbstractConverter.PHYSICAL.SINGLETON([]).[2](child=rel#1757856:Subset#8.PHYSICAL.ANY([]).[2],convention=PHYSICAL,DrillDistributionTraitDef=SINGLETON([]),sort=[2])]
      

      The query itself does not have any issues. Also the below variants work :

      1. No flatten of repeated list in the select clause
      create table dfs.ctas_flatten.`test` as select uid, flatten(lst_lst[0]) from `data1.json` order by flatten(lst_lst[0]);
      2. Removing the flatten from the order by. (Ordering by a scalar has no issues) 
      create table dfs.ctas_flatten.`test` as select uid, flatten(lst_lst) lst, flatten(lst_lst[0]) from `data1.json`;
      

      Attached the data set and the complete error log file

        Attachments

        1. data.json
          4 kB
          Rahul Challapalli
        2. error.log
          8 kB
          Rahul Challapalli

          Activity

            People

            • Assignee:
              jni Jinfeng Ni
              Reporter:
              rkins Rahul Challapalli
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: