-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
#699 fix return type conflict when calling builtin math fuctions #716
Conversation
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.
2bb386f
to
23a254d
Compare
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.
This is looking good to me -- thank you @lvheyang !
I think all this PR needs to be mergeable are some tests (either in context.rs or sql.rs) of running math queries against columns that have float32
, int
etc.
Let me know if you would like some help or more specific pointers
5b3d6df
to
0000617
Compare
Thanks for your kind help! @alamb I added test cases in context.rs, test SQLs:
Is there any case else needed? |
@lvheyang see https://github.com/apache/arrow-rs/blob/f1a831f/arrow/src/array/array.rs#L234-L244 for numeric types with other bit width. |
@houqp 👌, I will add them all in the test case. |
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.
This looks like an improvement to me. Thank you @lvheyang !
"| 1 |", | ||
"+---------+", | ||
]; | ||
let results = plan_and_collect(&mut ctx, "SELECT sqrt(v) FROM t") |
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.
👍 it is a good test. We can finagle the types later if needed (e.g. if we ever want to support sqrt(numeric)
--> numeric
.
I think this PR makes DataFusion better than it is on master.
Any thoughts @Dandandan or @jorgecarleitao ? |
Thank you again for the contribution @lvheyang . |
Which issue does this PR close?
Closes #699
Rationale for this change
When we infer schema we should also consider the input arguments' datatype. such as sqrt(f32) -> f32, sqrt(64) -> f64. But now builtin functions statically return Float64. It causes
column types
andschema types
conflict.What changes are included in this PR?
Change the return type in datafusion/src/physical_plan/functions.rs. This PR made builtin math functions return the same type as the input argument
Are there any user-facing changes?