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

unnest errors in conjunction with SELECT * #12684

Closed
ahirner opened this issue Sep 30, 2024 · 5 comments · Fixed by #12760
Closed

unnest errors in conjunction with SELECT * #12684

ahirner opened this issue Sep 30, 2024 · 5 comments · Fixed by #12760
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@ahirner
Copy link
Contributor

ahirner commented Sep 30, 2024

Describe the bug

One cannot include all colums in addition to the unnested column. Consequently, excluding some of all columns also stopped working in 42.

To Reproduce

Create table with regular and to be unnested columns:

CREATE TABLE d AS VALUES
('x', 1, [named_struct('a', 1, 'b', 2)]),
('y', 2, [named_struct('a', 3, 'b', 4), named_struct('a', 5, 'b', 6)]);

Query unnested structs but also all others.

SELECT unnest(column3), * FROM d;

Error:

Schema error: No field named "*". Valid fields are "UNNEST(d.column3)", d.column1, d.column2, d.column3, "UNNEST(d.column3)", d.column1, d.column2, d.column3.

When excluding some via except:

SELECT unnest(column3), * except (column3, column1) FROM d;

.. the error becomes:

Schema error: No field named "* EXCEPT (column3, column1)". Valid fields are "UNNEST(d.column3)", d.column2, "UNNEST(d.column3)", d.column2.

Expected behavior

The qeries do work in datafusion 41:

+-------------------+---------+---------+------------------------------+
| unnest(d.column3) | column1 | column2 | column3                      |
+-------------------+---------+---------+------------------------------+
| {a: 1, b: 2}      | x       | 1       | [{a: 1, b: 2}]               |
| {a: 3, b: 4}      | y       | 2       | [{a: 3, b: 4}, {a: 5, b: 6}] |
| {a: 5, b: 6}      | y       | 2       | [{a: 3, b: 4}, {a: 5, b: 6}] |
+-------------------+---------+---------+------------------------------+

..with except (column3, column1):

+-------------------+---------+
| unnest(d.column3) | column2 |
+-------------------+---------+
| {a: 1, b: 2}      | 1       |
| {a: 3, b: 4}      | 2       |
| {a: 5, b: 6}      | 2       |
+-------------------+---------+

Additional context

It seems a to be a parsing issue, or perhaps loosing track of field names (#12560)?

@ahirner ahirner added the bug Something isn't working label Sep 30, 2024
@alamb
Copy link
Contributor

alamb commented Sep 30, 2024

Thanks for the report @ahirner -- the only obvious change to unnest in 42 was #11797 from @jayzhan211

Hopefully someone can look into this soon

@alamb alamb added the help wanted Extra attention is needed label Sep 30, 2024
@ahirner
Copy link
Contributor Author

ahirner commented Sep 30, 2024

Or it's related to more optimal wildcard expansion? #11681
(can't bisect right now)

@hailelagi
Copy link
Contributor

hailelagi commented Oct 1, 2024

take (after a few hours of debugging, this is a little bit beyond me)

@goldmedal
Copy link
Contributor

take

@goldmedal
Copy link
Contributor

Or it's related to more optimal wildcard expansion? #11681 (can't bisect right now)

I have confirmed that it's a missed case of #11681.
Thanks @ahirner for reporting it. I'll fix it as soon as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
4 participants