0lai0 opened a new pull request, #3710: URL: https://github.com/apache/datafusion-comet/pull/3710
## Which issue does this PR close? <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123. --> Closes #3179 ## Rationale for this change Previously, the code used a catch-all pattern DataType::Timestamp(_, _) and unconditionally applied "UTC" to the resulting array. This fundamentally changed the semantics of TimestampNTZ and blocked proper downstream support for the NTZ type. ## What changes are included in this PR? This PR fixes the bug where casting a string to TimestampNTZ (Timestamp without time zone) incorrectly produces an Arrow array with UTC timezone metadata. Key changes include: - Refactored cast_utf8_to_timestamp! macro: Updated the macro to accept an Option<&str> for the timezone metadata ($with_tz). The array builder now conditionally applies .with_timezone(tz_str) only if a timezone string is explicitly provided. - Separated Timestamp and TimestampNTZ handling: In cast_string_to_timestamp, we now explicitly pattern match DataType::Timestamp(_, Some(_)) and DataType::Timestamp(_, None). - Corrected NTZ semantics: For TimestampNTZ, the macro now uses &Utc as the baseline for timestamp_parser to calculate the correct naive epoch microseconds, while passing None::<&str> to ensure the resulting Arrow array has no timezone metadata attached. ## How are these changes tested? <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> Add test -- 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]
