Skip to content

Conversation

@Lordworms
Copy link
Contributor

@Lordworms Lordworms commented Apr 5, 2024

Which issue does this PR close?

Closes #9925

Rationale for this change

The signature of the coalesce function has changed to variadic_equal and we need to add a new rule to coercion [Dictionary, Utf8] to Dictionary

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 physical-expr Changes to the physical-expr crates labels Apr 5, 2024
@Lordworms Lordworms changed the title coercion vec[Dictionary, Utf8] to Dictionary coercion vec[Dictionary, Utf8] to Dictionary for coalesce function Apr 5, 2024
@github-actions github-actions bot added sqllogictest SQL Logic Tests (.slt) and removed physical-expr Changes to the physical-expr crates labels Apr 5, 2024
finish

remove print

add space
@Lordworms Lordworms marked this pull request as ready for review April 5, 2024 03:54
Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you for working on this @Lordworms 🙏

I think we need a few more tests and to handle a few more cases, but it looks good so far

Some(type_into.clone())
}

Dictionary(_, _) if matches!(type_from, Utf8) => Some(type_into.clone()),
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this currently says it is possible to coerce from Utf8 to any dictionary type (e.g. even Dictionary(Int64, Int32))

I think the dictionary_coercion function does something similar here: https://github.com/apache/arrow-datafusion/blob/37b73751b19b82516443579c714b3b5986dac927/datafusion/expr/src/type_coercion/binary.rs#L635-L634

So maybe we need to verify we can coerce the value types, like this?

Suggested change
Dictionary(_, _) if matches!(type_from, Utf8) => Some(type_into.clone()),
Dictionary(_, value_type) if coerce_from(value_type, from_type) => Some(type_into.clone()),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it

Copy link
Contributor

@alamb alamb left a comment

Choose a reason for hiding this comment

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

Thank you @Lordworms -- this looks very nice to me 🙏

@alamb alamb merged commit 4d85979 into apache:main Apr 5, 2024
wiedld pushed a commit to influxdata/arrow-datafusion that referenced this pull request Apr 10, 2024
…pache#9958)

* for debug

finish

remove print

add space

* fix clippy

* finish

* fix clippy
alamb pushed a commit to alamb/datafusion that referenced this pull request Apr 16, 2024
…pache#9958)

* for debug

finish

remove print

add space

* fix clippy

* finish

* fix clippy
alamb added a commit that referenced this pull request Apr 17, 2024
…9958) (#10104)

* for debug

finish

remove print

add space

* fix clippy

* finish

* fix clippy

Co-authored-by: Lordworms <[email protected]>
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 sqllogictest SQL Logic Tests (.slt)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regression: Coercion stopped working for coalesce on a dictionary column

2 participants