nuno-faria commented on issue #26907:
URL: https://github.com/apache/datafusion/issues/26907#issuecomment-6518734933

   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 
https://github.com/apache/datafusion/pull/19265).
   
   One thing to note is that by default DuckDB assumes `DATETIME` as having 
microsecond precision:
   ```sql
   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:
   ```sql
   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                           │
   └──────────────────────────────────────────────────────┘
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to