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

Substrait doesn't support alias in projection #6489

Open
waynexia opened this issue May 30, 2023 · 2 comments
Open

Substrait doesn't support alias in projection #6489

waynexia opened this issue May 30, 2023 · 2 comments
Assignees
Labels
bug Something isn't working substrait Changes to the substrait crate

Comments

@waynexia
Copy link
Member

Describe the bug

SQLs like these will fail:

SELECT a as alias_a, a FROM data;

or

SELECT a as alias_a FROM data ORDER BY a;

The error message looks like

Error: Plan("Projections require unique expression names but the expression \"data.a\" at position 0 and \"data.a\" at position 1 have the same name. Consider aliasing (\"AS\") one of them.")

To Reproduce

Adding case in datafusion/substrait/tests/roundtrip_logical_plan.rs like:

    #[tokio::test]
    async fn roundtrip_alias_in_projection() -> Result<()> {
        roundtrip("SELECT a as alias_a, a FROM data").await
    }

Expected behavior

It should generate correct LogicalPlan without error

Additional context

No response

@waynexia waynexia added bug Something isn't working substrait Changes to the substrait crate labels May 30, 2023
@waynexia waynexia self-assigned this May 30, 2023
@waynexia
Copy link
Member Author

https://github.com/apache/arrow-datafusion/pull/5077/files#diff-7bd0ab7829b96498566ab887a4003134c38092e96441b8f5c8ccdb297478884eR384-R386 processes Expr::Alias but it isn't supported yet.

#[tokio::test]
async fn roundtrip_field_alias() -> Result<()> {
    roundtrip("SELECT data.a as b FROM data").await
}

Fails with

Projection: data.a AS b
  TableScan: data projection=[a]
TableScan: data projection=[a]
thread 'cases::roundtrip_logical_plan::roundtrip_field_alias' panicked at 'assertion failed: `(left == right)`
  left: `"Projection: data.a AS b\n  TableScan: data projection=[a]"`,
 right: `"TableScan: data projection=[a]"`

@killme2008
Copy link

Looks like it was fix in #10829

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

No branches or pull requests

2 participants