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

fix: coalesce function should return correct data type #9459

Merged
merged 8 commits into from
Mar 7, 2024

Conversation

viirya
Copy link
Member

@viirya viirya commented Mar 5, 2024

Which issue does this PR close?

Closes #9458.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added logical-expr Logical plan and expressions sqllogictest SQL Logic Tests (.slt) labels Mar 5, 2024
@viirya
Copy link
Member Author

viirya commented Mar 5, 2024

Some remaining test failures are unrelated. But some seem related. I'll keep looking into them.

@github-actions github-actions bot added the physical-expr Physical Expressions label Mar 5, 2024
Comment on lines +421 to +423
if *type_into == coerced_type {
Some(coerced_type)
} else {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For function argument, we want to coerce to exact the type (valid type) instead of third type.

Comment on lines +96 to 100
"could not cast {} from {} to {}",
$NAME,
$ARG.data_type(),
type_name::<$ARRAY_TYPE>()
))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I debug, I found that it is a more useful error message to show the source data type too.

@viirya viirya merged commit 37b7375 into apache:main Mar 7, 2024
23 checks passed
@viirya
Copy link
Member Author

viirya commented Mar 7, 2024

Thanks @Dandandan

wiedld pushed a commit to wiedld/arrow-datafusion that referenced this pull request Apr 1, 2024
* fix: Remove supported coalesce types

* Use comparison_coercion

* Fix test

* Fix

* Add comment

* More

* fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
logical-expr Logical plan and expressions physical-expr Physical Expressions sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

coalesce function returns incorrect result
2 participants