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

[SPARK-51584][SQL] Add rule that pushes Project through Offset and Suite that tests it #50326

Conversation

Pajaraja
Copy link
Contributor

What changes were proposed in this pull request?

Add a new rule PushProjectionThroughOffset analogous to PushProjectionThroughLimit, that pushes projection nodes beneath Offset nodes.

Why are the changes needed?

Currently, if a Project node is above a Offset and Limit node, the Project will get pushed through the Limit node, but not the Offset node, and then the Offset and LocalLimit nodes won't get swapped, eliminating the optimization LocalLimit nets in this case.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Created PushProjectionThroughOffsetSuite to test this new rule.

Was this patch authored or co-authored using generative AI tooling?

No.

@github-actions github-actions bot added the SQL label Mar 19, 2025
@Pajaraja Pajaraja marked this pull request as draft March 19, 2025 12:39
@Pajaraja Pajaraja closed this Mar 19, 2025
@Pajaraja Pajaraja reopened this Mar 19, 2025
@Pajaraja Pajaraja marked this pull request as ready for review March 19, 2025 12:39
@Pajaraja Pajaraja requested a review from cloud-fan March 19, 2025 14:39

val query1 = testRelation
.offset(5)
.select(Symbol("a"), Symbol("b"), 'c')
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
.select(Symbol("a"), Symbol("b"), 'c')
.select($"a", $"b", $"c")

Copy link
Contributor

Choose a reason for hiding this comment

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

ditto for other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@cloud-fan
Copy link
Contributor

let's create a JIRA ticket for it

@Pajaraja
Copy link
Contributor Author

let's create a JIRA ticket for it

I requested a JIRA account, so I will create it when I get approved.

@Pajaraja Pajaraja changed the title [SQL] Add rule that pushes Project through Offset and Suite that tests it [SPARK-51584][SQL] Add rule that pushes Project through Offset and Suite that tests it Mar 21, 2025
@Pajaraja
Copy link
Contributor Author

let's create a JIRA ticket for it

I requested a JIRA account, so I will create it when I get approved.

Created here: https://issues.apache.org/jira/browse/SPARK-51584.

@Pajaraja Pajaraja requested a review from cloud-fan March 21, 2025 15:45
@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in dc76834 Mar 24, 2025
Copy link
Contributor

@beliefer beliefer left a comment

Choose a reason for hiding this comment

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

late LGTM.

SauronShepherd pushed a commit to SauronShepherd/spark that referenced this pull request Mar 25, 2025
…ite that tests it

### What changes were proposed in this pull request?

Add a new rule PushProjectionThroughOffset analogous to PushProjectionThroughLimit, that pushes projection nodes beneath Offset nodes.

### Why are the changes needed?

Currently, if a Project node is above a Offset and Limit node, the Project will get pushed through the Limit node, but not the Offset node, and then the Offset and LocalLimit nodes won't get swapped, eliminating the optimization LocalLimit nets in this case.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Created PushProjectionThroughOffsetSuite to test this new rule.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes apache#50326 from Pajaraja/pavle-martinovic_data/ProjectionPushDownThroughLimit.

Authored-by: pavle-martinovic_data <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants