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

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.24.0
    • Component/s: None
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: