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

Invalid "Invalid literal" error for complex expression

    Details

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

      Description

      SQL:

      select 8388608/(60+27.39)
      

      When I call the

      sqlToRelConverter.convertQuery 

      convert the SqlNode to RelNode, an error as follow:

      Exception in thread "main" java.lang.AssertionError: Internal error: invalid literal: 60 + 27.39
      	at org.apache.calcite.util.Util.newInternal(Util.java:777)
      	at org.apache.calcite.sql.SqlLiteral.value(SqlLiteral.java:350)
      	at org.apache.calcite.sql.SqlCallBinding.getOperandLiteralValue(SqlCallBinding.java:219)
      	at org.apache.calcite.sql.SqlBinaryOperator.getMonotonicity(SqlBinaryOperator.java:189)
      	at org.apache.calcite.sql.SqlCall.getMonotonicity(SqlCall.java:180)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectList(SqlToRelConverter.java:3502)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:665)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:622)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:2852)
      	at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:556)
      	at org.apache.calcite.prepare.PlannerImpl.rel(PlannerImpl.java:227)
      
      

      Is this OK?

        Issue Links

          Activity

          Hide
          julianhyde Julian Hyde added a comment -

          I reproduced this:

          diff --git a/core/src/test/resources/sql/misc.iq b/core/src/test/resources/sql/misc.iq
          index 3874d69..9dcd07e 100644
          --- a/core/src/test/resources/sql/misc.iq
          +++ b/core/src/test/resources/sql/misc.iq
          @@ -1195,6 +1195,10 @@ from "scott".dept;
           
           !ok
           
          +# [CALCITE-1486] Invalid literal
          +select 8388608/(60+27.39);
          +!ok
          +
           # [CALCITE-1120] Support SELECT without FROM
           select 2 + 2;
           +--------+
          

          No, it's not OK. getOperandLiteralValue should assume that the operand is constant, but not that it is a literal. If it is not a literal it should use constant reduction.

          Show
          julianhyde Julian Hyde added a comment - I reproduced this: diff --git a/core/src/test/resources/sql/misc.iq b/core/src/test/resources/sql/misc.iq index 3874d69..9dcd07e 100644 --- a/core/src/test/resources/sql/misc.iq +++ b/core/src/test/resources/sql/misc.iq @@ -1195,6 +1195,10 @@ from "scott".dept; !ok +# [CALCITE-1486] Invalid literal +select 8388608/(60+27.39); +!ok + # [CALCITE-1120] Support SELECT without FROM select 2 + 2; +--------+ No, it's not OK. getOperandLiteralValue should assume that the operand is constant, but not that it is a literal. If it is not a literal it should use constant reduction.
          Hide
          dongming Dongming Liu added a comment -

          Thanks.

          Show
          dongming Dongming Liu added a comment - Thanks.
          Show
          julianhyde Julian Hyde added a comment - Fixed in http://git-wip-us.apache.org/repos/asf/calcite/commit/b7e99bca .
          Hide
          julianhyde Julian Hyde added a comment -

          Resolved in release 1.11.0 (2017-01-11).

          Show
          julianhyde Julian Hyde added a comment - Resolved in release 1.11.0 (2017-01-11).

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              dongming Dongming Liu
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development