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

In Babel, allow 'CAST(integer AS DATE)' even though it is illegal in Calcite SQL

    XMLWordPrintableJSON

Details

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

    Description

      In Babel, allow 'CAST(integer AS DATE)', even though it is illegal in Calcite SQL (and standard SQL).

      Map it to valid standard SQL. BigQuery CAST(n AS DATE) is equivalent to Calcite DATE '1970-01-01' + n * INTERVAL '1' DAY.

      Also, add functions DATE_FROM_UNIX_DATE(INTEGER), UNIX_SECONDS(TIMESTAMP), UNIX_MILLIS(TIMESTAMP), UNIX_MICROS(TIMESTAMP), TIMESTAMP_SECONDS(BIGINT), TIMESTAMP_MILLIS(BIGINT), TIMESTAMP_MICROS(BIGINT) in the BigQuery library. They are well-named and well-specified, so they might be useful to people working in dialects besides BigQuery. DATE_FROM_UNIX_DATE(0) should return DATE '1970-01-01'.

      Attachments

        Issue Links

          Activity

            People

              julianhyde Julian Hyde
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: