Skip to content

Support DATETIME SQL type in the planner #26907

Description

@hozan23

Is your feature request related to a problem or challenge?

Planning DATETIME fails unless a TypePlanner handles it:

  > select CAST('2026-09-21 08:55:40' AS DATETIME);
  This feature is not implemented: Unsupported SQL type DATETIME

Since #26885, MySqlDialect unparses timestamp casts as DATETIME / DATETIME(p), so DataFusion cannot plan the SQL it produces.

Describe the solution you'd like

Treat DATETIME as an alias of TIMESTAMP without a time zone, the same way TIMESTAMP is planned today:

SQL Arrow
DATETIME Timestamp(Nanosecond, None)
DATETIME(0) Timestamp(Second, None)
DATETIME(3) Timestamp(Millisecond, None)
DATETIME(6) Timestamp(Microsecond, None)
DATETIME(9) Timestamp(Nanosecond, None)
other precisions error

Describe alternatives you've considered

No response

Additional context

No response

Willingness to contribute

I would like to contribute to this feature, but request guidance from the DataFusion community

Activity

  1. added theissue type on Oct 29, 2026
  2. nuno-faria commented on Oct 30, 2026

    @nuno-faria
    Contributor

    I think this should be supported by default. I been searching and found that the Datetime type is used as an example to extend DataFusion (https://datafusion.apache.org/library-user-guide/extending-sql.html#example-custom-datetime-type), so that would maybe need to be changed (cc: @geoffreyclaude and @alamb from #19265).

    One thing to note is that by default DuckDB assumes DATETIME as having microsecond precision:

    select CAST('2026-09-21 08:55:40.123123123' AS DATETIME);
    ┌───────────────────────────────────────────────────┐
    │ CAST('2026-09-21 08:55:40.123123123' AS DATETIME) │
    │                     timestamp                     │
    ├───────────────────────────────────────────────────┤
    │ 2026-09-21 08:55:40.123123                        │
    └───────────────────────────────────────────────────┘
    
    select CAST('2026-09-21 08:55:40.123123123' AS DATETIME(9));
    ┌──────────────────────────────────────────────────────┐
    │ CAST('2026-09-21 08:55:40.123123123' AS DATETIME(9)) │
    │                     timestamp_ns                     │
    ├──────────────────────────────────────────────────────┤
    │ 2026-09-21 08:55:40.123123123                        │
    └──────────────────────────────────────────────────────┘

    And it appears that an invalid precision is rounded to the next one:

    select CAST('2026-09-21 08:55:40.123123123' AS DATETIME(1));
    ┌──────────────────────────────────────────────────────┐
    │ CAST('2026-09-21 08:55:40.123123123' AS DATETIME(1)) │
    │                     timestamp_ms                     │
    ├──────────────────────────────────────────────────────┤
    │ 2026-09-21 08:55:40.123                              │
    └──────────────────────────────────────────────────────┘
    
    select CAST('2026-09-21 08:55:40.123123123' AS DATETIME(5));
    ┌──────────────────────────────────────────────────────┐
    │ CAST('2026-09-21 08:55:40.123123123' AS DATETIME(5)) │
    │                      timestamp                       │
    ├──────────────────────────────────────────────────────┤
    │ 2026-09-21 08:55:40.123123                           │
    └──────────────────────────────────────────────────────┘
  3. geoffreyclaude commented on Oct 30, 2026

    @geoffreyclaude
    Contributor

    @nuno-faria No hard opinion on my part. I just picked Datetime as an example since it isn't supported.

  4. alamb commented on Oct 30, 2026

    @alamb
    Contributor

    I agree -- this makes sense to me (to treat it as an alias timestamp)

    The microsecond vs nanosecond thing I think is long standing (I suspect duckdb treats timestamps as having microsecond precision too)

  5. hozan23 commented on Oct 31, 2026

    @hozan23
    ContributorAuthor

    Thanks everyone for the input! I've opened #26975, which plans DATETIME as an alias of TIMESTAMP without a time zone, as discussed.

  6. added a commit that references this issue on Nov 4, 2026
    aeba33f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions