Combine two datasets based on matching column values, similar to SQL JOIN operations. Supports inner, left, right, and left anti join types.
For large datasets that don't fit in memory, consider using joinEach instead.
composer require flow-php/etl ~0.34.3 Read from various data sources.
Shape and optimize for your needs.
Store and secure in one of many available data sinks.
Combine two datasets based on matching column values, similar to SQL JOIN operations. Supports inner, left, right, and left anti join types.
For large datasets that don't fit in memory, consider using joinEach instead.
<?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' => '[email protected]'],
['id' => 3, 'email' => '[email protected]'],
['id' => 4, 'email' => '[email protected]'],
];
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();