Skip to content

Commit 5758cef

Browse files
authored
Remove of MapKe/MapValue/ListElement/StructureElement objects (#1343)
* Removed MapValue and MapKey * Removed ListElement object * Dont allow to use nullable types as map key * Removed StructureElement * Updated DSL json
1 parent 315aebb commit 5758cef

File tree

54 files changed

+700
-1179
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+700
-1179
lines changed

UPGRADE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,29 @@ Please follow the instructions for your specific version to ensure a smooth upgr
55

66
---
77

8+
## Upgrading from 0.10.x to 0.11.x
9+
10+
### 1) Removed StructureElement/struct_element/structure_element from StructureType Definition
11+
12+
Before:
13+
```php
14+
type_structure([
15+
struct_element('name', string()),
16+
struct_element('age', integer()),
17+
]);
18+
```
19+
20+
After:
21+
```php
22+
type_structure([
23+
'name' => string(),
24+
'age' => integer(),
25+
]);
26+
```
27+
828
## Upgrading from 0.8.x to 0.10.x
929

30+
1031
### 1) Providing multiple paths to single extractor
1132

1233
From now in order to read from multiple locations use `from_all(Extractor ...$extractors) : Exctractor` extractor.

examples/topics/data_frame/reorder_columns/code.php

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
declare(strict_types=1);
44

5-
use function Flow\ETL\DSL\{
6-
bool_entry,
5+
use function Flow\ETL\DSL\{bool_entry,
76
compare_entries_by_type_and_name,
87
data_frame,
98
datetime_entry,
@@ -16,15 +15,14 @@
1615
row,
1716
rows,
1817
str_entry,
19-
struct_element,
2018
struct_entry,
21-
struct_type,
2219
to_stream,
2320
type_float,
2421
type_int,
2522
type_list,
2623
type_map,
2724
type_string,
25+
type_structure,
2826
uuid_entry};
2927

3028
data_frame()
@@ -54,18 +52,15 @@
5452
'country' => 'country',
5553
'location' => ['lat' => 1.5, 'lon' => 1.5],
5654
],
57-
struct_type([
58-
struct_element('street', type_string()),
59-
struct_element('city', type_string()),
60-
struct_element('zip', type_string()),
61-
struct_element('country', type_string()),
62-
struct_element(
63-
'location',
64-
struct_type([
65-
struct_element('lat', type_float()),
66-
struct_element('lon', type_float()),
67-
])
68-
),
55+
type_structure([
56+
'street' => type_string(),
57+
'city' => type_string(),
58+
'zip' => type_string(),
59+
'country' => type_string(),
60+
'location' => type_structure([
61+
'lat' => type_float(),
62+
'lon' => type_float(),
63+
]),
6964
]),
7065
),
7166
)

rector.tests.php

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
<?php
22

33
use Flow\ETL\Config;
4+
use Flow\ETL\Extractor\ArrayExtractor;
5+
use Flow\ETL\Extractor\CacheExtractor;
6+
use Flow\ETL\Extractor\ChainExtractor;
7+
use Flow\ETL\Extractor\ChunkExtractor;
8+
use Flow\ETL\Extractor\DataFrameExtractor;
9+
use Flow\ETL\Extractor\MemoryExtractor;
10+
use Flow\ETL\Extractor\PipelineExtractor;
11+
use Flow\ETL\Extractor\RowsExtractor;
412
use Flow\ETL\FlowContext;
513
use Flow\ETL\PHP\Type\Logical\DateTimeType;
614
use Flow\ETL\PHP\Type\Logical\DateType;
715
use Flow\ETL\PHP\Type\Logical\JsonType;
8-
use Flow\ETL\PHP\Type\Logical\List\ListElement;
916
use Flow\ETL\PHP\Type\Logical\ListType;
10-
use Flow\ETL\PHP\Type\Logical\Map\MapKey;
11-
use Flow\ETL\PHP\Type\Logical\Map\MapValue;
1217
use Flow\ETL\PHP\Type\Logical\MapType;
13-
use Flow\ETL\PHP\Type\Logical\Structure\StructureElement;
1418
use Flow\ETL\PHP\Type\Logical\StructureType;
1519
use Flow\ETL\PHP\Type\Logical\TimeType;
1620
use Flow\ETL\PHP\Type\Logical\UuidType;
@@ -42,6 +46,7 @@
4246
use Flow\ETL\Row\Entry\UuidEntry;
4347
use Flow\ETL\Row\Entry\XMLElementEntry;
4448
use Flow\ETL\Row\Entry\XMLEntry;
49+
use Flow\ETL\Row\Schema;
4550
use Flow\ETL\Row\Schema\Definition;
4651
use Flow\ETL\Rows;
4752
use Flow\Tools\Rector\NewObjectToFunction;
@@ -67,7 +72,7 @@
6772
StaticCallToFuncCallRector::class,
6873
[
6974
// Building Blocks
70-
new StaticCallToFuncCall(Flow\ETL\Row::class, 'create', 'Flow\ETL\DSL\row'),
75+
new StaticCallToFuncCall(Row::class, 'create', 'Flow\ETL\DSL\row'),
7176
new StaticCallToFuncCall(Config::class, 'default', 'Flow\ETL\DSL\config'),
7277
// Schema
7378
new StaticCallToFuncCall(Definition::class, 'boolean', 'Flow\ETL\DSL\bool_schema'),
@@ -85,36 +90,6 @@
8590
new StaticCallToFuncCall(Definition::class, 'uuid', 'Flow\ETL\DSL\uuid_schema'),
8691
new StaticCallToFuncCall(Definition::class, 'xml', 'Flow\ETL\DSL\xml_schema'),
8792
new StaticCallToFuncCall(Definition::class, 'xml_element', 'Flow\ETL\DSL\xml_element_schema'),
88-
// Logical Types
89-
new StaticCallToFuncCall(MapKey::class, 'integer', 'Flow\ETL\DSL\type_integer'),
90-
new StaticCallToFuncCall(MapKey::class, 'string', 'Flow\ETL\DSL\type_string'),
91-
new StaticCallToFuncCall(MapValue::class, 'boolean', 'Flow\ETL\DSL\type_boolean'),
92-
new StaticCallToFuncCall(MapValue::class, 'datetime', 'Flow\ETL\DSL\type_datetime'),
93-
new StaticCallToFuncCall(MapValue::class, 'float', 'Flow\ETL\DSL\type_float'),
94-
new StaticCallToFuncCall(MapValue::class, 'integer', 'Flow\ETL\DSL\type_integer'),
95-
new StaticCallToFuncCall(MapValue::class, 'json', 'Flow\ETL\DSL\type_json'),
96-
new StaticCallToFuncCall(MapValue::class, 'list', 'Flow\ETL\DSL\type_list'),
97-
new StaticCallToFuncCall(MapValue::class, 'map', 'Flow\ETL\DSL\type_map'),
98-
new StaticCallToFuncCall(MapValue::class, 'object', 'Flow\ETL\DSL\type_object'),
99-
new StaticCallToFuncCall(MapValue::class, 'string', 'Flow\ETL\DSL\type_string'),
100-
new StaticCallToFuncCall(MapValue::class, 'structure', 'Flow\ETL\DSL\type_structure'),
101-
new StaticCallToFuncCall(MapValue::class, 'uuid', 'Flow\ETL\DSL\type_uuid'),
102-
new StaticCallToFuncCall(MapValue::class, 'xml', 'Flow\ETL\DSL\type_xml'),
103-
new StaticCallToFuncCall(MapValue::class, 'xmlElement', 'Flow\ETL\DSL\type_xml_element'),
104-
105-
new StaticCallToFuncCall(ListElement::class, 'boolean', 'Flow\ETL\DSL\type_boolean'),
106-
new StaticCallToFuncCall(ListElement::class, 'datetime', 'Flow\ETL\DSL\type_datetime'),
107-
new StaticCallToFuncCall(ListElement::class, 'float', 'Flow\ETL\DSL\type_float'),
108-
new StaticCallToFuncCall(ListElement::class, 'integer', 'Flow\ETL\DSL\type_integer'),
109-
new StaticCallToFuncCall(ListElement::class, 'json', 'Flow\ETL\DSL\type_json'),
110-
new StaticCallToFuncCall(ListElement::class, 'list', 'Flow\ETL\DSL\type_list'),
111-
new StaticCallToFuncCall(ListElement::class, 'map', 'Flow\ETL\DSL\type_map'),
112-
new StaticCallToFuncCall(ListElement::class, 'object', 'Flow\ETL\DSL\type_object'),
113-
new StaticCallToFuncCall(ListElement::class, 'string', 'Flow\ETL\DSL\type_string'),
114-
new StaticCallToFuncCall(ListElement::class, 'structure', 'Flow\ETL\DSL\type_structure'),
115-
new StaticCallToFuncCall(ListElement::class, 'uuid', 'Flow\ETL\DSL\type_uuid'),
116-
new StaticCallToFuncCall(ListElement::class, 'xml', 'Flow\ETL\DSL\type_xml'),
117-
new StaticCallToFuncCall(ListElement::class, 'xmlElement', 'Flow\ETL\DSL\type_xml_element'),
11893
]
11994
)
12095
->withConfiguredRule(
@@ -124,7 +99,7 @@
12499
new NewObjectToFunction(Rows::class, 'Flow\ETL\DSL\rows'),
125100
new NewObjectToFunction(Config::class, 'Flow\ETL\DSL\config'),
126101
new NewObjectToFunction(FlowContext::class, 'Flow\ETL\DSL\flow_context'),
127-
new NewObjectToFunction(Flow\ETL\Row\Schema::class, 'Flow\ETL\DSL\schema'),
102+
new NewObjectToFunction(Schema::class, 'Flow\ETL\DSL\schema'),
128103

129104
// Entries
130105
new NewObjectToFunction(BooleanEntry::class, 'Flow\ETL\DSL\boolean_entry'),
@@ -166,17 +141,16 @@
166141
new NewObjectToFunction(UuidType::class, 'Flow\ETL\DSL\type_uuid'),
167142
new NewObjectToFunction(XMLElementType::class, 'Flow\ETL\DSL\type_xml_element'),
168143
new NewObjectToFunction(XMLType::class, 'Flow\ETL\DSL\type_xml'),
169-
new NewObjectToFunction(StructureElement::class, 'Flow\ETL\DSL\structure_element'),
170144

171145
// Extractors
172-
new NewObjectToFunction(Flow\ETL\Extractor\CacheExtractor::class, 'from_cache'),
173-
new NewObjectToFunction(Flow\ETL\Extractor\RowsExtractor::class, 'from_rows'),
174-
new NewObjectToFunction(Flow\ETL\Extractor\ArrayExtractor::class, 'from_array'),
175-
new NewObjectToFunction(Flow\ETL\Extractor\ChainExtractor::class, 'from_all'),
176-
new NewObjectToFunction(Flow\ETL\Extractor\MemoryExtractor::class, 'from_memory'),
177-
new NewObjectToFunction(Flow\ETL\Extractor\ChunkExtractor::class, 'chunks_from'),
178-
new NewObjectToFunction(Flow\ETL\Extractor\PipelineExtractor::class, 'from_pipeline'),
179-
new NewObjectToFunction(Flow\ETL\Extractor\DataFrameExtractor::class, 'from_data_frame'),
146+
new NewObjectToFunction(CacheExtractor::class, 'from_cache'),
147+
new NewObjectToFunction(RowsExtractor::class, 'from_rows'),
148+
new NewObjectToFunction(ArrayExtractor::class, 'from_array'),
149+
new NewObjectToFunction(ChainExtractor::class, 'from_all'),
150+
new NewObjectToFunction(MemoryExtractor::class, 'from_memory'),
151+
new NewObjectToFunction(ChunkExtractor::class, 'chunks_from'),
152+
new NewObjectToFunction(PipelineExtractor::class, 'from_pipeline'),
153+
new NewObjectToFunction(DataFrameExtractor::class, 'from_data_frame'),
180154

181155
]
182156
)

src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/Integration/DbalDataFrameFactoryTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,12 @@ public function test_dataframe_factory_with_schema() : void
127127
'type' => [
128128
'type' => 'map',
129129
'key' => [
130-
'type' => [
131-
'type' => 'string',
132-
'nullable' => false,
133-
],
130+
'type' => 'string',
131+
'nullable' => false,
134132
],
135133
'value' => [
136-
'type' => [
137-
'type' => 'integer',
138-
'nullable' => false,
139-
],
134+
'type' => 'integer',
135+
'nullable' => false,
140136
],
141137
'nullable' => false,
142138
],

src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/Integration/DbalLimitOffsetExtractorTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,12 @@ public function test_extracting_entire_table_using_qb_with_schema() : void
154154
'type' => [
155155
'type' => 'map',
156156
'key' => [
157-
'type' => [
158-
'type' => 'string',
159-
'nullable' => false,
160-
],
157+
'type' => 'string',
158+
'nullable' => false,
161159
],
162160
'value' => [
163-
'type' => [
164-
'type' => 'integer',
165-
'nullable' => false,
166-
],
161+
'type' => 'integer',
162+
'nullable' => false,
167163
],
168164
'nullable' => false,
169165
],

src/adapter/etl-adapter-doctrine/tests/Flow/ETL/Adapter/Doctrine/Tests/Integration/DbalQueryExtractorTest.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,12 @@ public function test_extracting_multiple_rows_with_schema() : void
186186
'type' => [
187187
'type' => 'map',
188188
'key' => [
189-
'type' => [
190-
'type' => 'string',
191-
'nullable' => false,
192-
],
189+
'type' => 'string',
190+
'nullable' => false,
193191
],
194192
'value' => [
195-
'type' => [
196-
'type' => 'integer',
197-
'nullable' => false,
198-
],
193+
'type' => 'integer',
194+
'nullable' => false,
199195
],
200196
'nullable' => false,
201197
],

0 commit comments

Comments
 (0)