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

Invalid unparse for TRIM in PrestoDialect

    XMLWordPrintableJSON

Details

    Description

      sql not support as follow:

       

      presto> SELECT TRIM(LEADING 'a' from 'abcd');
      Query 20250504_062451_29862_cqcdm failed: line 1:25: mismatched input 'from'. Expecting: ',', <expression>
      
      SELECT TRIM(TRAILING 'a' from 'abcd')
      Query 20250504_062451_29863_cqcdm failed: line 1:25: mismatched input 'from'. Expecting: ',', <expression> 
      
      SELECT TRIM(BOTH 'a' from 'abcd')
      Query 20250504_062451_29863_cqcdm failed: line 1:25: mismatched input 'from'. Expecting: ',', <expression> 

       

      so need convert to:

      presto> SELECT TRIM('abcd', 'a');
      > bcd 
      
      presto> SELECT LTRIM('abcd', 'a');
      > bcd 
      
      presto> SELECT RTRIM('abcd', 'd');
      > abc 
      
      presto> SELECT TRIM(' abcd ');
      > abcd

      we can also refer to doc https://prestodb.io/docs/current/functions/string.html by search trim/ltrim/rtrim functions

      so we need to fix it by unparse trim correctly.

      Attachments

        Issue Links

          Activity

            People

              xuzifu666 Yu Xu
              xuzifu666 Yu Xu
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: