You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "tustvold (via GitHub)" <gi...@apache.org> on 2023/03/09 15:53:05 UTC

[GitHub] [arrow-datafusion] tustvold commented on a diff in pull request #5517: fix: cast literal to timestamp

tustvold commented on code in PR #5517:
URL: https://github.com/apache/arrow-datafusion/pull/5517#discussion_r1131237011


##########
datafusion/optimizer/src/unwrap_cast_in_comparison.rs:
##########
@@ -428,6 +452,36 @@ fn try_cast_literal_to_type(
     }
 }
 
+/// Cast a timestamp value from one unit to another
+fn cast_between_timestamp(from: DataType, to: DataType, value: i128) -> Option<i64> {

Review Comment:
   I think this has problematic overflow behaviour, I wonder if we can determine the scale factor and multiply or divide by this instead? This is what arrow-cast does - https://github.com/apache/arrow-rs/blob/master/arrow-cast/src/cast.rs#L1671
   
   Currently I think converting `i64::MAX / 1_000` to milliseconds from seconds will silently overflow, when in reality it shouldn't



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org