Skip to content

Commit 5ad1576

Browse files
cigraingerclaude
andcommitted
test: peer-node integration test for auto-broadcast join routing
Verifies that Dux.distribute(workers) |> Dux.join(local_right, on: :id) automatically broadcasts the local right side to peer worker nodes. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 6c3d437 commit 5ad1576

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

‎test/dux/distributed_correctness_peer_test.exs‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,49 @@ defmodule Dux.DistributedCorrectnessPeerTest do
375375
end
376376
end
377377

378+
test "auto-broadcast join via distribute + join on peers" do
379+
{peer1, node1} = start_peer(:auto_bcast1)
380+
{peer2, node2} = start_peer(:auto_bcast2)
381+
382+
try do
383+
{:ok, w1} = start_worker_on(node1)
384+
{:ok, w2} = start_worker_on(node2)
385+
Process.sleep(200)
386+
387+
# Left: distributed across peer workers
388+
left =
389+
Dux.from_query("SELECT x AS id, x * 10 AS amount FROM range(1, 6) t(x)")
390+
|> Dux.distribute([w1, w2])
391+
392+
# Right: local table ref — will be auto-broadcast by Coordinator
393+
right =
394+
Dux.from_list([
395+
%{id: 1, name: "Alice"},
396+
%{id: 3, name: "Carol"},
397+
%{id: 5, name: "Eve"}
398+
])
399+
|> Dux.compute()
400+
401+
result =
402+
left
403+
|> Dux.join(right, on: :id)
404+
|> Dux.sort_by(:id)
405+
|> Dux.to_rows()
406+
407+
# 3 matching ids per worker × 2 workers = 6 rows
408+
assert length(result) == 6
409+
410+
names = Enum.map(result, & &1["name"]) |> Enum.uniq() |> Enum.sort()
411+
assert names == ["Alice", "Carol", "Eve"]
412+
413+
# All rows have amount from left side
414+
assert Enum.all?(result, &is_integer(&1["amount"]))
415+
after
416+
:peer.stop(peer1)
417+
:peer.stop(peer2)
418+
end
419+
end
420+
378421
test "shuffle join across peer workers" do
379422
{peer1, node1} = start_peer(:shuffle_peer1)
380423
{peer2, node2} = start_peer(:shuffle_peer2)

0 commit comments

Comments
 (0)