Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add test case
  • Loading branch information
haohuaijin committed Jun 22, 2026
commit fc93043a4740aea76b0016f7a6cc019ba3cbd6da
47 changes: 47 additions & 0 deletions datafusion/proto/tests/cases/roundtrip_physical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3666,6 +3666,53 @@ fn test_hash_join_with_dynamic_filter_roundtrip() -> Result<()> {
Ok(())
}

#[test]
fn test_hash_join_swap_clears_dynamic_filter_before_roundtrip() -> Result<()> {
let build_schema = Arc::new(Schema::new(vec![Field::new(
"build_key",
DataType::Int64,
false,
)]));
let probe_schema = Arc::new(Schema::new(vec![
Field::new("probe_payload_0", DataType::Int64, false),
Field::new("probe_payload_1", DataType::Int64, false),
Field::new("probe_key", DataType::Int64, false),
]));

let build_child = Arc::new(EmptyExec::new(Arc::clone(&build_schema)));
let probe_child = Arc::new(EmptyExec::new(Arc::clone(&probe_schema)));
let on: Vec<(Arc<dyn PhysicalExpr>, Arc<dyn PhysicalExpr>)> = vec![(
Arc::new(Column::new("build_key", 0)),
Arc::new(Column::new("probe_key", 2)),
)];

let dynamic_filter = Arc::new(DynamicFilterPhysicalExpr::new(
vec![Arc::new(Column::new("probe_key", 2))],
lit(true),
));
let join = HashJoinExec::try_new(
build_child,
probe_child,
on,
None,
&JoinType::Inner,
None,
PartitionMode::CollectLeft,
NullEquality::NullEqualsNothing,
false,
)?
.with_dynamic_filter_expr(dynamic_filter)?;

let swapped = join.swap_inputs(PartitionMode::CollectLeft)?;

// If HashJoinExec::swap_inputs keeps the old dynamic filter, the swapped
// join still serializes a filter whose child is `probe_key@2`. During
// deserialization, HashJoinExec validates that filter against the new
// right/probe schema (`build_key` only), and fails with an out-of-bounds
// column reference.
roundtrip_test(swapped)
}

/// returns a SessionContext with an empty `netflow` table registered
fn netflow_context() -> Result<SessionContext> {
let ctx = SessionContext::new();
Expand Down
Loading