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

Support cast between StructArray. #5219

Closed
my-vegetable-has-exploded opened this issue Dec 18, 2023 · 1 comment · Fixed by #5221
Closed

Support cast between StructArray. #5219

my-vegetable-has-exploded opened this issue Dec 18, 2023 · 1 comment · Fixed by #5221
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog

Comments

@my-vegetable-has-exploded
Copy link
Contributor

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

In apache/datafusion#6635, we think supporting cast between StructArray will be helpful to implement multi column In list.

For example,

❯ CREATE TABLE colors (
    color_id INT PRIMARY KEY,
    color_name VARCHAR(50)
);
0 rows in set. Query took 0.002 seconds.

❯ INSERT INTO colors (color_id, color_name) VALUES (1, 'Red'), (2, 'Blue');
+-------+
| count |
+-------+
| 2     |
+-------+
1 row in set. Query took 0.002 seconds.

❯ SELECT * FROM colors WHERE struct(color_id) IN (struct(1));
type_coercion
caused by
Error during planning: Can not find compatible types to compare Struct([Field { name: "c0", data_type: Int32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }]) with [Struct([Field { name: "c0", data_type: Int64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }])]

After supporting cast between StructArray, we can just use struct(color_id) IN (struct(1)) rather than struct(color_id) IN (struct(arrow_cast(1,'Int32'))); in this example.

Describe the solution you'd like

  • check can_cast_types recursively for each field
  • cast_with_options recursively for each field

Describe alternatives you've considered

Additional context

I'm willing to submit a pr later.

@my-vegetable-has-exploded my-vegetable-has-exploded added the enhancement Any new improvement worthy of a entry in the changelog label Dec 18, 2023
@tustvold tustvold added the arrow Changes to the arrow crate label Jan 5, 2024
@tustvold
Copy link
Contributor

tustvold commented Jan 5, 2024

label_issue.py automatically added labels {'arrow'} from #5221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arrow Changes to the arrow crate enhancement Any new improvement worthy of a entry in the changelog
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants