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

AbstractSqlTester fails to build query for expression TRIM(string)

    XMLWordPrintableJSON

Details

    Description

      When running the following test in SqlOperatorTest,

      f.checkString("trim(' aAa ')", "aAa", "VARCHAR(5) NOT NULL");
      

      it throws "java.lang.StringIndexOutOfBoundsException: begin 8, end 21, length 17".

      The expression "trim(' aAa ')" will be parsed into "trim(both ' ' from ' aAa ')" (call it TrimFuncCall).
      However, when building the above query that extracts all literals as columns in an underlying select(in AbstractSqlTester.buildQuery2()), the space literal in TrimFuncCall will be extracted, which doesn't exist in the original expression "trim(' aAa ')". We just need to extract "' aAa '" in this case, and get

      select trim(p0) from (values (' aAa ')) as t(p0)
      

      Attachments

        Issue Links

          Activity

            People

              VAE ZheHu
              VAE ZheHu
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: