Jefffrey commented on code in PR #22897:
URL: https://github.com/apache/datafusion/pull/22897#discussion_r3396161459
##########
datafusion/common/src/scalar/mod.rs:
##########
@@ -4292,7 +4292,13 @@ impl ScalarValue {
.or_else(|| timestamp_to_timestamp_multiplier(&source_type,
target_type))
&& let Some(value) = self.temporal_scalar_value_as_i64()
{
- ensure_timestamp_in_bounds(value, multiplier, &source_type,
target_type)?;
+ if cast_options.safe {
+ if multiplier > 1 && value.checked_mul(multiplier).is_none() {
+ return ScalarValue::try_new_null(target_type);
+ }
+ } else {
+ ensure_timestamp_in_bounds(value, multiplier, &source_type,
target_type)?;
+ }
Review Comment:
```suggestion
match ensure_timestamp_in_bounds(value, multiplier,
&source_type, target_type)
{
Ok(()) => {}
Err(_) if cast_options.safe => {
return ScalarValue::try_new_null(target_type);
}
Err(e) => return Err(e),
}
```
perhaps like this to reuse the validation logic from
`ensure_timestamp_in_bounds`?
--
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]