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

Query with filter with cast to timestamp literal does not return any results

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.15.0
    • 1.16.0
    • None

    Description

      When filter in the query has a cast of timestamp literal, the query does not return any results.

      Steps to reproduce:
      1. Create a table with timestamp values with milliseconds

      create table dfs.tmp.test_timestamp_filter as (select timestamp '2018-01-01 12:12:12.123' as c1, timestamp '9999-12-31 23:59:59.999' as c2);
      

      2. Run query with filter and cast to timestamp:

      select * from dfs.tmp.test_timestamp_filter where c1 = cast('2018-01-01 12:12:12.123' as timestamp(3));
      

      This query should return a single row, but it does not return any results.

      The following query returns the correct result:

      select * from dfs.tmp.test_timestamp_filter where c1 = timestamp '2018-01-01 12:12:12.123';
      
      +--------------------------+--------------------------+
      |            c1            |            c2            |
      +--------------------------+--------------------------+
      | 2018-01-01 12:12:12.123  | 9999-12-31 23:59:59.999  |
      +--------------------------+--------------------------+
      1 row selected (0.139 seconds)
      

      The problem in DrillConstExecutor, when it used to simplify cast, timestamp precision is lost and it is trimmed to the value with 0 precision.

      Attachments

        Issue Links

          Activity

            People

              volodymyr Vova Vysotskyi
              volodymyr Vova Vysotskyi
              Bohdan Kazydub Bohdan Kazydub
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: