-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
DataFrame parse_sql_expr does not handle aliases #12518
Comments
I spent some time on tracing code but found unable to fix it. DetailTo be specific, I run following with debugger attachedlet df = ctx.sql("SELECT 1 as col0").await?; let expr = df.parse_sql_expr("1 + 3 * col0 as new_col0")?; And found this line, whose value return from
BinaryOp { left: Value(Number("1", false)), op: Plus, right: BinaryOp { left: Value(Number("3", false)), op: Multiply, right: Identifier(Ident { value: "col0", quote_style: None }) } } |
I think you're right @Eason0729 I did not have much time to investigate but initial investigation lead to |
There is a private method I would propose changing the return type from
This could cause other method to change(including some public methods on SessionState). If above is okay, I would begin working on it. |
|
Mainly because it could be done without changing I think I should start writing code right away, as it would be better to communicate with code. I would do it in my fork and let you know when I am ready, then I might learn how to do it without changing public method in SessionState. |
I just finish it in my fork. It's not meant to be a pull request, just to showcase what I would like to change. Here is the public API I change: diff Also, I change sqlparser of my fork to make |
It does look good, @Eason0729. |
Okay, then I will remove thing that doesn't belong to pull request and submit pull request. |
PR in sqlparser: apache/datafusion-sqlparser-rs#1444 |
Let's wait for apache/datafusion-sqlparser-rs#1444, then I will submit a PR for |
Thank you @Eason0729 -- we'll try and release a sqlparser release shortly |
Hey @Eason0729 any interested in continuing this issue? |
@milenkovicm I am waiting for next release of |
My bad, I thought it's released |
It is on my queue: apache/datafusion-sqlparser-rs#1423 |
I just see sqlparser release I will start working on that tomorrow. |
Describe the bug
df.parse_sql_expr does not handle expression aliases, for expressions like
it will return
col(
col0`) expressionTo Reproduce
statement
from
datafusion/datafusion-examples/examples/parse_sql_expr.rs
Line 125 in aeca7ea
can be used to demonstrate this issue
as return column has
sum(?table?.int_col)
as the nameExpected behavior
it is expected to have expression alias handled
Additional context
No response
The text was updated successfully, but these errors were encountered: