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

Validator rejects valid "WITH ... ORDER BY" query

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.0-incubating
    • Component/s: None
    • Labels:
      None

      Description

      The validator rejects a valid "WITH ... ORDER BY" query, giving the error "Aggregate expression is illegal in ORDER BY clause of non-aggregating SELECT". Example:

      with q as (select * from emp)
      select count(*) from q group by deptno order by count(*)
      

      The validator is doing a rewrite on the SqlOrderBy and is adding a wrapper SqlSelect. But its result, "select * from (...) order by count( * )" is not valid. We should instead generate "select * from (...) order by 1".

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        Close issues resolved in release 0.9.0-incubating (2014-08-25).

        Show
        julianhyde Julian Hyde added a comment - Close issues resolved in release 0.9.0-incubating (2014-08-25).
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/incubator-optiq/commit/3b2eeb76 .

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            julianhyde Julian Hyde
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development