Skip to content

Coercion::new_implicit is confusing when desired type is TypeSignatureClass::Native #24135

Description

@Jefffrey

Is your feature request related to a problem or challenge?

/// 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:

Coercion::new_implicit(
TypeSignatureClass::Native(logical_string()),
vec![TypeSignatureClass::Any],
NativeType::String,
)

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

Activity

  1. added theissue type on Aug 6, 2026
  2. Jamison929611 commented on Aug 12, 2026

    @Jamison929611
    Contributor

    I'd like to work on this. I plan to add a focused new_implicit_native convenience constructor with tests, keep new_implicit backward compatible, and migrate only clear representative call sites.

  3. added 2 commits that reference this issue on Aug 16, 2026
    d2f65a7
    3359eab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions