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

Error NamedStructField should be rewritten in OperatorToFunction with subquery if query is wrapped in view #10764

Open
ahirner opened this issue Jun 2, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@ahirner
Copy link

ahirner commented Jun 2, 2024

Describe the bug

When selecting from a view that selects fields from structs, this error is thrown:

Internal error: NamedStructField should be rewritten in OperatorToFunction.

To Reproduce

In datafusion 38.0.0 cli:

> create or replace view v as select struct(1, 'b')['c1'];
0 row(s) fetched.
Elapsed 0.001 seconds.

> select * from v;
Internal error: NamedStructField should be rewritten in OperatorToFunction.
This was likely caused by a bug in DataFusion's code and we would welcome that you file an bug report in our issue tracker

Expected behavior

+--------------------------------+
| struct(Int64(1),Utf8("b"))[c1] |
+--------------------------------+
| b                              |
+--------------------------------+
1 row(s) fetched.

Additional context

It errors the same when a subquery is viewed: create view v as select (select struct(1, 'b')['c1']);.
This error appeared once as a regression in 37.0: #10029

@ahirner ahirner added the bug Something isn't working label Jun 2, 2024
@jonahgao
Copy link
Member

jonahgao commented Jun 4, 2024

It appears to be successful on the current main branch.

DataFusion CLI v38.0.0
> create or replace view v as select struct(1, 'b')['c1'];
0 row(s) fetched.
Elapsed 0.005 seconds.

> select * from v;
+--------------------------------+
| struct(Int64(1),Utf8("b"))[c1] |
+--------------------------------+
| b                              |
+--------------------------------+
1 row(s) fetched.
Elapsed 0.006 seconds.

@sergiimk
Copy link
Contributor

sergiimk commented Jun 4, 2024

Also hit a similar error in a different scenario and can confirm that master version fixed it for me.

@ahirner
Copy link
Author

ahirner commented Jun 8, 2024

Can confirm that it's gone for our more complicated use case in 8fcb3e4b, thus also probably in 0.39.
Was or should it be covered in a test? Otherwise feel free to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants