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

Validator should derive type of expression in ORDER BY

    Details

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

      Description

      SqlValidator.expandOrderExpr() does not validate node type and properly set it. Queries like the following currently fail in SqlToRelConverter because the type in thought to be unknown. Simple fix is to ensure that the type is validated when we expand the expression.

      java.lang.AssertionError: Parsing failed throwing error: class org.apache.calcite.sql.SqlBasicCall: ROW_NUMBER() OVER (PARTITION BY `employee`.`store_id` ORDER BY `employee`.`department_id` ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
      
      	at org.junit.Assert.fail(Assert.java:88)
      	at org.junit.Assert.assertTrue(Assert.java:41)
      	at org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.checkRel2Sql(RelToSqlConverterTest.java:58)
      	at org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.checkRel2Sql(RelToSqlConverterTest.java:63)
      	at org.apache.calcite.rel.rel2sql.RelToSqlConverterTest.testOver(RelToSqlConverterTest.java:391)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
      	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
      	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
      	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
      	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
      	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
      	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
      	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
      	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
      	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
      	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
      	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
      	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
      	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
      	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
      	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
      

        Activity

        Hide
        julianhyde Julian Hyde added a comment -

        That test is using RelToSql not SqlToRel but yes, the validator should test type when it expands. Add that query to SqlToRelConverterTest and you'll kill two birds with one stone.

        Show
        julianhyde Julian Hyde added a comment - That test is using RelToSql not SqlToRel but yes, the validator should test type when it expands. Add that query to SqlToRelConverterTest and you'll kill two birds with one stone.
        Hide
        minjikim MinJi Kim added a comment -

        Thanks for the review! I moved the test case to SqlToRelConverterTest.

        Show
        minjikim MinJi Kim added a comment - Thanks for the review! I moved the test case to SqlToRelConverterTest.
        Hide
        julianhyde Julian Hyde added a comment -
        Show
        julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/b4f28d7e . MinJi Kim , thanks for the PR!
        Hide
        jcamachorodriguez Jesus Camacho Rodriguez added a comment -

        Resolved in release 1.9.0 (2016-09-22)

        Show
        jcamachorodriguez Jesus Camacho Rodriguez added a comment - Resolved in release 1.9.0 (2016-09-22)

          People

          • Assignee:
            julianhyde Julian Hyde
            Reporter:
            minjikim MinJi Kim
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development