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

Remove unnecessary projection in logical plan optimization phase #747

Merged
merged 3 commits into from
Jul 19, 2021

Conversation

waynexia
Copy link
Member

Which issue does this PR close?

Related to #277 .

What changes are included in this PR?

This PR adds an optimization rule to remove unnecessary projection plans.

We'll consider a projection as "unnecessary" if it only reorders columns (requires the same columns against its sub-plan) and is not the first projection.

For the case where the sub-plan of a projection is a table scan, projection will be pushed down into the table scan plan as a Vec<usize> array. From the documentation, this array should be ordered. So I keep the projection in this situation (test case reorder_projection()).

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
@github-actions github-actions bot added the datafusion Changes in the datafusion crate label Jul 18, 2021
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.

Looks good -- thank you @waynexia

@@ -496,6 +506,60 @@ mod tests {
Ok(())
}

#[test]
fn redundunt_project() -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn redundunt_project() -> Result<()> {
fn redundant_project() -> Result<()> {

}

#[test]
fn noncontiguous_redundunt_projection() -> Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fn noncontiguous_redundunt_projection() -> Result<()> {
fn noncontiguous_redundant_projection() -> Result<()> {

@alamb alamb merged commit b5e034b into apache:master Jul 19, 2021
@waynexia waynexia deleted the patch-1 branch July 19, 2021 16:44
@houqp houqp added the enhancement New feature or request label Jul 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datafusion Changes in the datafusion crate enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants