Repository navigation
Closed
Feature
Copy link
Labels
enhancementNew feature or requestNew feature or request
Description
Is your feature request related to a problem or challenge?
datafusion/datafusion/expr-common/src/signature.rs
Lines 1102 to 1119 in f27e50c
| /// Create a new coercion with implicit coercion rules. | |
| /// | |
| /// `allowed_source_types` defines the possible types that can be coerced to `desired_type`. | |
| /// `default_casted_type` is the default type to be used for coercion if we cast from other types via `allowed_source_types`. | |
| pub fn new_implicit( | |
| desired_type: TypeSignatureClass, | |
| allowed_source_types: Vec<TypeSignatureClass>, | |
| default_casted_type: NativeType, | |
| ) -> Self { | |
| Self::Implicit { | |
| desired_type, | |
| implicit_coercion: ImplicitCoercion { | |
| allowed_source_types, | |
| default_casted_type, | |
| }, | |
| encoding_preservation: EncodingPreservation::default(), | |
| } | |
| } |
Example usages:
datafusion/datafusion/functions/src/unicode/reverse.rs
Lines 65 to 69 in f27e50c
| Coercion::new_implicit( | |
| TypeSignatureClass::Native(logical_string()), | |
| vec![TypeSignatureClass::Any], | |
| NativeType::String, | |
| ) |
datafusion/datafusion/functions-aggregate/src/approx_percentile_cont.rs
Lines 142 to 146 in f27e50c
| Coercion::new_implicit( | |
| TypeSignatureClass::Native(logical_float64()), | |
| vec![TypeSignatureClass::Numeric], | |
| NativeType::Float64, | |
| ), |
When desired_type is a TypeSignatureClass::Native(_), its confusing to need to specify default_casted_type to be the same; we already know our desired native type.
Describe the solution you'd like
Perhaps a new API like
pub fn new_implicit_native(
desired_type: LogicalTypeRef,
allowed_source_types: Vec<TypeSignatureClass>,
) -> Self {
Self::new_implicit(
TypeSignatureClass::Native(desired_type),
allowed_source_types,
desired_type.native().clone(),
)
}Then we could use it like
Coercion::new_implicit_native(
logical_string(),
vec![TypeSignatureClass::Any],
)And see where we can use this hopefully more intuitive API
Describe alternatives you've considered
Is there a better/cleaner way to handle this? Open to suggestions
Additional context
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Activity
Jamison929611 commentedon Aug 12, 2026
I'd like to work on this. I plan to add a focused
new_implicit_nativeconvenience constructor with tests, keepnew_implicitbackward compatible, and migrate only clear representative call sites.feat: add implicit native coercion constructor (apache#24282)
feat: add implicit native coercion constructor (apache#24282)