Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-23242

Sql. Validator accepts functions that do not exist in runtime. It is not possible to call f(INTEGER) with f(BIGINT)

Log workAgile BoardRank to TopRank to BottomAttach filesAttach ScreenshotBulk Copy AttachmentsBulk Move AttachmentsAdd voteVotersWatch issueWatchersCreate sub-taskConvert to sub-taskLinkCloneLabelsUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • sql

    Description

      The following functions when called with BIGINT arguments at integer positions are accepted by the validator, but execution of such functions fails with runtime errors:

       * OVERLAY: while resolving method 'overlay
       * REPEAT: while resolving method 'repeat
       * SUBSTRING:  while resolving method 'substring
       * CHR: while resolving method 'charFromUtf8
       * LEFT:  while resolving method 'left
       * RIGHT: while resolving method 'right
       * SPACE:  while resolving method  in class class ...
       * POSITION:  while resolving method 'position
      

      Example with CHR(INT) function defined as

      public static final SqlFunction CHR =
            SqlBasicFunction.create("CHR",
                ReturnTypes.CHAR,
                OperandTypes.INTEGER,
                SqlFunctionCategory.STRING);
      
         @Test
          public void test() {
              sql("SELECT CHR(1000::BIGINT)");
          }
      
      org.apache.ignite.sql.SqlException: IGN-CMN-65535 TraceId:6002aa38-1fae-4e4e-b56c-a8134d3ed2dc while resolving method 'charFromUtf8[long]' in class class org.apache.calcite.runtime.SqlFunctions
      
      	....
      
      Caused by: java.lang.NoSuchMethodException: org.apache.calcite.runtime.SqlFunctions.charFromUtf8(long)
      	at java.base/java.lang.Class.getMethod(Class.java:2108)
      	at org.apache.calcite.adapter.enumerable.EnumUtils.call(EnumUtils.java:663)
      	... 37 more
      

      The problem stems from the fact that these functions, according to their definitions in the operator table, accept parameters from the INTEGER type family, which includes the BIGINT type. However, the runtime definition for such functions lacks implementations that accept parameters of the long type (which corresponds to Calciteā€™s BIGINT).

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned Assign to me
            mzhuravkov Maksim Zhuravkov

            Dates

              Created:
              Updated:

              Slack

                Issue deployment