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 parse "tablename.struct(xxxxx)" to be Expr::Struct #1199

Closed
Lordworms opened this issue Mar 31, 2024 · 2 comments
Closed

Support parse "tablename.struct(xxxxx)" to be Expr::Struct #1199

Lordworms opened this issue Mar 31, 2024 · 2 comments

Comments

@Lordworms
Copy link

related to apache/datafusion#9891

@Lordworms
Copy link
Author

Lordworms commented Apr 1, 2024

how to reproduce

select struct(time,load1,load2,host) from t1;
image
r#"SELECT t1."struct(time,load1,load2,host)" FROM t1;"#;
image

@Lordworms
Copy link
Author

I think there are two ways to solve the problem, the first one is to separate the struct in Tokenizer, like in
image
we could try to match "struct" here and if it matches, do the same logic as the non-quote "match".
The second one is to do a rewrite in Datafusion, but it also includes the parse of "t1."struct(xxxxx)", but we have to deal with I think the best way to do it is in SQL-parser.
However, the tricky part is how to determine the pattern of parse quoted "struct(xxx)", since the tokenizer's next() method does not have a state to save the previous token(my current thought is when the last token is Period and the dialect is a general or big query, we do the logics above). I don't know whether it is the best way. Could you please give me a hint about it? @alamb

@Lordworms Lordworms closed this as not planned Won't fix, can't repro, duplicate, stale Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant