flow php

Example: Partition pruning

Topic: Partitioning

Code

<?php

declare(strict_types=1);

use function Flow\ETL\Adapter\CSV\from_csv;
use function Flow\ETL\DSL\{data_frame, lit, ref, to_stream};

require __DIR__ . '/../../../autoload.php';

data_frame()
    ->read(from_csv(__DIR__ . '/input/color=*/sku=*/*.csv'))
    ->filterPartitions(ref('color')->notEquals(lit('green')))
    ->collect()
    ->write(to_stream(__DIR__ . '/output.txt', truncate: false))
    ->run();

Output

+----+-------+-----------+
| id | color |       sku |
+----+-------+-----------+
|  7 |  blue | PRODUCT01 |
|  8 |  blue | PRODUCT02 |
|  1 |   red | PRODUCT01 |
|  2 |   red | PRODUCT02 |
|  3 |   red | PRODUCT03 |
+----+-------+-----------+
5 rows

Contributors

Join us on GitHub external resource
scroll back to top