Skip to content

Wrong result from projection #264

@Dandandan

Description

@Dandandan

Describe the bug
Projection is removed when it contains the same fields.
This

To Reproduce

> select (1+1) as a from (select 1 as a);
+---+
| a |
+---+
| 1 |
+---+
1 rows in set. Query took 0 seconds.;

Expected behavior
Should return 2 instead of reusing the expression from the field.

Additional context
The bug seems to originate from the project function https://github.com/apache/arrow-datafusion/blob/master/datafusion/src/sql/planner.rs#L652 .
I think when we remove the "optimization" to get rid of the projection, the query will return the correct result.
Removal of any redundant projections should move to a properly tested optimization pass rather than in the sql -> logical plan planner.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions