flow php

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

Code

<?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__ . '/../../../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();

Contributors

Join us on GitHub external resource
scroll back to top