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

Window functions throws exception without ORDER BY

    Details

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

      Description

      Specifiying a window without a order by gives me this exception:

      {
      "level" : "ERROR",
      "message" : {
      "messagePattern" : "Error {}: {}",
      "arguments" : [ "4b6de09d-6550-4e18-b457-46acdaa44b9b", "Failure
      while parsing sql." ]
      },
      "logger" : "org.apache.drill.exec.work.foreman.Foreman",
      "throwable" : {
      "name" : "java.lang.NullPointerException",
      "stackTrace" : [

      { "className" : "org.eigenbase.sql.SqlIdentifier", "methodName" : "getMonotonicity", "fileName" : "SqlIdentifier.java", "lineNumber" : 263, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.SelectScope", "methodName" : "getMonotonicity", "fileName" : "SelectScope.java", "lineNumber" : 149, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.SqlWindow", "methodName" : "isTableSorted", "fileName" : "SqlWindow.java", "lineNumber" : 323, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.SqlWindow", "methodName" : "validate", "fileName" : "SqlWindow.java", "lineNumber" : 693, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.SqlNodeList", "methodName" : "validate", "fileName" : "SqlNodeList.java", "lineNumber" : 144, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.SqlValidatorImpl", "methodName" : "validateWindowClause", "fileName" : "SqlValidatorImpl.java", "lineNumber" : 2820, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.SqlValidatorImpl", "methodName" : "validateSelect", "fileName" : "SqlValidatorImpl.java", "lineNumber" : 2767, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.SelectNamespace", "methodName" : "validateImpl", "fileName" : "SelectNamespace.java", "lineNumber" : 60, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.AbstractNamespace", "methodName" : "validate", "fileName" : "AbstractNamespace.java", "lineNumber" : 80, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.SqlValidatorImpl", "methodName" : "validateNamespace", "fileName" : "SqlValidatorImpl.java", "lineNumber" : 747, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.SqlValidatorImpl", "methodName" : "validateQuery", "fileName" : "SqlValidatorImpl.java", "lineNumber" : 736, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.SqlSelect", "methodName" : "validate", "fileName" : "SqlSelect.java", "lineNumber" : 209, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.SqlValidatorImpl", "methodName" : "validateScopedExpression", "fileName" : "SqlValidatorImpl.java", "lineNumber" : 710, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "org.eigenbase.sql.validate.SqlValidatorImpl", "methodName" : "validate", "fileName" : "SqlValidatorImpl.java", "lineNumber" : 426, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      ,

      { "className" : "net.hydromatic.optiq.prepare.PlannerImpl", "methodName" : "validate", "fileName" : "PlannerImpl.java", "lineNumber" : 175, "codeLocation" : "optiq-core-0.7-SNAPSHOT.jar", "version" : "na", "exact" : false }

      }

      ---------------- Imported from GitHub ----------------
      Url: https://github.com/julianhyde/optiq/issues/285
      Created by: tnachen
      Labels:
      Created at: Mon May 19 07:24:32 CEST 2014
      State: closed

        Activity

        Hide
        github-import GitHub Import added a comment -

        [Date: Mon May 19 08:49:36 CEST 2014, Author: julianhyde]

        What is your test case?

        Show
        github-import GitHub Import added a comment - [Date: Mon May 19 08:49:36 CEST 2014, Author: julianhyde ] What is your test case?
        Hide
        github-import GitHub Import added a comment -

        [Date: Mon May 19 11:18:39 CEST 2014, Author: tnachen]

        Basically a HepPlanner with WindowAggSplitterRule, and passing in a parsed SqlNode from any query with a empty ORDER BY clause, ie:

        select sum(a1) over w from a window w as (partition by a1);

        I saw you added a test case, does the test case pass for you?

        Show
        github-import GitHub Import added a comment - [Date: Mon May 19 11:18:39 CEST 2014, Author: tnachen ] Basically a HepPlanner with WindowAggSplitterRule, and passing in a parsed SqlNode from any query with a empty ORDER BY clause, ie: select sum(a1) over w from a window w as (partition by a1); I saw you added a test case, does the test case pass for you?
        Hide
        github-import GitHub Import added a comment -

        [Date: Mon May 19 23:30:35 CEST 2014, Author: julianhyde]

        Thanks for logging this. Next time if it is reproducible via SQL please include the SQL in the issue, include a standard-format Java stack.

        If you don't log the SQL I am tempted to think you can only reproduce by calling the API and maybe you're running with assertions disabled and have done something stupid. In other words, if it's simple, make it look simple.

        Show
        github-import GitHub Import added a comment - [Date: Mon May 19 23:30:35 CEST 2014, Author: julianhyde ] Thanks for logging this. Next time if it is reproducible via SQL please include the SQL in the issue, include a standard-format Java stack. If you don't log the SQL I am tempted to think you can only reproduce by calling the API and maybe you're running with assertions disabled and have done something stupid. In other words, if it's simple, make it look simple.
        Hide
        github-import GitHub Import added a comment -

        [Date: Tue May 20 01:11:34 CEST 2014, Author: tnachen]

        Got it! Will definitely add the SQL example next time.

        Show
        github-import GitHub Import added a comment - [Date: Tue May 20 01:11:34 CEST 2014, Author: tnachen ] Got it! Will definitely add the SQL example next time.
        Hide
        github-import GitHub Import added a comment -
        Show
        github-import GitHub Import added a comment - [Date: Thu May 22 09:59:05 CEST 2014, Author: julianhyde ] Fixed in https://github.com/julianhyde/optiq/commit/8ec7ef88c04231f8546c9734a2b35091ad471660 .

          People

          • Assignee:
            Unassigned
            Reporter:
            github-import GitHub Import
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development