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

Handle alias when parsing sql(parse_sql_expr) #12939

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Eason0729
Copy link
Contributor

Which issue does this PR close?

Close #12518

Also, we need to wait for next sqlparser release, so this PR is expected to be draft for a while.

Rationale for this change

What changes are included in this PR?

In #12518 , parse_sql_expr call sql_expr_to_logical_expr, then parse_sql_into_dialect.

add sql_expr_to_logical_expr_with_alias and parse_sql_into_dialect_with_alias function, whose returns contain alias if there is alias.

Are these changes tested?

Are there any user-facing changes?

@github-actions github-actions bot added sql SQL Planner core Core DataFusion crate labels Oct 15, 2024
@Eason0729
Copy link
Contributor Author

This PR duplicates some of the function that return Expr(sqlparser) and add _with_alias to their name(change return type to ExprWithAlias simultaneously).

However, I thinks the duplication is unneeded for function that return Expr(datafusion), because datafusion already have Alias entry in Expr enum.

@Eason0729 Eason0729 marked this pull request as ready for review November 22, 2024 05:17
Copy link
Contributor

@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 @Eason0729 !

I looked at #12518

Could you possible add a test showing the usecase from that issue working?

For example a test that does something like:

df.parse_sql_expr("SUM(int_col) as sum_int_col")

@alamb
Copy link
Contributor

alamb commented Nov 23, 2024

FYI @milenkovicm

@Eason0729
Copy link
Contributor Author

Thanks @Eason0729 !

I looked at #12518

Could you possible add a test showing the usecase from that issue working?

For example a test that does something like:

df.parse_sql_expr("SUM(int_col) as sum_int_col")

Sure, I will work on that next week.

@alamb
Copy link
Contributor

alamb commented Nov 25, 2024

Marking as draft as I think this PR is no longer waiting on feedback. Please mark it as ready for review when it is ready for another look

@alamb alamb marked this pull request as draft November 25, 2024 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Core DataFusion crate sql SQL Planner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DataFrame parse_sql_expr does not handle aliases
2 participants