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 regression list Type Coercion List with inner type struct which has large/view types #14385

Merged
merged 3 commits into from
Feb 3, 2025

Conversation

alamb
Copy link
Contributor

@alamb alamb commented Jan 31, 2025

Which issue does this PR close?

Rationale for this change

See issue -- nested structs in Lists are not coerced correctly

What changes are included in this PR?

  1. Fix bug (basically the same fix in Do not rename struct fields when coercing types in CASE #14384 to the type_union resolution)
  2. Add tests

Are these changes tested?

Yes, new sqllogictests

Are there any user-facing changes?

Bug fix

@github-actions github-actions bot added the sqllogictest SQL Logic Tests (.slt) label Jan 31, 2025
@alamb alamb changed the title Fix list Type Coercion List with inner type struct which has large/view types Fix regression list Type Coercion List with inner type struct which has large/view types Jan 31, 2025
@alamb alamb mentioned this pull request Jan 31, 2025
32 tasks
@alamb alamb closed this Jan 31, 2025
@alamb alamb reopened this Jan 31, 2025
@alamb alamb force-pushed the alamb/fix_inner_list_coercion branch from a578ebe to f0583a6 Compare February 1, 2025 12:13
@alamb alamb marked this pull request as ready for review February 1, 2025 12:13
@alamb alamb requested a review from jayzhan211 February 3, 2025 11:37
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

lgtm thanks @alamb

@@ -459,14 +459,14 @@ create table t as values({r: 'a', c: 1}), ({r: 'b', c: 2.3});
query ?
select * from t;
----
{c0: a, c1: 1.0}
Copy link
Contributor

Choose a reason for hiding this comment

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

the column names change is the part of the fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes -- these are the field names of the struct type

The values that were written into the table are liek this (a few rows above). Note the field names are r and c

create table t as values({r: 'a', c: 1}), ({r: 'b', c: 2.3});

Because they got coerced (1 needed to get coercered to the same type as 2.3) the field names got reassigned to c0 and c1 🤯 )

The fix in this PR preserves the names from the input which seems much more correct to me

Copy link
Contributor Author

@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.

Thanks (again) @comphead -- I also merged this PR up to my branch locally and verified it passed the tests

@alamb alamb merged commit 17b5e71 into apache:main Feb 3, 2025
26 checks passed
@alamb alamb deleted the alamb/fix_inner_list_coercion branch February 3, 2025 20:02
alamb added a commit to alamb/datafusion that referenced this pull request Feb 3, 2025
…as large/view types (apache#14385)

* Test for coercing inner structs

* Fix but, update tests

* Update tests
alamb added a commit that referenced this pull request Feb 3, 2025
…as large/view types (#14385) (#14456)

* Test for coercing inner structs

* Fix but, update tests

* Update tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sqllogictest SQL Logic Tests (.slt)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Type Coercion fails for List with inner type struct which has large/view types
2 participants