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

Query with complex expressions in lateral and unnest fails with CannotPlanException

    XMLWordPrintableJSON

Details

    Description

      Queries like this:

      select l.name from cp.`lateraljoin/nested-customer.parquet` c,
      lateral (select u.item.i_name as name from unnest(c.orders[0].items) as u(item)) l limit 1
      

      fail with CannotPlanException:

      1:07:15.750 [2482e64c-9c2c-70b6-324e-848de16cb4c3:foreman] ERROR o.a.d.e.p.s.h.DefaultSqlHandler - Node [rel#142:Subset#8.LOGICAL.ANY([]).[]] could not be implemented; planner state:
      
      Root: rel#142:Subset#8.LOGICAL.ANY([]).[]
      Original rel:
      LogicalSort(subset=[rel#142:Subset#8.LOGICAL.ANY([]).[]], fetch=[1]): rowcount = 1.0, cumulative cost = {1.0 rows, 4.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 140
        LogicalProject(subset=[rel#139:Subset#7.NONE.ANY([]).[]], name=[$2]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 138
          LogicalCorrelate(subset=[rel#137:Subset#6.NONE.ANY([]).[]], correlation=[$cor0], joinType=[inner], requiredColumns=[{1}]): rowcount = 1.0, cumulative cost = {inf}, id = 136
            EnumerableTableScan(subset=[rel#126:Subset#0.ENUMERABLE.ANY([]).[]], table=[[cp, lateraljoin/nested-customer.parquet]]): rowcount = 100.0, cumulative cost = {100.0 rows, 101.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 9
            LogicalProject(subset=[rel#135:Subset#5.NONE.ANY([]).[]], name=[ITEM($0, 'i_name')]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 134
              LogicalProject(subset=[rel#133:Subset#4.NONE.ANY([]).[]], item=[$0]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 132
                Uncollect(subset=[rel#131:Subset#3.NONE.ANY([]).[]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 130
                  LogicalProject(subset=[rel#129:Subset#2.NONE.ANY([]).[]], EXPR$0=[ITEM(ITEM($cor0.orders, 0), 'items')]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 128
                    LogicalValues(subset=[rel#127:Subset#1.NONE.ANY([]).[0]], tuples=[[{ 0 }]]): rowcount = 1.0, cumulative cost = {1.0 rows, 1.0 cpu, 0.0 io, 0.0 network, 0.0 memory}, id = 10
      

      Due to the project from the right side of correlate, ProjectComplexRexNodeCorrelateTransposeRule cannot be applied, so later DrillUnnestRule cannot convert Uncollect with project with complex expressions to DrillUnnestRel.

      Attachments

        Issue Links

          Activity

            People

              volodymyr Vova Vysotskyi
              volodymyr Vova Vysotskyi
              Hanumath Maduri Hanumath Maduri
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: