datafusion: DataFrame parse_sql_expr does not handle aliases

Describe the bug

df.parse_sql_expr does not handle expression aliases, for expressions like

df.parse_sql_expr("col0 as new_col0")

it will return col(col0`) expression

To Reproduce

statement

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

from

https://github.com/apache/datafusion/blob/aeca7ea99940401573eb14601c74316279bbdae5/datafusion-examples/examples/parse_sql_expr.rs#L125

can be used to demonstrate this issue

as return column has sum(?table?.int_col) as the name

Expected behavior

it is expected to have expression alias handled

Additional context

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

I just see sqlparser release 0.52.0. (which was released 6 days ago 😄 )

I will start working on that tomorrow.

My bad, I thought it’s released

It is on my queue: https://github.com/apache/datafusion-sqlparser-rs/issues/1423

Okay, then I will remove thing that doesn’t belong to pull request and submit pull request.

My bad, I thought it’s released

@milenkovicm Yes, I am interested in working on this issue.

I am waiting for next release of sqlparser, so parse_expr_with_alias method on sqlparser::parser::Parser can be make public.

Hey @Eason0729 any interested in continuing this issue?