Skip to content
Search
Examples

Transformations

Description

size() counts the elements of a list or map column (the characters of a string) without unpacking it, so the array itself stays in the row.

Documentation

Transformations are expressions over a row, evaluated column by column.

Code

<?php

declare(strict_types=1);

use function Flow\ETL\DSL\{data_frame, from_array, int_schema, map_schema, ref, schema, to_output};
use function Flow\Types\DSL\{type_integer, type_map, type_string};

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

data_frame()
    ->read(from_array(
        [['id' => 1, 'array' => ['a' => 1, 'b' => 2, 'c' => 3]]],
        schema(int_schema('id'), map_schema('array', type_map(type_string(), type_integer()))),
    ))
    ->withColumn('array_size', ref('array')->size())
    ->write(to_output(truncate: false))
    ->run();
Contributors

Built in the open.

Join us on GitHub
scroll back to top