From 0efd397c9f1bbf9b003da61a815e164f6827e3b3 Mon Sep 17 00:00:00 2001 From: Norbert Orzechowicz Date: Thu, 25 Apr 2024 22:59:07 +0200 Subject: [PATCH] Updated examples --- .../topics/aggregations/group_by/code.php | 6 +- .../topics/aggregations/group_by/output.txt | 12 +-- .../data_source/http_dynamic/output.txt | 2 +- .../topics/data_source/sequence_date/code.php | 2 +- .../data_source/sequence_date/output.txt | 92 +------------------ .../partitioning/partition_pruning/output.txt | 6 +- .../topics/partitioning/reading/output.txt | 30 +++--- 7 files changed, 30 insertions(+), 120 deletions(-) diff --git a/examples/topics/aggregations/group_by/code.php b/examples/topics/aggregations/group_by/code.php index 9e147d2bd..3cb0c1a62 100644 --- a/examples/topics/aggregations/group_by/code.php +++ b/examples/topics/aggregations/group_by/code.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use function Flow\ETL\DSL\{data_frame, from_array, ref, to_stream}; +use function Flow\ETL\DSL\{count, data_frame, from_array, ref, to_stream}; require __DIR__ . '/../../../autoload.php'; @@ -19,7 +19,7 @@ ['id' => 9, 'group' => 'A'], ['id' => 10, 'group' => 'B'], ])) - ->groupBy(ref('group')) // GroupedDataFrame - ->toDF() // DataFrame + ->groupBy(ref('group')) + ->aggregate(count(ref('group'))) ->write(to_stream(__DIR__ . '/output.txt', truncate: false)) ->run(); diff --git a/examples/topics/aggregations/group_by/output.txt b/examples/topics/aggregations/group_by/output.txt index 0056816f0..ec60d8208 100644 --- a/examples/topics/aggregations/group_by/output.txt +++ b/examples/topics/aggregations/group_by/output.txt @@ -1,7 +1,7 @@ -+-------+ -| group | -+-------+ -| A | -| B | -+-------+ ++-------+-------------+ +| group | group_count | ++-------+-------------+ +| A | 5 | +| B | 5 | ++-------+-------------+ 2 rows diff --git a/examples/topics/data_source/http_dynamic/output.txt b/examples/topics/data_source/http_dynamic/output.txt index 94d4484d5..1f8ddd4d6 100644 --- a/examples/topics/data_source/http_dynamic/output.txt +++ b/examples/topics/data_source/http_dynamic/output.txt @@ -1,6 +1,6 @@ +----------+----------+---------------------+--------------+-----------+-----------------------------+----------------------+ | login | name | blog | public_repos | followers | html_url | created_at | +----------+----------+---------------------+--------------+-----------+-----------------------------+----------------------+ -| flow-php | Flow PHP | http://flow-php.com | 30 | 89 | https://github.com/flow-php | 2020-10-26T18:40:27Z | +| flow-php | Flow PHP | http://flow-php.com | 30 | 91 | https://github.com/flow-php | 2020-10-26T18:40:27Z | +----------+----------+---------------------+--------------+-----------+-----------------------------+----------------------+ 1 rows diff --git a/examples/topics/data_source/sequence_date/code.php b/examples/topics/data_source/sequence_date/code.php index 83c4c678a..3ff19cd18 100644 --- a/examples/topics/data_source/sequence_date/code.php +++ b/examples/topics/data_source/sequence_date/code.php @@ -11,7 +11,7 @@ 'date', new DateTimeImmutable('2024-01-01 00:00:00 UTC'), new DateInterval('P1D'), - new DateTimeImmutable('now + 60 days'), + new DateTimeImmutable('2024-01-01 00:00:00 +60 days'), )) ->collect() ->write(to_stream(__DIR__ . '/output.txt', truncate: false)) diff --git a/examples/topics/data_source/sequence_date/output.txt b/examples/topics/data_source/sequence_date/output.txt index 7ce0cbf56..6b3d483df 100644 --- a/examples/topics/data_source/sequence_date/output.txt +++ b/examples/topics/data_source/sequence_date/output.txt @@ -61,95 +61,5 @@ | 2024-02-27T00:00:00+00:00 | | 2024-02-28T00:00:00+00:00 | | 2024-02-29T00:00:00+00:00 | -| 2024-03-01T00:00:00+00:00 | -| 2024-03-02T00:00:00+00:00 | -| 2024-03-03T00:00:00+00:00 | -| 2024-03-04T00:00:00+00:00 | -| 2024-03-05T00:00:00+00:00 | -| 2024-03-06T00:00:00+00:00 | -| 2024-03-07T00:00:00+00:00 | -| 2024-03-08T00:00:00+00:00 | -| 2024-03-09T00:00:00+00:00 | -| 2024-03-10T00:00:00+00:00 | -| 2024-03-11T00:00:00+00:00 | -| 2024-03-12T00:00:00+00:00 | -| 2024-03-13T00:00:00+00:00 | -| 2024-03-14T00:00:00+00:00 | -| 2024-03-15T00:00:00+00:00 | -| 2024-03-16T00:00:00+00:00 | -| 2024-03-17T00:00:00+00:00 | -| 2024-03-18T00:00:00+00:00 | -| 2024-03-19T00:00:00+00:00 | -| 2024-03-20T00:00:00+00:00 | -| 2024-03-21T00:00:00+00:00 | -| 2024-03-22T00:00:00+00:00 | -| 2024-03-23T00:00:00+00:00 | -| 2024-03-24T00:00:00+00:00 | -| 2024-03-25T00:00:00+00:00 | -| 2024-03-26T00:00:00+00:00 | -| 2024-03-27T00:00:00+00:00 | -| 2024-03-28T00:00:00+00:00 | -| 2024-03-29T00:00:00+00:00 | -| 2024-03-30T00:00:00+00:00 | -| 2024-03-31T00:00:00+00:00 | -| 2024-04-01T00:00:00+00:00 | -| 2024-04-02T00:00:00+00:00 | -| 2024-04-03T00:00:00+00:00 | -| 2024-04-04T00:00:00+00:00 | -| 2024-04-05T00:00:00+00:00 | -| 2024-04-06T00:00:00+00:00 | -| 2024-04-07T00:00:00+00:00 | -| 2024-04-08T00:00:00+00:00 | -| 2024-04-09T00:00:00+00:00 | -| 2024-04-10T00:00:00+00:00 | -| 2024-04-11T00:00:00+00:00 | -| 2024-04-12T00:00:00+00:00 | -| 2024-04-13T00:00:00+00:00 | -| 2024-04-14T00:00:00+00:00 | -| 2024-04-15T00:00:00+00:00 | -| 2024-04-16T00:00:00+00:00 | -| 2024-04-17T00:00:00+00:00 | -| 2024-04-18T00:00:00+00:00 | -| 2024-04-19T00:00:00+00:00 | -| 2024-04-20T00:00:00+00:00 | -| 2024-04-21T00:00:00+00:00 | -| 2024-04-22T00:00:00+00:00 | -| 2024-04-23T00:00:00+00:00 | -| 2024-04-24T00:00:00+00:00 | -| 2024-04-25T00:00:00+00:00 | -| 2024-04-26T00:00:00+00:00 | -| 2024-04-27T00:00:00+00:00 | -| 2024-04-28T00:00:00+00:00 | -| 2024-04-29T00:00:00+00:00 | -| 2024-04-30T00:00:00+00:00 | -| 2024-05-01T00:00:00+00:00 | -| 2024-05-02T00:00:00+00:00 | -| 2024-05-03T00:00:00+00:00 | -| 2024-05-04T00:00:00+00:00 | -| 2024-05-05T00:00:00+00:00 | -| 2024-05-06T00:00:00+00:00 | -| 2024-05-07T00:00:00+00:00 | -| 2024-05-08T00:00:00+00:00 | -| 2024-05-09T00:00:00+00:00 | -| 2024-05-10T00:00:00+00:00 | -| 2024-05-11T00:00:00+00:00 | -| 2024-05-12T00:00:00+00:00 | -| 2024-05-13T00:00:00+00:00 | -| 2024-05-14T00:00:00+00:00 | -| 2024-05-15T00:00:00+00:00 | -| 2024-05-16T00:00:00+00:00 | -| 2024-05-17T00:00:00+00:00 | -| 2024-05-18T00:00:00+00:00 | -| 2024-05-19T00:00:00+00:00 | -| 2024-05-20T00:00:00+00:00 | -| 2024-05-21T00:00:00+00:00 | -| 2024-05-22T00:00:00+00:00 | -| 2024-05-23T00:00:00+00:00 | -| 2024-05-24T00:00:00+00:00 | -| 2024-05-25T00:00:00+00:00 | -| 2024-05-26T00:00:00+00:00 | -| 2024-05-27T00:00:00+00:00 | -| 2024-05-28T00:00:00+00:00 | -| 2024-05-29T00:00:00+00:00 | +---------------------------+ -150 rows +60 rows diff --git a/examples/topics/partitioning/partition_pruning/output.txt b/examples/topics/partitioning/partition_pruning/output.txt index 45432feb5..4aba31182 100644 --- a/examples/topics/partitioning/partition_pruning/output.txt +++ b/examples/topics/partitioning/partition_pruning/output.txt @@ -1,10 +1,10 @@ +----+-------+-----------+ | id | color | sku | +----+-------+-----------+ +| 7 | blue | PRODUCT01 | +| 8 | blue | PRODUCT02 | +| 1 | red | PRODUCT01 | | 2 | red | PRODUCT02 | | 3 | red | PRODUCT03 | -| 1 | red | PRODUCT01 | -| 8 | blue | PRODUCT02 | -| 7 | blue | PRODUCT01 | +----+-------+-----------+ 5 rows diff --git a/examples/topics/partitioning/reading/output.txt b/examples/topics/partitioning/reading/output.txt index eda133b8e..ac2f08434 100644 --- a/examples/topics/partitioning/reading/output.txt +++ b/examples/topics/partitioning/reading/output.txt @@ -1,20 +1,20 @@ +----+-------+-----------+ | id | color | sku | +----+-------+-----------+ -| 5 | green | PRODUCT02 | +| 7 | blue | PRODUCT01 | +----+-------+-----------+ Partitions: - - color=green - - sku=PRODUCT02 + - color=blue + - sku=PRODUCT01 1 rows +----+-------+-----------+ | id | color | sku | +----+-------+-----------+ -| 6 | green | PRODUCT03 | +| 8 | blue | PRODUCT02 | +----+-------+-----------+ Partitions: - - color=green - - sku=PRODUCT03 + - color=blue + - sku=PRODUCT02 1 rows +----+-------+-----------+ | id | color | sku | @@ -28,19 +28,19 @@ Partitions: +----+-------+-----------+ | id | color | sku | +----+-------+-----------+ -| 2 | red | PRODUCT02 | +| 5 | green | PRODUCT02 | +----+-------+-----------+ Partitions: - - color=red + - color=green - sku=PRODUCT02 1 rows +----+-------+-----------+ | id | color | sku | +----+-------+-----------+ -| 3 | red | PRODUCT03 | +| 6 | green | PRODUCT03 | +----+-------+-----------+ Partitions: - - color=red + - color=green - sku=PRODUCT03 1 rows +----+-------+-----------+ @@ -55,18 +55,18 @@ Partitions: +----+-------+-----------+ | id | color | sku | +----+-------+-----------+ -| 8 | blue | PRODUCT02 | +| 2 | red | PRODUCT02 | +----+-------+-----------+ Partitions: - - color=blue + - color=red - sku=PRODUCT02 1 rows +----+-------+-----------+ | id | color | sku | +----+-------+-----------+ -| 7 | blue | PRODUCT01 | +| 3 | red | PRODUCT03 | +----+-------+-----------+ Partitions: - - color=blue - - sku=PRODUCT01 + - color=red + - sku=PRODUCT03 1 rows