Skip to content

Conversation

@norberttech
Copy link
Member

Change Log

Added

  • Reference - representing reference to given entry/entries in DataFrame

Fixed

Changed

Removed

Deprecated

Security


Description

The goal of Reference is to stop using primitive string values as entry references and move into Reference object that might come with things like alias, for example.

The final goal is to replace all string $entry with string|Reference $entry types.
string should still stay for convenience in simple use cases.

Example:

<?php

declare(strict_types=1);

use function Flow\ETL\DSL\struct;
use Flow\ETL\DSL\CSV;
use Flow\ETL\DSL\Transform;
use Flow\ETL\Filesystem\SaveMode;
use Flow\ETL\Flow;
use Flow\ETL\GroupBy\Aggregation;

require __DIR__ . '/../../bootstrap.php';

(new Flow())
    ->extract(CSV::from(__FLOW_DATA__ . '/users.csv'))
    ->rows(Transform::array_unpack('row'))
    ->groupBy('user_id')
    ->aggregate(
        Aggregation::collect(struct('skill', 'value', 'active')->as('skills')),
    )
    ->rows(Transform::to_json('skills'))
    ->write(CSV::to(__FLOW_OUTPUT__ . '/users_aggregated.csv'))
    ->mode(SaveMode::Overwrite)
    ->run();

@norberttech norberttech merged commit cf8cb34 into flow-php:1.x Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant