Example: Parquet
Topic: Data writing
Description
Write data to a parquet file.
function to_parquet(string|Path $path) : Loader
Additional options:
withOptions(\Flow\Parquet\Options $options)
- Options for the parquet writer
withCompression(Compressions $compression)
- default Compressions::SNAPPY
, supports one of the following Compressions
withSchema(Schema $schema)
- when provided writer will use this instead of inferring schema from each rows batch
composer.json
{
"name": "flow-php/examples",
"description": "Flow PHP - Examples",
"license": "MIT",
"type": "library",
"require": {
"flow-php/etl": "1.x-dev",
"flow-php/etl-adapter-parquet": "1.x-dev",
"flow-php/parquet": "1.x-dev",
"flow-php/snappy": "1.x-dev"
}
}
code.php
<?php
declare(strict_types=1);
use function Flow\ETL\Adapter\Parquet\to_parquet;
use function Flow\ETL\DSL\{data_frame, from_array, overwrite};
require __DIR__ . '/vendor/autoload.php';
data_frame()
->read(from_array([
['id' => 1],
['id' => 2],
['id' => 3],
['id' => 4],
['id' => 5],
]))
->collect()
->saveMode(overwrite())
->write(to_parquet(__DIR__ . '/output.parquet'))
->run();