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

SqlParser should parse MySQL DATETIME type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.37.0
    • None
    • babel

    Description

      MySQL has two different data types: TIMESTAMP and DATETIME. The difference between them is the range they support.

      From the documentation [1]
      The TIMESTAMP data type is used for values that contain both date and time parts. TIMESTAMP has a range of '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC.

      The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in 'YYYY-MM-DD hh:mm:ss' format. The supported range is '1000-01-01 00:00:00' to '9999-12-31 23:59:59'.

      Calcite's TIMESTAMP likely supports both ranges, and for unparse logic, the MySQL dialect class always uses DATETIME because the TIMESTAMP range is a subset of the DATETIME range.

      The only missing part is parsing the DATETIME datatype. For example

      SELECT CAST(timestamp_field AS DATETIME) FROM <table>
      

      [1] https://dev.mysql.com/doc/refman/8.4/en/datetime.html

      Attachments

        Issue Links

          Activity

            People

              dmsysolyatin Dmitry Sysolyatin
              dmsysolyatin Dmitry Sysolyatin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated: