-
Notifications
You must be signed in to change notification settings - Fork 6.6k
[Data] Limit operator push down #54457
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
base: master
Are you sure you want to change the base?
[Data] Limit operator push down #54457
Conversation
Signed-off-by: Goutam V <goutam@anyscale.com>
Signed-off-by: Goutam V <goutam@anyscale.com>
Signed-off-by: Goutam V <goutam@anyscale.com>
for limit_output_op in limit_op.output_dependencies: | ||
limit_output_op._input_dependencies = [ops_between_new_input_and_limit[0]] | ||
last_op = ops_between_new_input_and_limit[0] | ||
last_op._output_dependencies = limit_op.output_dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct me if i'm wrong but don't u still need to
- link limit_output_op.output_dependencies.input_dependencies to last_op.output_dependencies
- ops_between_new_input_and_limit[-1] (most upstream op) input dependencies need to link with limit_output_op.output_dependencies
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me draw it out and double check this
- Union operations (pushed to all inputs) | ||
|
||
We stop at: | ||
- Any operator that can modify the number of output rows (Sort, Shuffle, Aggregate, Read etc.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can pushdown limit into these Ops but not past it. For instance, limit pushdown into Sorts involve sorting on keys for the entire Dataset, but only yield limit rows on the Sorted Dataset.
Same for Joins, Groupbys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. https://docs.rs/datafusion-optimizer/48.0.1/src/datafusion_optimizer/push_down_limit.rs.html#38 Datafusion does this for sort whereby limit is embedded into the sort operator.
Signed-off-by: Goutam V <goutam@anyscale.com>
Signed-off-by: Goutam V <goutam@anyscale.com>
Signed-off-by: Goutam V <goutam@anyscale.com>
Why are these changes needed?
Previously, the limit operator push down optimization was disabled because there was no guarantee that
Map
,MapBatches
etc. were not modifying the number of rows. In this change, we pushdown the limit operator forProject
,MapRows
,MapBatches
and forUnion
each union has its own limit operator pushed down on it.Related issue number
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.