-
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
Consolidate coercion code in datafusion_expr::type_coercion
and submodules
#3728
Conversation
use std::{fmt, str::FromStr}; | ||
|
||
pub static STRINGS: &[DataType] = &[DataType::Utf8, DataType::LargeUtf8]; |
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.
Moved to type_coercion/aggregate.rs
//! performed because all valid i32 values can be represented using an | ||
//! i64. However, i64 -> i32 is never performed as there are i64 | ||
//! values which can not be represented by i32 values. | ||
//! | ||
|
||
use crate::{Signature, TypeSignature}; |
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.
Moved this code into Moved to
type_coercion/function.rsas it is related to function coercion, despite the
data_types` generic name
Ok(()) | ||
} | ||
} | ||
pub mod aggregates; |
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.
Now the code for various coercion lives in a module that helps identify what it is for
@@ -421,30 +422,6 @@ fn coercion_decimal_mathematics_type( | |||
} | |||
} | |||
|
|||
/// Determine if a DataType is signed numeric or not |
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.
moved into type_coercion.rs
as this is not specific to binary expressions
@@ -17,6 +17,7 @@ | |||
|
|||
//! Coercion rules for matching argument types for binary operators |
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.
I renamed binary_rule.rs
to type_coercion/binary.rs
to better explain what it is for. I have always been confused about the name binary_rule
I think this module has a lot more code than for binary operators so it can be split / cleaned up more but I felt this is a good start
Thanks for your work @alamb |
I am going to merge this PR quickly as it is blocking some of my other work I think it has the potential to gather conflicts and I think @liukun4515 is ok with the plan (even though he hasn't yet explicitly approved it). I am happy to make any changes in follow on PRs -- please just let me know |
Benchmark runs are scheduled for baseline = 23682f6 and contender = 7c5c2e5. 7c5c2e5 is a master commit associated with this PR. Results will be available as each benchmark for each run completes. |
LGTM |
Which issue does this PR close?
re #3582
re #3419
Rationale for this change
I want to continue the good work from @liukun4515 to get type coercion into a single place as part of the logical planning phase, as well as to prepare for the additional work described in #3419 by @andygrove
This PR just moves coercion code around, no functional change is intended
Note that I plan to make a public API for coercion shortly -- see #3708
What changes are included in this PR?
Move coercion code from various places that it was scattered around the codebase into `datafusion_expr::type_coercion and submodules
Are there any user-facing changes?
If anyone calls these functions directly, they will need to change how to find them