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

Query fails when an ORDER BY clause is used with WITH-CLAUSE

    Details

      Description

      Adding a WITH clause with a simple CTE causes a query with an ORDER BY to fail. This happens even when the CTE is unrelated to the main query.

      The following query fails to execute:

      WITH 
           x
           AS (SELECT  ss_sold_date_sk a1
               FROM  store_sales) 
      SELECT  x.a1
      FROM   x
      ORDER  BY 
                x.a1;
      

      Error:
      Query failed: SqlValidatorException: Table 'x' not found

      Log attached.

      The following query executes fine:

      WITH 
           x
           AS (SELECT  ss_sold_date_sk a1
               FROM  store_sales) 
      SELECT  x.a1
      FROM   x
      

        Attachments

        1. drillbit.log
          12 kB
          Abhishek Girish

          Issue Links

            Activity

              People

              • Assignee:
                seanhychu Sean Hsuan-Yi Chu
                Reporter:
                agirish Abhishek Girish
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: