Skip to content
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

Improve human readable display for DataType::List #7048

Open
alamb opened this issue Jan 30, 2025 · 1 comment · May be fixed by #7051
Open

Improve human readable display for DataType::List #7048

alamb opened this issue Jan 30, 2025 · 1 comment · May be fixed by #7051
Assignees
Labels
enhancement Any new improvement worthy of a entry in the changelog good first issue Good for newcomers help wanted

Comments

@alamb
Copy link
Contributor

alamb commented Jan 30, 2025

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

@alamb alamb added enhancement Any new improvement worthy of a entry in the changelog good first issue Good for newcomers help wanted labels Jan 30, 2025
@irenjj
Copy link

irenjj commented Jan 31, 2025

take

@irenjj irenjj linked a pull request Jan 31, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Any new improvement worthy of a entry in the changelog good first issue Good for newcomers help wanted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants