MCPcopy Create free account
hub / github.com/apache/datafusion / join_agg_yields

Function join_agg_yields

datafusion/core/tests/execution/coop.rs:618–699  ·  view source on GitHub ↗
(
    #[values(false, true)] pretend_infinite: bool,
)

Source from the content-addressed store, hash-verified

616#[rstest]
617#[tokio::test]
618async fn join_agg_yields(
619 #[values(false, true)] pretend_infinite: bool,
620) -> Result<(), Box<dyn Error>> {
621 // Session, schema, and a single 8 K‐row batch for each side
622 let session_ctx = SessionContext::new();
623
624 // on the right side, we’ll shift each value by +1 so that not everything joins,
625 // but plenty of matching keys exist (e.g. 0 on left matches 1 on right, etc.)
626 let infinite_left = make_lazy_exec_with_range("value", -10..10, false);
627 let infinite_right =
628 make_lazy_exec_with_range("value", 0..i64::MAX, pretend_infinite);
629
630 // 2b) Create Join keys → join on “value” = “value”
631 let left_keys: Vec<Arc<dyn PhysicalExpr>> = vec![Arc::new(Column::new("value", 0))];
632 let right_keys: Vec<Arc<dyn PhysicalExpr>> = vec![Arc::new(Column::new("value", 0))];
633
634 let part_left = Partitioning::Hash(left_keys, 1);
635 let part_right = Partitioning::Hash(right_keys, 1);
636
637 // Wrap each side in Repartition so they are both hashed into 1 partition
638 let hashed_left = Arc::new(RepartitionExec::try_new(
639 Arc::new(infinite_left),
640 part_left,
641 )?);
642 let hashed_right = Arc::new(RepartitionExec::try_new(
643 Arc::new(infinite_right),
644 part_right,
645 )?);
646
647 // Build an Inner HashJoinExec → left.value = right.value
648 let join = Arc::new(HashJoinExec::try_new(
649 hashed_left,
650 hashed_right,
651 vec![(
652 Arc::new(Column::new("value", 0)),
653 Arc::new(Column::new("value", 0)),
654 )],
655 None,
656 &JoinType::Inner,
657 None,
658 PartitionMode::CollectLeft,
659 NullEquality::NullEqualsNull,
660 false,
661 )?);
662
663 // Project only one column (“value” from the left side) because we just want to sum that
664 let input_schema = join.schema();
665
666 let proj_expr = vec![ProjectionExpr::new(
667 Arc::new(Column::new_with_schema("value", &input_schema)?) as _,
668 "value",
669 )];
670
671 let projection = Arc::new(ProjectionExec::try_new(proj_expr, join)?);
672 let projection_schema = projection.schema();
673
674 let output_fields = vec![Field::new("total", DataType::Int64, true)];
675 let output_schema = Arc::new(Schema::new(output_fields));

Callers

nothing calls this directly

Calls 7

newFunction · 0.85
query_yieldsFunction · 0.85
schemaMethod · 0.45
buildMethod · 0.45
aliasMethod · 0.45
task_ctxMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…