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

Can't parse custom function with name 'DATEADD' in babel

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Resolved
    • 1.36.0
    • None
    • babel
    • None

    Description

      1. config

          I use SqlBabelParserImpl.FACTORY, and create SqlCustomOperatorTable.java which extends org.apache.calcite.sql.fun.SqlStdOperatorTable.

      Frameworks.newConfigBuilder()
              .parserConfig(SqlParser.config()
                      .withLex(Lex.MYSQL)
                      .withCaseSensitive(false)
                      .withConformance(SqlConformanceEnum.MYSQL_5)
                      .withParserFactory(SqlBabelParserImpl.FACTORY)
              )
              .operatorTable(SqlCustomOperatorTable.instance()) 

          In my SqlCustomOperatorTable, I define my custom function named with 'DATEADD'. 

      2. error

          When i try the sql below, i got error as follows.

      select dateadd(1698389166000, interval 1 year) 
      Encountered "1698389166000" at line 1, column 16.
      Was expecting one of:
          <IDENTIFIER> ...
          <HYPHENATED_IDENTIFIER> ...
          <QUOTED_IDENTIFIER> ...
          <BACK_QUOTED_IDENTIFIER> ...
          <BIG_QUERY_BACK_QUOTED_IDENTIFIER> ...
          <BRACKET_QUOTED_IDENTIFIER> ...
          <UNICODE_QUOTED_IDENTIFIER> ... 

          Is 'DATEADD' a reserved word? Is there any method to let me create a custom function with name 'DATEADD'?

          Thanks for your help.

      Attachments

        Activity

          People

            Unassigned Unassigned
            simonalexs SimonAlexs
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: