Skip to content

Commit 2ccaa96

Browse files
committed
Clena up
Signed-off-by: Austin Liu <austin362667@gmail.com> Clean up Signed-off-by: Austin Liu <austin362667@gmail.com>
1 parent 3337d66 commit 2ccaa96

File tree

10 files changed

+32
-26
lines changed

10 files changed

+32
-26
lines changed

datafusion/core/src/physical_planner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2558,7 +2558,7 @@ mod tests {
25582558
unimplemented!("NoOp");
25592559
}
25602560

2561-
fn allows_limit_to_inputs(&self) -> bool {
2561+
fn supports_limit_pushdown(&self) -> bool {
25622562
false // Disallow limit push-down by default
25632563
}
25642564
}

datafusion/core/tests/user_defined/user_defined_plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl UserDefinedLogicalNodeCore for TopKPlanNode {
444444
})
445445
}
446446

447-
fn allows_limit_to_inputs(&self) -> bool {
447+
fn supports_limit_pushdown(&self) -> bool {
448448
false // Disallow limit push-down by default
449449
}
450450
}

datafusion/expr/src/logical_plan/extension.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,15 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
196196
fn dyn_eq(&self, other: &dyn UserDefinedLogicalNode) -> bool;
197197
fn dyn_ord(&self, other: &dyn UserDefinedLogicalNode) -> Option<Ordering>;
198198

199-
/// Indicates to the optimizer if its safe to push a limit down past
200-
/// this extension node
201-
fn allows_limit_to_inputs(&self) -> bool;
199+
/// Returns `true` if a limit can be safely pushed down through this
200+
/// `UserDefinedLogicalNode` node.
201+
///
202+
/// If this method returns `true`, and the query plan contains a limit at
203+
/// the output of this node, DataFusion will push the limit to the input
204+
/// of this node.
205+
fn supports_limit_pushdown(&self) -> bool {
206+
false
207+
}
202208
}
203209

204210
impl Hash for dyn UserDefinedLogicalNode {
@@ -300,9 +306,15 @@ pub trait UserDefinedLogicalNodeCore:
300306
None
301307
}
302308

303-
/// Indicates to the optimizer if its safe to push a limit down past
304-
/// this extension node
305-
fn allows_limit_to_inputs(&self) -> bool;
309+
/// Returns `true` if a limit can be safely pushed down through this
310+
/// `UserDefinedLogicalNode` node.
311+
///
312+
/// If this method returns `true`, and the query plan contains a limit at
313+
/// the output of this node, DataFusion will push the limit to the input
314+
/// of this node.
315+
fn supports_limit_pushdown(&self) -> bool {
316+
false // Disallow limit push-down by default
317+
}
306318
}
307319

308320
/// Automatically derive UserDefinedLogicalNode to `UserDefinedLogicalNode`
@@ -370,8 +382,8 @@ impl<T: UserDefinedLogicalNodeCore> UserDefinedLogicalNode for T {
370382
.and_then(|other| self.partial_cmp(other))
371383
}
372384

373-
fn allows_limit_to_inputs(&self) -> bool {
374-
self.allows_limit_to_inputs()
385+
fn supports_limit_pushdown(&self) -> bool {
386+
self.supports_limit_pushdown()
375387
}
376388
}
377389

datafusion/optimizer/src/analyzer/subquery.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ mod test {
386386
})
387387
}
388388

389-
fn allows_limit_to_inputs(&self) -> bool {
389+
fn supports_limit_pushdown(&self) -> bool {
390390
false // Disallow limit push-down by default
391391
}
392392
}

datafusion/optimizer/src/optimize_projections/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ mod tests {
896896
Some(vec![output_columns.to_vec()])
897897
}
898898

899-
fn allows_limit_to_inputs(&self) -> bool {
899+
fn supports_limit_pushdown(&self) -> bool {
900900
false // Disallow limit push-down by default
901901
}
902902
}
@@ -996,7 +996,7 @@ mod tests {
996996
Some(vec![left_reqs, right_reqs])
997997
}
998998

999-
fn allows_limit_to_inputs(&self) -> bool {
999+
fn supports_limit_pushdown(&self) -> bool {
10001000
false // Disallow limit push-down by default
10011001
}
10021002
}

datafusion/optimizer/src/push_down_filter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1500,7 +1500,7 @@ mod tests {
15001500
})
15011501
}
15021502

1503-
fn allows_limit_to_inputs(&self) -> bool {
1503+
fn supports_limit_pushdown(&self) -> bool {
15041504
false // Disallow limit push-down by default
15051505
}
15061506
}

datafusion/optimizer/src/push_down_limit.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,7 @@ impl OptimizerRule for PushDownLimit {
154154
Ok(Transformed::yes(LogicalPlan::SubqueryAlias(subquery_alias)))
155155
}
156156
LogicalPlan::Extension(extension_plan)
157-
if !extension_plan.node.allows_limit_to_inputs() =>
158-
{
159-
// If push down is not allowed, keep the original limit
160-
original_limit(skip, fetch, LogicalPlan::Extension(extension_plan))
161-
}
162-
LogicalPlan::Extension(extension_plan)
163-
if extension_plan.node.allows_limit_to_inputs() =>
157+
if extension_plan.node.supports_limit_pushdown() =>
164158
{
165159
let new_children = extension_plan
166160
.node
@@ -353,7 +347,7 @@ mod test {
353347
})
354348
}
355349

356-
fn allows_limit_to_inputs(&self) -> bool {
350+
fn supports_limit_pushdown(&self) -> bool {
357351
true // Allow limit push-down
358352
}
359353
}
@@ -406,7 +400,7 @@ mod test {
406400
})
407401
}
408402

409-
fn allows_limit_to_inputs(&self) -> bool {
403+
fn supports_limit_pushdown(&self) -> bool {
410404
false // Disallow limit push-down by default
411405
}
412406
}

datafusion/optimizer/src/test/user_defined.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl UserDefinedLogicalNodeCore for TestUserDefinedPlanNode {
7777
})
7878
}
7979

80-
fn allows_limit_to_inputs(&self) -> bool {
80+
fn supports_limit_pushdown(&self) -> bool {
8181
false // Disallow limit push-down by default
8282
}
8383
}

datafusion/proto/tests/cases/roundtrip_logical_plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ impl UserDefinedLogicalNodeCore for TopKPlanNode {
10611061
})
10621062
}
10631063

1064-
fn allows_limit_to_inputs(&self) -> bool {
1064+
fn supports_limit_pushdown(&self) -> bool {
10651065
false // Disallow limit push-down by default
10661066
}
10671067
}

datafusion/substrait/tests/cases/roundtrip_logical_plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl UserDefinedLogicalNode for MockUserDefinedLogicalPlan {
150150
unimplemented!()
151151
}
152152

153-
fn allows_limit_to_inputs(&self) -> bool {
153+
fn supports_limit_pushdown(&self) -> bool {
154154
false // Disallow limit push-down by default
155155
}
156156
}

0 commit comments

Comments
 (0)