Uploaded image for project: 'Apache Drill'
  1. Apache Drill
  2. DRILL-2313

Query fails when one of the operands is a DATE literal without an explicit cast

    XMLWordPrintableJSON

Details

    Description

      For operations involving the date datatype, when one of the operands is a DATE literal without a cast, query fails.

      The following query fails to validate:

      SELECT
               *
      FROM     
               date_dim
               
      WHERE    d_date BETWEEN '2002-3-01' AND cast('2002-3-01' AS DATE) 
      
      LIMIT 1;
      

      Query failed: SqlValidatorException: Cannot apply 'BETWEEN' to arguments of type '<ANY> BETWEEN <CHAR(9)> AND <DATE>'. Supported form(s): '<COMPARABLE_TYPE> BETWEEN <COMPARABLE_TYPE> AND <COMPARABLE_TYPE>'

      The following query executes fine:

      SELECT
               *
      FROM     
               date_dim
               
      WHERE    d_date BETWEEN '2002-3-01' AND 
                        '2002-3-01'
      LIMIT 1;
      

      Both the queries execute fine on postgres

      Attachments

        Issue Links

          Activity

            People

              seanhychu Sean Hsuan-Yi Chu
              agirish Abhishek Girish
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: