Skip to content

Improve human readable display for DataType::List #7048

Closed

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
Often we would like to display DataTypes as part of an error message in DataFusion

The documentation (link) says

The Display and FromStr implementations for DataType are human-readable, parseable, and reversible.

However this is not the case for ListArray

In apache/datafusion#14378 I made what looks like it should be a nice error message

format!("It is not possible to concatenate arrays of different types. Expected: {}, got: {}", expr_type, arg_type)

However, what comes out is is 🤮

query error DataFusion error: Error during planning: It is not possible to concatenate arrays of different types. Expected: List(Field { name: "item", data_type: Utf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }), got: List(Field { name: "item", data_type: LargeUtf8, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })

Describe the solution you'd like
I would like a way to get a nicer human readable version of this for error messages

Soemthing like

Expected: List(Utf8;N), got: List(LargeUtf8;N)

Where the N stands for nullable

Describe alternatives you've considered

I personally recommend

  1. Explicitly implemeting Display for DataType::List
  2. Don't print out any information that is the default (e.g if the field name is "item" then don't print it)

Right now it simply uses the Debug implementation:

fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{self:?}")
}

Additional context

Activity

  1. irenjj commented on Jan 31, 2025

    @irenjj
    Contributor

    take

  2. emilk commented on Sep 2, 2025

    @emilk
    Contributor

    Note that a lot of error messages actually uses the Debug format of DataType, and so it would be great if that too was improved

  3. added a commit that references this issue on Sep 23, 2025
    cdbbbf7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions