Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion benchmarks/src/Joining/JoinEachScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function run(): void
data_frame(BenchmarkConfig::builder())
->read(from_floe(Datasets::orders($this->rows)->floe()))
->batchSize(1000)
->withEntry('seller_id', ref('seller_id')->cast(type_string()))
->withColumn('seller_id', ref('seller_id')->cast(type_string()))
->joinEach(new SellersDataFrameFactory(Datasets::sellers($this->rows)->parquet()), join_on([
'seller_id' => 'id',
], join_prefix: 'sellers_'))
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/Joining/JoinOrdersWithSellersScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function run(): void
data_frame(BenchmarkConfig::builder())
->read(from_floe(Datasets::orders($this->rows)->floe()))
->batchSize(1000)
->withEntry('seller_id', ref('seller_id')->cast(type_string()))
->withColumn('seller_id', ref('seller_id')->cast(type_string()))
->join(
data_frame()->read(from_parquet(Datasets::sellers($this->rows)->parquet())),
join_on(['seller_id' => 'id'], join_prefix: 'sellers_'),
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/Partitioning/PartitionCardinality.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function column(): string
*/
public function derive(DataFrame $frame): DataFrame
{
return $frame->withEntry('day', ref('created_at')->dateFormat('Y-m-d'));
return $frame->withColumn('day', ref('created_at')->dateFormat('Y-m-d'));
}

public function reference(): Reference
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/Pipeline/CanonicalPipeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* The one pipeline shape every source is measured through, so a source's number differs only by its
* read leg. Every subject that claims to be comparable with the others must run through here.
*
* withEntry is the only verb that adds a column, so it forces schema widening at plan-bind time.
* withColumn is the only verb that adds a column, so it forces schema widening at plan-bind time.
* filter is deliberately non-selective - created_at is never null - so the row count reaching the sink
* cannot move for a second reason. select re-converges every source onto the same five columns, so the
* sink does identical work whatever was read. Floe stores typed values, adding no stringification the
Expand All @@ -42,7 +42,7 @@ public function run(): void
{
data_frame(BenchmarkConfig::builder())
->read($this->extractor)
->withEntry('contact', ref('customer')->concat(lit(' <'), ref('email'), lit('>')))
->withColumn('contact', ref('customer')->concat(lit(' <'), ref('email'), lit('>')))
->filter(ref('created_at')->isNotNull())
->select('order_id', 'seller_id', 'created_at', 'customer', 'contact')
->write(to_floe($this->sink))
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/Pipeline/NodePipelineScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public function run(): void
->read(from_xml($this->source->path($this->rows), self::XML_NODE_PATH)->withSchema(schema(xml_schema(
'node',
))))
->withEntry('body', ref('node')->cast(type_string())),
->withColumn('body', ref('node')->cast(type_string())),
NodeSource::text => data_frame(BenchmarkConfig::builder())
->read(from_text($this->source->path($this->rows))->withSchema(schema(str_schema('text'))))
->withEntry('body', ref('text')->concat(lit(' |'))),
->withColumn('body', ref('text')->concat(lit(' |'))),
};

$frame
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/Pipeline/PlanDepthScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/**
* schema() answers from the plan without executing it, so this prices Planner::plan() alone (optimize, translate,
* bind, split) rather than $depth withEntry calls per row.
* bind, split) rather than $depth withColumn calls per row.
*
* One call plans PLANS identical plans, because a single plan is far below timer resolution.
*/
Expand All @@ -33,7 +33,7 @@ public function bind(): Schema
->read((new SourceExtractor($this->source, SchemaMode::declared, $this->rows))->extractor());

for ($step = 0; $step < $this->depth; $step++) {
$frame = $frame->withEntry('c' . $step, ref('customer')->concat(lit((string) $step)));
$frame = $frame->withColumn('c' . $step, ref('customer')->concat(lit((string) $step)));
}

return $frame->schema();
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/Service/Seal/SealWriteScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function run(): void
data_frame()
->read(from_floe(Datasets::orders($this->rows)->floe()))
->batchSize(1000)
->write(to_seal_upsert($engine, $this->index())->withIdentifierEntry('order_id')->withBulkSize(1000))
->write(to_seal_upsert($engine, $this->index())->withIdentifierColumn('order_id')->withBulkSize(1000))
->run();
}

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/Window/MovingAverageScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function run(): void

$partitioning
->derive(data_frame(BenchmarkConfig::builder())->read(from_floe(Datasets::orders($this->rows)->floe())))
->withEntry(
->withColumn(
'moving_average',
average(ref('discount'))
->over(
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/Window/RankScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function run(): void

$partitioning
->derive(data_frame(BenchmarkConfig::builder())->read(from_floe(Datasets::orders($this->rows)->floe())))
->withEntry(
->withColumn(
'rank',
rank()->over(window()->partitionBy($partitioning->reference())->orderBy(ref('created_at'))),
)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/Window/RowNumberScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function run(): void

$partitioning
->derive(data_frame(BenchmarkConfig::builder())->read(from_floe(Datasets::orders($this->rows)->floe())))
->withEntry(
->withColumn(
'row_number',
row_number()->over(window()->partitionBy($partitioning->reference())->orderBy(ref('created_at'))),
)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/Window/RunningTotalScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function run(): void

$partitioning
->derive(data_frame(BenchmarkConfig::builder())->read(from_floe(Datasets::orders($this->rows)->floe())))
->withEntry(
->withColumn(
'running_total',
sum(ref('discount'))
->over(window()->partitionBy($partitioning->reference())->orderBy(ref('created_at'))),
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/src/Window/WholePartitionScenario.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function run(): void

$partitioning
->derive(data_frame(BenchmarkConfig::builder())->read(from_floe(Datasets::orders($this->rows)->floe())))
->withEntry('seller_total', sum(ref('discount'))->over(window()->partitionBy($partitioning->reference())))
->withColumn('seller_total', sum(ref('discount'))->over(window()->partitionBy($partitioning->reference())))
->run();
}
}
2 changes: 1 addition & 1 deletion benchmarks/suites/Pipeline/OrdersPipelineBench.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use PhpBench\Attributes as Bench;

/**
* Rung 4 of the ladder: read -> withEntry -> filter -> select -> write, one subject per source.
* Rung 4 of the ladder: read -> withColumn -> filter -> select -> write, one subject per source.
*
* Parquet, Floe, Doctrine and PostgreSQL have no inferred arm on purpose. They declare from metadata
* (footer / driver describe-query) and never sample, so the inferred-vs-declared comparison is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function test_every_column_is_nullable_on_every_source(): void
{
foreach (Source::cases() as $source) {
foreach (OrdersSchema::of($source)->definitions() as $definition) {
static::assertTrue($definition->isNullable(), $source->value . '.' . $definition->entry()->name());
static::assertTrue($definition->isNullable(), $source->value . '.' . $definition->reference()->name());
}
}
}
Expand All @@ -40,7 +40,7 @@ public function test_the_five_projected_columns_exist_on_every_source(): void
$names = [];

foreach (OrdersSchema::of($source)->definitions() as $definition) {
$names[] = $definition->entry()->name();
$names[] = $definition->reference()->name();
}

foreach (['order_id', 'seller_id', 'created_at', 'customer', 'email'] as $projected) {
Expand Down
10 changes: 5 additions & 5 deletions documentation/adrs/variadic-arguments-pattern.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ Several Flow PHP methods accept multiple arguments where at least one is require
A proposal was made to simplify the API signatures from:

```php ignore
public function partitionBy(string|Reference $entry, string|Reference ...$entries) : self
public function partitionBy(string|Reference $column, string|Reference ...$columns) : self
```

To:

```php ignore
public function partitionBy(string|Reference ...$entries) : self
public function partitionBy(string|Reference ...$columns) : self
```

The rationale for the proposal was to reduce array operations like `array_unshift()` used internally to merge the first required argument with the variadic rest.
Expand Down Expand Up @@ -67,10 +67,10 @@ public function method(Type ...$args) : ReturnType
### 1. Pure variadic with runtime validation

```php ignore
public function partitionBy(string|Reference ...$entries) : self
public function partitionBy(string|Reference ...$columns) : self
{
if ([] === $entries) {
throw new InvalidArgumentException('At least one entry is required.');
if ([] === $columns) {
throw new InvalidArgumentException('At least one column is required.');
}
// ...
}
Expand Down
2 changes: 1 addition & 1 deletion documentation/components/adapters/chartjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ $data = [

df()
->read(from_array($data))
->withEntry('Profit', ref('Revenue')->minus(ref('CM'))->minus(ref('Ads Spends'))->minus(ref('Storage Costs'))->minus(ref('Shipping Costs'))->round(lit(2)))
->withColumn('Profit', ref('Revenue')->minus(ref('CM'))->minus(ref('Ads Spends'))->minus(ref('Storage Costs'))->minus(ref('Shipping Costs'))->round(lit(2)))
->write(
to_chartjs_file(
$chart = bar_chart(
Expand Down
2 changes: 1 addition & 1 deletion documentation/components/adapters/excel.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Write each row to the sheet named by its `category` value:
<?php

$loader = to_excel('path/to/output.xlsx')
->withSheetNameFromEntry('category');
->withSheetNameFromColumn('category');

data_frame()
->read($extractor)
Expand Down
4 changes: 2 additions & 2 deletions documentation/components/adapters/parquet.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ use function Flow\Types\DSL\type_json;

data_frame()
->read(from_parquet(__DIR__ . '/orders.parquet', columns: ['id', 'payload', 'created_at']))
->withEntry('payload', ref('payload')->cast(type_json()))
->withEntry('created_at', to_timezone(ref('created_at'), 'Europe/Warsaw'))
->withColumn('payload', ref('payload')->cast(type_json()))
->withColumn('created_at', to_timezone(ref('created_at'), 'Europe/Warsaw'))
->write(to_output())
->run();
```
Expand Down
8 changes: 4 additions & 4 deletions documentation/components/adapters/postgresql.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ Two helpers convert between a Flow `Schema` and a PostgreSQL table definition:
(and related index/constraint) SQL via `toSql()`.
- `pgsql_table_to_flow_schema()` turns a `Flow\PostgreSql\Schema\Table` back into a Flow `Schema`.

Column types are resolved through the shared `EntryTypesMap` (Flow type → PostgreSQL column type), and per-column
Column types are resolved through the shared `TypesMap` (Flow type → PostgreSQL column type), and per-column
details - primary keys, unique constraints, indexes, length, precision/scale, defaults, identity, generated columns,
and explicit type overrides - are driven by `PostgreSqlMetadata` entries attached to each schema definition.

Expand Down Expand Up @@ -625,11 +625,11 @@ $schema = pgsql_table_to_flow_schema($table);

### Customizing the Type Mapping

Both helpers accept an optional `EntryTypesMap`. Its second constructor argument overrides the Flow type → PostgreSQL
Both helpers accept an optional `TypesMap`. Its second constructor argument overrides the Flow type → PostgreSQL
column type mapping (the first argument keeps overriding the value-binding types used by the loader):

```php
use Flow\ETL\Adapter\PostgreSql\EntryTypesMap;
use Flow\ETL\Adapter\PostgreSql\TypesMap;
use Flow\PostgreSql\QueryBuilder\Schema\ColumnType;
use Flow\Types\Type\Native\StringType;

Expand All @@ -638,7 +638,7 @@ use function Flow\ETL\Adapter\PostgreSql\to_pgsql_schema_table;
$table = to_pgsql_schema_table(
$schema,
'users',
typesMap: new EntryTypesMap([], [
typesMap: new TypesMap([], [
StringType::class => ColumnType::varchar(255), // default strings to varchar(255) instead of text
]),
);
Expand Down
4 changes: 2 additions & 2 deletions documentation/components/adapters/seal.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ to_seal_upsert($engine, 'users')->withBulkSize(500);

### Deleting Documents

`to_seal_delete()` removes documents by their identifiers, read from the `id` column. `withIdentifierEntry()` names
`to_seal_delete()` removes documents by their identifiers, read from the `id` column. `withIdentifierColumn()` names
another column.

```php
Expand All @@ -111,7 +111,7 @@ data_frame()
```

```php
to_seal_delete($engine, 'products')->withIdentifierEntry('sku');
to_seal_delete($engine, 'products')->withIdentifierColumn('sku');
```

### Data Normalization
Expand Down
2 changes: 1 addition & 1 deletion documentation/components/adapters/xml.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use function Flow\ETL\DSL\{data_frame, ref, to_output};

data_frame()
->read(from_xml(__DIR__ . '/simple_items.xml')->withXMLNodePath('root/items/item'))
->withEntry('id', ref('node')->xpath('id')->domElementValue())
->withColumn('id', ref('node')->xpath('id')->domElementValue())
->write(to_output(truncate: false))
->run();
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ use function Flow\ETL\DSL\lit;
new class implements Transformation {
public function transform(DataFrame $dataFrame): DataFrame
{
return $dataFrame->withEntry('time', lit(\time()));
return $dataFrame->withColumn('time', lit(\time()));
}
};
```
Expand Down
10 changes: 5 additions & 5 deletions documentation/components/cli/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Options:
--analyze[=ANALYZE] Collect processing statistics and print them. [default: false]
--config=CONFIG Path to a local php file that MUST return instance of: Flow\ETL\Config
--input-json-pointer=INPUT-JSON-POINTER JSON Pointer to a subtree from which schema should be extracted
--input-json-pointer-entry-name When set, JSON Pointer will be used as an entry name in the schema
--input-json-pointer-column-name When set, JSON Pointer will be used as a column name in the schema
--output-json-date-time-format=OUTPUT-JSON-DATE-TIME-FORMAT Date time format used in JSON output
--output-json-rows-in-new-line When set, each row will be printed in a new line
--input-csv-header[=INPUT-CSV-HEADER] When set, CSV header will be used as a schema
Expand Down Expand Up @@ -174,7 +174,7 @@ Options:
--output-ascii Print schema as ascii list
--config=CONFIG Path to a local php file that MUST return instance of: Flow\ETL\Config
--input-json-pointer=INPUT-JSON-POINTER JSON Pointer to a subtree from which schema should be extracted
--input-json-pointer-entry-name When set, JSON Pointer will be used as an entry name in the schema
--input-json-pointer-column-name When set, JSON Pointer will be used as a column name in the schema
--input-csv-header[=INPUT-CSV-HEADER] When set, CSV header will be used as a schema
--input-csv-empty-to-null[=INPUT-CSV-EMPTY-TO-NULL] When set, empty CSV values will be treated as NULL values
--input-csv-separator=INPUT-CSV-SEPARATOR CSV separator character
Expand Down Expand Up @@ -243,7 +243,7 @@ Options:
--input-file-offset=INPUT-FILE-OFFSET Number of rows to skip before starting to read data
--config=CONFIG Path to a local php file that MUST return instance of: Flow\ETL\Config
--input-json-pointer=INPUT-JSON-POINTER JSON Pointer to a subtree from which schema should be extracted
--input-json-pointer-entry-name When set, JSON Pointer will be used as an entry name in the schema
--input-json-pointer-column-name When set, JSON Pointer will be used as a column name in the schema
--input-csv-header[=INPUT-CSV-HEADER] When set, CSV header will be used as a schema
--input-csv-empty-to-null[=INPUT-CSV-EMPTY-TO-NULL] When set, empty CSV values will be treated as NULL values
--input-csv-separator=INPUT-CSV-SEPARATOR CSV separator character
Expand Down Expand Up @@ -295,7 +295,7 @@ Options:
--output-columns=OUTPUT-COLUMNS Columns to include in output, when not set all columns are displayed (multiple values allowed)
--config=CONFIG Path to a local php file that MUST return instance of: Flow\ETL\Config
--input-json-pointer=INPUT-JSON-POINTER JSON Pointer to a subtree from which schema should be extracted
--input-json-pointer-entry-name When set, JSON Pointer will be used as an entry name in the schema
--input-json-pointer-column-name When set, JSON Pointer will be used as a column name in the schema
--input-csv-header[=INPUT-CSV-HEADER] When set, CSV header will be used as a schema
--input-csv-empty-to-null[=INPUT-CSV-EMPTY-TO-NULL] When set, empty CSV values will be treated as NULL values
--input-csv-separator=INPUT-CSV-SEPARATOR CSV separator character
Expand Down Expand Up @@ -341,7 +341,7 @@ Options:
--input-file-offset=INPUT-FILE-OFFSET Number of rows to skip before starting to read data
--config=CONFIG Path to a local php file that MUST return instance of: Flow\ETL\Config
--input-json-pointer=INPUT-JSON-POINTER JSON Pointer to a subtree from which schema should be extracted
--input-json-pointer-entry-name When set, JSON Pointer will be used as an entry name in the schema
--input-json-pointer-column-name When set, JSON Pointer will be used as a column name in the schema
--input-excel-header[=INPUT-EXCEL-HEADER] When set, Excel header will be used as a schema
--input-excel-sheet-name=INPUT-EXCEL-SHEET-NAME When set, Excel sheet name will be selected for reading
--input-excel-offset=INPUT-EXCEL-OFFSET Offset to start reading from
Expand Down
Loading
Loading