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

Incorrect return type for BigQuery TRUNC functions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.35.0
    • None

    Description

      This is written in Calcite terms, a Calcite TIMESTAMP is a BigQuery DATETIME and a Calcite TIMESTAMP_LTZ is a BigQuery TIMESTAMP

      The four BigQuery TRUNC functions: DATE_TRUNC, DATETIME_TRUNC, TIME_TRUNC, and TIMESTAMP_TRUNC have varying return types based on (1) which function and (2) the supplied datetime type. The return type can be inferred according to this chart:

      FUNC/TYPE DATE TIMESTAMP TIME TS w/ LTZ
      DATE_TRUNC DATE TIMESTAMP INVALID TS w/ LTZ
      DATETIME_TRUNC TIMESTAMP TIMESTAMP INVALID TS w/ LTZ
      TIME_TRUNC INVALID INVALID TIME INVALID
      TIMESTAMP_TRUNC TIMESTAMP TIMESTAMP INVALID TS w/ LTZ

       The opened PR corrects the current implementations to match this chart, primarily by adjusting the set return types in the operator table, and also converting DATES to TIMESTAMPS in the convertlet table for the DATETIME_TRUNC and TIMESTAMP_TRUNC functions.

      Relevant Docs

      Attachments

        Issue Links

          Activity

            People

              tanclary Tanner Clary
              tanclary Tanner Clary
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: