hozan23 opened a new issue, #26885:
URL: https://github.com/apache/datafusion/issues/26885

   ### Describe the bug
   
   `MySqlDialect::timestamp_cast_dtype` always returns `DATETIME` with no 
precision. In MySQL, `DATETIME` means `DATETIME(0)`, so a sub-second timestamp 
is rounded to whole seconds:
   
         CAST('2026-09-21 08:55:40.006' AS DATETIME)  -- 2026-09-21 08:55:40
   
   
   ### To Reproduce
   
    ```rust
     let unparser = Unparser::new(&MySqlDialect {});
     let expr = 
Expr::Literal(ScalarValue::TimestampMillisecond(Some(1789980940006), None), 
None);
     println!("{}", unparser.expr_to_sql(&expr)?);
     // CAST('2026-09-21 08:55:40.006' AS DATETIME)
     ```
   
   
   ### Expected behavior
   
   The cast keeps the time unit's precision: `DATETIME` for seconds, 
`DATETIME(3)` for milliseconds, and `DATETIME(6)` for micro- and nanoseconds 
(must be in the range 0 to 6).
   
     See https://dev.mysql.com/doc/refman/8.0/en/fractional-seconds.html
   
   
   ### Additional context
   
   _No response_
   
   ### Willingness to contribute
   
   I plan to contribute a fix for this bug independently


-- 
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