-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow to change order of entries through select transformation * Added dedicated transformer allowing developers to reorder entries by custom strategies * Added entries reorder example * CS Fixes * Fixed static analysis errors
- Loading branch information
1 parent
cc7013a
commit 6dd9cce
Showing
25 changed files
with
796 additions
and
205 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | | ||
+----------+----------+---------------------+--------------+-----------+-----------------------------+----------------------+ | ||
+----------+-----------------------------+---------------------+----------+--------------+-----------+----------------------+ | ||
| name | html_url | blog | login | public_repos | followers | created_at | | ||
+----------+-----------------------------+---------------------+----------+--------------+-----------+----------------------+ | ||
| Flow PHP | https://github.com/flow-php | http://flow-php.com | flow-php | 30 | 89 | 2020-10-26T18:40:27Z | | ||
+----------+-----------------------------+---------------------+----------+--------------+-----------+----------------------+ | ||
1 rows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use function Flow\ETL\DSL\{array_entry, | ||
bool_entry, | ||
compare_entries_by_type_and_name, | ||
data_frame, | ||
datetime_entry, | ||
float_entry, | ||
from_rows, | ||
int_entry, | ||
json_entry, | ||
list_entry, | ||
map_entry, | ||
object_entry, | ||
row, | ||
rows, | ||
str_entry, | ||
struct_element, | ||
struct_entry, | ||
struct_type, | ||
to_output, | ||
to_stream, | ||
type_float, | ||
type_int, | ||
type_list, | ||
type_map, | ||
type_string, | ||
uuid_entry}; | ||
use Ramsey\Uuid\Uuid; | ||
|
||
data_frame() | ||
->read(from_rows(rows( | ||
row( | ||
int_entry('int_a', 1), | ||
int_entry('int_b', 1), | ||
float_entry('float_a', \random_int(100, 100000) / 100), | ||
float_entry('float_b', \random_int(100, 100000) / 100), | ||
bool_entry('bool', false), | ||
bool_entry('bool_a', false), | ||
bool_entry('bool_c', false), | ||
datetime_entry('datetime_d', new DateTimeImmutable('now')), | ||
datetime_entry('datetime_z', new DateTimeImmutable('now')), | ||
str_entry('string_a', 'string'), | ||
str_entry('string_b', 'string'), | ||
uuid_entry('uuid', new Flow\ETL\Row\Entry\Type\Uuid(Uuid::uuid4())), | ||
json_entry('json', ['id' => 1, 'status' => 'NEW']), | ||
array_entry( | ||
'array', | ||
[ | ||
['id' => 1, 'status' => 'NEW'], | ||
['id' => 2, 'status' => 'PENDING'], | ||
] | ||
), | ||
list_entry('list', [1, 2, 3], type_list(type_int())), | ||
map_entry('map', [0 => 'zero', 1 => 'one', 2 => 'two'], type_map(type_int(), type_string())), | ||
struct_entry( | ||
'struct', | ||
[ | ||
'street' => 'street', | ||
'city' => 'city', | ||
'zip' => 'zip', | ||
'country' => 'country', | ||
'location' => ['lat' => 1.5, 'lon' => 1.5], | ||
], | ||
struct_type([ | ||
struct_element('street', type_string()), | ||
struct_element('city', type_string()), | ||
struct_element('zip', type_string()), | ||
struct_element('country', type_string()), | ||
struct_element( | ||
'location', | ||
struct_type([ | ||
struct_element('lat', type_float()), | ||
struct_element('lon', type_float()), | ||
]) | ||
), | ||
]), | ||
), | ||
object_entry('object', new ArrayIterator([1, 2, 3])), | ||
) | ||
))) | ||
->reorderEntries(compare_entries_by_type_and_name()) | ||
->write(to_output(false)) | ||
->write(to_stream(__DIR__ . '/output.txt', truncate: false)) | ||
->run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
+--------------------------------------+-------+-------+-------+--------+--------+---------+---------+---------------------------+---------------------------+----------+----------+-------------------------------------------------------+---------+-------------------------+----------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+ | ||
| uuid | int_a | int_b | bool | bool_a | bool_c | float_a | float_b | datetime_d | datetime_z | string_a | string_b | array | list | json | map | object | struct | | ||
+--------------------------------------+-------+-------+-------+--------+--------+---------+---------+---------------------------+---------------------------+----------+----------+-------------------------------------------------------+---------+-------------------------+----------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+ | ||
| 1fb2af91-332b-409f-b314-d26969651f1d | 1 | 1 | false | false | false | 468.02 | 75.21 | 2024-04-27T14:24:02+00:00 | 2024-04-27T14:24:02+00:00 | string | string | [{"id":1,"status":"NEW"},{"id":2,"status":"PENDING"}] | [1,2,3] | {"id":1,"status":"NEW"} | ["zero","one","two"] | ArrayIterator Object( [storage:ArrayIterator:private] => Array ( [0] => 1 [1] => 2 [2] => 3 )) | {"street":"street","city":"city","zip":"zip","country":"country","location":{"lat":1.5,"lon":1.5}} | | ||
+--------------------------------------+-------+-------+-------+--------+--------+---------+---------+---------------------------+---------------------------+----------+----------+-------------------------------------------------------+---------+-------------------------+----------------------+------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------+ | ||
1 rows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
+----------+----------+---------------------+--------------+-----------+-----------------------------+----------------------+ | ||
| login | name | blog | public_repos | followers | html_url | created_at | | ||
+----------+----------+---------------------+--------------+-----------+-----------------------------+----------------------+ | ||
| flow-php | Flow PHP | http://flow-php.com | 30 | 91 | https://github.com/flow-php | 2020-10-26T18:40:27Z | | ||
+----------+----------+---------------------+--------------+-----------+-----------------------------+----------------------+ | ||
+----------+-----------------------------+---------------------+----------+--------------+-----------+----------------------+ | ||
| name | html_url | blog | login | public_repos | followers | created_at | | ||
+----------+-----------------------------+---------------------+----------+--------------+-----------+----------------------+ | ||
| Flow PHP | https://github.com/flow-php | http://flow-php.com | flow-php | 30 | 91 | 2020-10-26T18:40:27Z | | ||
+----------+-----------------------------+---------------------+----------+--------------+-----------+----------------------+ | ||
1 rows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.