Skip to content

Commit 37f9d27

Browse files
authored
fix: autocast handling datetime | numeric type merge (#2196)
- renamed Stages to Segments
1 parent 858ebec commit 37f9d27

File tree

8 files changed

+355
-5
lines changed

8 files changed

+355
-5
lines changed

src/core/etl/src/Flow/ETL/Pipeline.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,18 @@
44

55
namespace Flow\ETL;
66

7-
use Flow\ETL\Pipeline\Stages;
7+
use Flow\ETL\Pipeline\Segments;
88

99
/**
1010
* @internal
1111
*/
1212
final readonly class Pipeline
1313
{
14-
private Stages $stages;
14+
private Segments $stages;
1515

1616
public function __construct(private Extractor $extractor)
1717
{
18-
$this->stages = new Stages();
18+
$this->stages = new Segments();
1919
}
2020

2121
public function add(Transformer|Loader|Processor $step) : self
@@ -68,7 +68,7 @@ public function process(FlowContext $context) : \Generator
6868
/**
6969
* Get the pipeline stages.
7070
*/
71-
public function stages() : Stages
71+
public function stages() : Segments
7272
{
7373
return $this->stages;
7474
}

src/core/etl/src/Flow/ETL/Pipeline/Stages.php renamed to src/core/etl/src/Flow/ETL/Pipeline/Segments.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
* @internal
1313
*/
14-
final class Stages
14+
final class Segments
1515
{
1616
private Segment $currentSegment;
1717

src/core/etl/src/Flow/ETL/Schema/Definition/DateDefinition.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,22 @@ public function merge(Definition $definition) : Definition
154154
);
155155
}
156156

157+
if ($definition instanceof FloatDefinition) {
158+
return new FloatDefinition(
159+
$this->ref,
160+
$this->nullable || $definition->isNullable(),
161+
$this->metadata->merge($definition->metadata())
162+
);
163+
}
164+
165+
if ($definition instanceof IntegerDefinition) {
166+
return new IntegerDefinition(
167+
$this->ref,
168+
$this->nullable || $definition->isNullable(),
169+
$this->metadata->merge($definition->metadata())
170+
);
171+
}
172+
157173
throw new RuntimeException(\sprintf(
158174
'Cannot merge %s with %s',
159175
self::class,

src/core/etl/src/Flow/ETL/Schema/Definition/DateTimeDefinition.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,22 @@ public function merge(Definition $definition) : Definition
146146
);
147147
}
148148

149+
if ($definition instanceof FloatDefinition) {
150+
return new FloatDefinition(
151+
$this->ref,
152+
$this->nullable || $definition->isNullable(),
153+
$this->metadata->merge($definition->metadata())
154+
);
155+
}
156+
157+
if ($definition instanceof IntegerDefinition) {
158+
return new IntegerDefinition(
159+
$this->ref,
160+
$this->nullable || $definition->isNullable(),
161+
$this->metadata->merge($definition->metadata())
162+
);
163+
}
164+
149165
throw new RuntimeException(\sprintf(
150166
'Cannot merge %s with %s',
151167
self::class,

src/core/etl/src/Flow/ETL/Schema/Definition/FloatDefinition.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ public function merge(Definition $definition) : Definition
146146
);
147147
}
148148

149+
if ($definition instanceof DateDefinition || $definition instanceof DateTimeDefinition) {
150+
return new self(
151+
$this->ref,
152+
$this->nullable || $definition->isNullable(),
153+
$this->metadata->merge($definition->metadata())
154+
);
155+
}
156+
149157
if ($definition instanceof StringDefinition) {
150158
return new StringDefinition(
151159
$this->ref,

src/core/etl/src/Flow/ETL/Schema/Definition/IntegerDefinition.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ public function merge(Definition $definition) : Definition
146146
);
147147
}
148148

149+
if ($definition instanceof DateDefinition || $definition instanceof DateTimeDefinition) {
150+
return new self(
151+
$this->ref,
152+
$this->nullable || $definition->isNullable(),
153+
$this->metadata->merge($definition->metadata())
154+
);
155+
}
156+
149157
if ($definition instanceof StringDefinition) {
150158
return new StringDefinition(
151159
$this->ref,

0 commit comments

Comments
 (0)