-
Notifications
You must be signed in to change notification settings - Fork 435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert scalar value to correct type based on arrow data type. #336
Conversation
I tried to add a test on date type with
Seems the aggregation on date types is not ready? I can look at it later. |
Yes, datafusion only supports string, numeric and timestamp types for min max aggregation at the moment. We need to update |
ScalarValue::from(raw_value) | ||
} | ||
ArrowDataType::Int32 => { | ||
let raw_value = i64::try_from(value).unwrap() as i32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason why we prefer downcasting from i64 to i32 over direct i32::try_from(value)
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i32::try_from
call only applies on an input of ScalarValue::Int32
. For number scalar value, we all use ScalarValue::Int64
to compare to get max/min values. That's said here the input is ScalarValue::Int64
and i32::try_from
will throw Cannot convert ...
error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ha, i see. perhaps in the future, we could change to_scalar_value
to do the scalar value type cast based on field type so we can avoid this intermediate 64 bits conversion overhead.
FYI @Dandandan |
Thanks for the info. I may take some time looking at it later. |
@houqp @Dandandan Thanks for the review. Is this good to go? |
Description
The description of the main changes of your pull request
This is a follow up of #327 for the comment #327 (comment).
For the max/min column scalar values, we convert it to correct
ScarlarValue
based on arrow datatype.Related Issue(s)
Documentation