Skip to content

Improve error messages when coercion fails #19004

Description

@alamb

Is your feature request related to a problem or challenge?

After #18820 is merged, running this query:

select array_slice(arrow_cast(make_array(1, 2, 3, 4, 5), 'ListView(Int64)'), 0, 6),
       array_slice(arrow_cast(make_array('h', 'e', 'l', 'l', 'o'), 'ListView(Utf8)'), 0, 5);

Results in a very hard to interpret error message:

DataFusion error: Error during planning: Failed to coerce arguments to satisfy a call to 'array_slice' function: coercion from ListView(Int64), Int64, Int64 to the signature OneOf([ArraySignature(Array { arguments: [Array, Index, Index], array_coercion: Some(FixedSizedListToList) }), ArraySignature(Array { arguments: [Array, Index, Index, Index], array_coercion: Some(FixedSizedListToList) })]) failed No function matches the given name and argument types 'array_slice(ListView(Int64), Int64, Int64)'. You might need to add explicit type casts.

As a user I would be pretty hard pressed to understand the actual problem is that array_slice doesn't support the ListView type

Describe the solution you'd like

I would like the error message to be more human readable

Describe alternatives you've considered

The error message for array_reverse seems much easier to understand:

> select array_reverse(arrow_cast(make_array(1, 2, 3, 4, 5), 'ListView(Int64)'));

Error during planning: array_reverse does not support type ListView(Int64) No function matches the given name and argument types 'array_reverse(ListView(Int64))'. You might need to add explicit type casts.
	Candidate functions:
	array_reverse(array)```

Perhaps something like

DataFusion error: Error during planning: Failed to coerce arguments to satisfy a call to 'array_slice' function. You might need to add explicit type casts.
	Candidate functions:
        array_slice(array, index, index)
        array_slice(array index, index, index)

I am not really sure how to work in the information that "Array" in this context means ListArray, LargeListArray or FixedSizeListArray

Additional context

No response

Activity

  1. added theissue type on Nov 30, 2025
  2. Jefffrey commented on Nov 30, 2025

    @Jefffrey
    Contributor

    Thanks for creating this, been meaning to do so but lost track 😅

  3. jatinkumarsingh commented on Dec 1, 2025

    @jatinkumarsingh
    Contributor

    @alamb
    sir i would love to work on this issue too
    could u plz assign it to me

  4. jatinkumarsingh commented on Dec 1, 2025

    @jatinkumarsingh
    Contributor

    take

  5. Jefffrey commented on Dec 10, 2025

    @Jefffrey
    Contributor

    I'll add on to this issue, we should look into improving the error message when using coercion API too. For example:

    > select log('');
    Error during planning: Internal error: Function 'log' failed to match any signature, errors: Internal error: Expect TypeSignatureClass::Decimal but received NativeType::String, DataType: Utf8.
    This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues,Internal error: Expect TypeSignatureClass::Float but received NativeType::String, DataType: Utf8.
    This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues,Error during planning: Function 'log' expects 2 arguments but received 1,Error during planning: Function 'log' expects 2 arguments but received 1.
    This issue was likely caused by a bug in DataFusion's code. Please help us to resolve this by filing a bug report in our issue tracker: https://github.com/apache/datafusion/issues No function matches the given name and argument types 'log(Utf8)'. You might need to add explicit type casts.
            Candidate functions:
            log(Coercion(TypeSignatureClass::Decimal))
            log(Coercion(TypeSignatureClass::Float, implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64))
            log(Coercion(TypeSignatureClass::Float, implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64), Coercion(TypeSignatureClass::Decimal))
            log(Coercion(TypeSignatureClass::Float, implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64), Coercion(TypeSignatureClass::Float, implicit_coercion=ImplicitCoercion([Numeric], default_type=Float64))

    It's not very readable, and it includes InternalError which is not right in terms of semantics.

    This can be tackled as a separate task, with this issue as a wider tracking issue.

  6. Jefffrey commented on Dec 25, 2025

    @Jefffrey
    Contributor

    Hey @jatinkumarsingh , how's the progress going on this?

  7. Jefffrey commented on Dec 27, 2025

    @Jefffrey
    Contributor

    I'll take over this as I think it's important to finally tackle this as part of other efforts to use the coercible API

  8. removed their assignment
    on Apr 16, 2026
  9. saadtajwar commented on Jun 30, 2026

    @saadtajwar
    Contributor

    Hey @alamb / @Jefffrey - is this one still open? Happy to work on this if so :)

  10. alamb commented on Jul 1, 2026

    @alamb
    ContributorAuthor

    Hey @alamb / @Jefffrey - is this one still open? Happy to work on this if so :)

    Yes thank you -- perhaps you can start with some research into the current behavior and then we can figure out how what the curent status and what it should look like after that

  11. saadtajwar commented on Jul 1, 2026

    @saadtajwar
    Contributor

    @alamb - sounds good, thank you! I'll start with some digging now and report back with my findings! 😁

  12. saadtajwar commented on Jul 1, 2026

    @saadtajwar
    Contributor

    take

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions