join() matches rows of two frames on column values, as SQL does: Join::inner, left, right or
left_anti. join_prefix renames the right side's columns, so names never collide. The right
frame is read whole (held in memory, spilled past the memory limit); to look up only what each
batch needs, use joinEach().
Examples
Joins
Description
Documentation
A join matches rows from two frames on a condition.
Code
<?php
declare(strict_types=1);
use function Flow\ETL\DSL\{data_frame, from_array, join_on, to_output};
use Flow\ETL\Join\Join;
require __DIR__ . '/vendor/autoload.php';
$users = [
['id' => 1, 'name' => 'John'],
['id' => 2, 'name' => 'Jane'],
['id' => 3, 'name' => 'Doe'],
['id' => 4, 'name' => 'Bruno'],
];
$emails = [
['id' => 2, 'email' => 'john@email.com'],
['id' => 3, 'email' => 'jane@emial.com'],
['id' => 4, 'email' => 'bruno@email.com'],
];
data_frame()
->read(from_array($users))
->join(
data_frame()->read(from_array($emails)),
join_on(['id' => 'id'], join_prefix: 'joined_'),
Join::left
)
->collect()
->write(to_output(truncate: false))
->run();