Skip to content

Commit 3529a44

Browse files
authored
Merge pull request #1270 from norberttech/chores/dependencies-2024-12-11
Dependencies 2024-12-11
2 parents 4535546 + 0d4192c commit 3529a44

File tree

18 files changed

+216
-314
lines changed

18 files changed

+216
-314
lines changed

composer.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205
"build": [
206206
"@test:docs",
207207
"@test:monorepo",
208+
"@test:examples",
208209
"@static:analyze",
209210
"@test",
210211
"@test:benchmark",
@@ -222,6 +223,12 @@
222223
"@test:benchmark:loader",
223224
"@test:benchmark:transformer"
224225
],
226+
"test:website": [
227+
"composer test --working-dir=./web/landing"
228+
],
229+
"test:examples": [
230+
"./examples/run.php"
231+
],
225232
"test:benchmark:building_blocks": [
226233
"tools/phpbench/vendor/bin/phpbench run --report=flow-report --group=building_blocks"
227234
],

composer.lock

Lines changed: 42 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use function Flow\ETL\DSL\{bool_schema, data_frame, from_array, int_schema, schema, str_schema, to_stream};
6+
use Flow\ETL\Loader\StreamLoader\Output;
7+
use Flow\ETL\Row\Schema\Metadata;
8+
9+
require __DIR__ . '/../../../autoload.php';
10+
11+
$schema = schema(
12+
int_schema('id', $nullable = false),
13+
str_schema('name', $nullable = true),
14+
bool_schema('active', $nullable = false, Metadata::empty()->add('key', 'value')),
15+
);
16+
17+
data_frame()
18+
->read(
19+
from_array([
20+
['id' => 1, 'name' => 'Product 1', 'active' => true],
21+
['id' => 2, 'name' => 'Product 2', 'active' => false],
22+
['id' => 3, 'name' => 'Product 3', 'active' => true],
23+
])->withSchema($schema)
24+
)
25+
->collect()
26+
->write(to_stream(__DIR__ . '/output.txt', truncate: false, output: Output::schema))
27+
->run();
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
While iterating through dataset that comes from a source which does not
2+
support strict schema, like CSV/XML/JSON, you can tell the extractor
3+
what schema to apply to each read column.
4+
5+
Otherwise, DataFrame will try to guess the schema based on the data in the column.
6+
It might be problematic if the first rows would be empty or null.
7+
If the first row is a null, entry factory (mechanism responsible for creating entries)
8+
will assume that the column is of type `string`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
schema
2+
|-- id: integer
3+
|-- name: string
4+
|-- active: boolean
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2

src/core/etl/src/Flow/ETL/DSL/functions.php

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
ArrayUnpack,
2929
Average,
3030
Between,
31-
CallMethod,
3231
Capitalize,
3332
Cast,
3433
Coalesce,
@@ -944,15 +943,6 @@ function upper(ScalarFunction|string $value) : ToUpper
944943
return new ToUpper($value);
945944
}
946945

947-
/**
948-
* @param array<mixed> $params
949-
*/
950-
#[DocumentationDSL(module: Module::CORE, type: DSLType::SCALAR_FUNCTION)]
951-
function call_method(object $object, ScalarFunction|string $method, array $params = []) : CallMethod
952-
{
953-
return new CallMethod($object, $method, $params);
954-
}
955-
956946
#[DocumentationDSL(module: Module::CORE, type: DSLType::SCALAR_FUNCTION)]
957947
function all(ScalarFunction ...$functions) : All
958948
{
@@ -1557,6 +1547,7 @@ function dom_element_to_string(\DOMElement $element, bool $format_output = false
15571547
return $doc->saveXML($doc->documentElement);
15581548
}
15591549

1550+
#[DocumentationDSL(module: Module::CORE, type: DSLType::HELPER)]
15601551
function date_interval_to_milliseconds(\DateInterval $interval) : int
15611552
{
15621553
if ($interval->y !== 0 || $interval->m !== 0) {
@@ -1573,6 +1564,7 @@ function date_interval_to_milliseconds(\DateInterval $interval) : int
15731564
: (int) ($absoluteSeconds * 1000 + $interval->f * 1000);
15741565
}
15751566

1567+
#[DocumentationDSL(module: Module::CORE, type: DSLType::HELPER)]
15761568
function date_interval_to_seconds(\DateInterval $interval) : int
15771569
{
15781570
if ($interval->y !== 0 || $interval->m !== 0) {
@@ -1589,6 +1581,7 @@ function date_interval_to_seconds(\DateInterval $interval) : int
15891581
: (int) ceil($absoluteSeconds + $interval->f);
15901582
}
15911583

1584+
#[DocumentationDSL(module: Module::CORE, type: DSLType::HELPER)]
15921585
function date_interval_to_microseconds(\DateInterval $interval) : int
15931586
{
15941587
if ($interval->y !== 0 || $interval->m !== 0) {

src/core/etl/src/Flow/ETL/Function/CallMethod.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/core/etl/src/Flow/ETL/Function/ScalarFunctionChain.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,15 +268,6 @@ public function lower() : self
268268
return new ToLower($this);
269269
}
270270

271-
/**
272-
* @param ScalarFunction|string $method
273-
* @param array<mixed> $params
274-
*/
275-
public function method(ScalarFunction|string $method, array $params) : self
276-
{
277-
return new CallMethod($this, $method, $params);
278-
}
279-
280271
public function minus(ScalarFunction|int|float $ref) : self
281272
{
282273
return new Minus($this, $ref);

0 commit comments

Comments
 (0)