cool9850311 commented on code in PR #27395:
URL: https://github.com/apache/datafusion/pull/27395#discussion_r4584904271
##########
datafusion/core/tests/physical_optimizer/projection_pushdown.rs:
##########
@@ -2255,52 +2274,85 @@ async fn split_descends_through_three_hosts() ->
Result<()> {
Arc::new(ProjectionExec::try_new(limit_split_exprs(&schema)?, outer)?);
assert_snapshot!(
- optimized_plan_text(projection)?,
- @r" ProjectionExec: expr=[__datafusion_leaf_0@1 as v, id@0 + 1 as w]
- GlobalLimitExec: skip=3, fetch=3
- GlobalLimitExec: skip=2, fetch=6
- GlobalLimitExec: skip=1, fetch=9
- DataSourceExec: file_groups={1 group: [[x]]}, projection=[id,
get_field(s@1, value) as __datafusion_leaf_0], file_type=parquet
+ OptimizationTest::new(projection, ProjectionPushdown::new(), false),
+ @r"
+ OptimizationTest:
+ input:
+ - ProjectionExec: expr=[get_field(s@1, value) as v, id@0 + 1 as w]
+ - GlobalLimitExec: skip=3, fetch=3
+ - GlobalLimitExec: skip=2, fetch=6
+ - GlobalLimitExec: skip=1, fetch=9
+ - DataSourceExec: file_groups={1 group: [[x]]},
projection=[id, s], file_type=parquet
+ output:
+ Ok:
+ - ProjectionExec: expr=[__datafusion_leaf_0@1 as v, id@0 + 1 as w]
+ - GlobalLimitExec: skip=3, fetch=3
+ - GlobalLimitExec: skip=2, fetch=6
+ - GlobalLimitExec: skip=1, fetch=9
+ - DataSourceExec: file_groups={1 group: [[x]]},
projection=[id, get_field(s@1, value) as __datafusion_leaf_0], file_type=parquet
"
);
Ok(())
}
-/// The nodes that meet the host conditions but are deliberately left out of
-/// the allowlist, in the other role they can play: the bottom of the chain.
-/// Each delegates `try_swapping_with_projection` to its own input, so the
split
-/// commits and the scan narrows in one pass. Every other test here bottoms out
-/// at a `DataSourceExec` or at a source that refuses. `CoalesceBatchesExec`
-/// behaves the same way but is deprecated in 52.0.0 and nothing constructs it
-/// any more, so it is not pinned here.
+/// `CooperativeExec` and `BufferExec` are not hosts, but as the *bottom* of
the
+/// chain they delegate the swap to their own input, so the split commits and
+/// the scan narrows in one pass.
#[tokio::test]
async fn split_commits_at_a_pass_through_bottom() -> Result<()> {
- for bottom in ["CooperativeExec", "BufferExec: capacity=4"] {
- let (schema, scan) = limit_split_scan()?;
- let wrapped: Arc<dyn ExecutionPlan> = if
bottom.starts_with("Cooperative") {
- Arc::new(CooperativeExec::new(scan))
- } else {
- Arc::new(BufferExec::new(scan, 4))
- };
- let limit: Arc<dyn ExecutionPlan> =
- Arc::new(GlobalLimitExec::new(wrapped, 1, Some(3)));
- let projection: Arc<dyn ExecutionPlan> =
- Arc::new(ProjectionExec::try_new(limit_split_exprs(&schema)?,
limit)?);
-
- let text = optimized_plan_text(projection)?;
- assert!(text.contains(bottom), "{bottom} missing from:\n{text}");
- assert!(
- text.contains(
- "projection=[id, get_field(s@1, value) as __datafusion_leaf_0]"
- ),
- "the scan did not absorb the leaf below {bottom}:\n{text}"
- );
- }
+ let (schema, scan) = limit_split_scan()?;
+ let cooperative: Arc<dyn ExecutionPlan> =
Arc::new(CooperativeExec::new(scan));
+ let limit: Arc<dyn ExecutionPlan> =
+ Arc::new(GlobalLimitExec::new(cooperative, 1, Some(3)));
+ let projection: Arc<dyn ExecutionPlan> =
+ Arc::new(ProjectionExec::try_new(limit_split_exprs(&schema)?, limit)?);
+
+ assert_snapshot!(
+ OptimizationTest::new(projection, ProjectionPushdown::new(), false),
+ @r"
+ OptimizationTest:
+ input:
+ - ProjectionExec: expr=[get_field(s@1, value) as v, id@0 + 1 as w]
+ - GlobalLimitExec: skip=1, fetch=3
+ - CooperativeExec
+ - DataSourceExec: file_groups={1 group: [[x]]}, projection=[id,
s], file_type=parquet
+ output:
+ Ok:
+ - ProjectionExec: expr=[__datafusion_leaf_0@1 as v, id@0 + 1 as w]
+ - GlobalLimitExec: skip=1, fetch=3
+ - CooperativeExec
+ - DataSourceExec: file_groups={1 group: [[x]]},
projection=[id, get_field(s@1, value) as __datafusion_leaf_0], file_type=parquet
+ "
Review Comment:
@alamb
Is it what you want?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]