diff --git a/examples/topics/data_reading/elasticsearch/code.php b/examples/topics/data_reading/elasticsearch/code.php index d7649570d..570d6e5f8 100644 --- a/examples/topics/data_reading/elasticsearch/code.php +++ b/examples/topics/data_reading/elasticsearch/code.php @@ -52,6 +52,6 @@ ] )) ->write(to_stream(__DIR__ . '/output.raw.txt', truncate: false)) - ->transform(es_hits_to_rows()) + ->with(es_hits_to_rows()) ->write(to_stream(__DIR__ . '/output.txt', truncate: false)) ->run(); diff --git a/examples/topics/data_writing/elasticsearch/code.php b/examples/topics/data_writing/elasticsearch/code.php index d7649570d..570d6e5f8 100644 --- a/examples/topics/data_writing/elasticsearch/code.php +++ b/examples/topics/data_writing/elasticsearch/code.php @@ -52,6 +52,6 @@ ] )) ->write(to_stream(__DIR__ . '/output.raw.txt', truncate: false)) - ->transform(es_hits_to_rows()) + ->with(es_hits_to_rows()) ->write(to_stream(__DIR__ . '/output.txt', truncate: false)) ->run(); diff --git a/src/adapter/etl-adapter-elasticsearch/tests/Flow/ETL/Adapter/Elasticsearch/Tests/Integration/ElasticsearchPHP/ElasticsearchExtractorTest.php b/src/adapter/etl-adapter-elasticsearch/tests/Flow/ETL/Adapter/Elasticsearch/Tests/Integration/ElasticsearchPHP/ElasticsearchExtractorTest.php index acc55afdb..10478eed6 100644 --- a/src/adapter/etl-adapter-elasticsearch/tests/Flow/ETL/Adapter/Elasticsearch/Tests/Integration/ElasticsearchPHP/ElasticsearchExtractorTest.php +++ b/src/adapter/etl-adapter-elasticsearch/tests/Flow/ETL/Adapter/Elasticsearch/Tests/Integration/ElasticsearchPHP/ElasticsearchExtractorTest.php @@ -90,7 +90,7 @@ public function test_extraction_index_with_from_and_size() : void $results = (data_frame()) ->extract(from_es($this->elasticsearchContext->clientConfig(), $params)) - ->transform(es_hits_to_rows(DocumentDataSource::fields)) + ->with(es_hits_to_rows(DocumentDataSource::fields)) ->fetch(); self::assertCount(2000, $results); diff --git a/src/adapter/etl-adapter-meilisearch/tests/Flow/ETL/Adapter/Meilisearch/Tests/Integration/MeilisearchPHP/MeilisearchExtractorTest.php b/src/adapter/etl-adapter-meilisearch/tests/Flow/ETL/Adapter/Meilisearch/Tests/Integration/MeilisearchPHP/MeilisearchExtractorTest.php index 2d0870cfb..a1d987b8e 100644 --- a/src/adapter/etl-adapter-meilisearch/tests/Flow/ETL/Adapter/Meilisearch/Tests/Integration/MeilisearchPHP/MeilisearchExtractorTest.php +++ b/src/adapter/etl-adapter-meilisearch/tests/Flow/ETL/Adapter/Meilisearch/Tests/Integration/MeilisearchPHP/MeilisearchExtractorTest.php @@ -68,7 +68,7 @@ public function test_extraction_index_with_from_and_size() : void $results = (data_frame()) ->extract(from_meilisearch($this->meilisearchContext->clientConfig(), $params, self::INDEX_NAME)) - ->transform(meilisearch_hits_to_rows()) + ->with(meilisearch_hits_to_rows()) ->fetch(); self::assertCount(49, $results); diff --git a/src/bridge/symfony/http-foundation/src/Flow/Bridge/Symfony/HttpFoundation/FlowStreamedResponse.php b/src/bridge/symfony/http-foundation/src/Flow/Bridge/Symfony/HttpFoundation/FlowStreamedResponse.php index 2f914e4ae..091ff5ece 100644 --- a/src/bridge/symfony/http-foundation/src/Flow/Bridge/Symfony/HttpFoundation/FlowStreamedResponse.php +++ b/src/bridge/symfony/http-foundation/src/Flow/Bridge/Symfony/HttpFoundation/FlowStreamedResponse.php @@ -34,7 +34,7 @@ private function stream() : void { df($this->config) ->read($this->extractor) - ->transform($this->transformations) + ->with($this->transformations) ->dropPartitions() ->write($this->output->loader()) ->run(); diff --git a/src/bridge/symfony/http-foundation/tests/Flow/Bridge/Symfony/HttpFoundation/Tests/Unit/Transformation/MaskColumnTransformationTest.php b/src/bridge/symfony/http-foundation/tests/Flow/Bridge/Symfony/HttpFoundation/Tests/Unit/Transformation/MaskColumnTransformationTest.php index 15449c469..a0e0dd04b 100644 --- a/src/bridge/symfony/http-foundation/tests/Flow/Bridge/Symfony/HttpFoundation/Tests/Unit/Transformation/MaskColumnTransformationTest.php +++ b/src/bridge/symfony/http-foundation/tests/Flow/Bridge/Symfony/HttpFoundation/Tests/Unit/Transformation/MaskColumnTransformationTest.php @@ -19,7 +19,7 @@ public function test_masking_columns_transformation() : void ['id' => 3, 'name' => 'John Smith', 'salary' => 9000, 'currency' => 'USD'], ['id' => 4, 'name' => 'Jane Smith', 'salary' => 10000, 'currency' => 'USD'], ])) - ->transform(new MaskColumns(['salary'])) + ->with(new MaskColumns(['salary'])) ->fetch() ->toArray(); diff --git a/src/core/etl/src/Flow/ETL/DataFrame.php b/src/core/etl/src/Flow/ETL/DataFrame.php index a00fc5921..9f140660f 100644 --- a/src/core/etl/src/Flow/ETL/DataFrame.php +++ b/src/core/etl/src/Flow/ETL/DataFrame.php @@ -222,7 +222,7 @@ public function collect() : self #[DSLMethod(exclude: true)] public function collectRefs(References $references) : self { - $this->transform(new CallbackRowTransformer(function (Row $row) use ($references) : Row { + $this->with(new CallbackRowTransformer(function (Row $row) use ($references) : Row { foreach ($row->entries()->all() as $entry) { $references->add($entry->ref()); } @@ -739,7 +739,7 @@ public function reorderEntries(Comparator $comparator = new TypeComparator()) : */ public function rows(Transformer|Transformation $transformer) : self { - return $this->transform($transformer); + return $this->with($transformer); } /** @@ -826,17 +826,13 @@ public function sortBy(Reference ...$entries) : self } /** + * Alias for DataFrame::with(). + * * @lazy */ public function transform(Transformer|Transformation $transformer) : self { - if ($transformer instanceof Transformer) { - $this->pipeline->add($transformer); - - return $this; - } - - return $transformer->transform($this); + return $this->with($transformer); } /** @@ -878,6 +874,20 @@ public function void() : self return $this; } + /** + * @lazy + */ + public function with(Transformer|Transformation $transformer) : self + { + if ($transformer instanceof Transformer) { + $this->pipeline->add($transformer); + + return $this; + } + + return $transformer->transform($this); + } + /** * @lazy * @@ -910,7 +920,7 @@ public function withEntry(string|Definition $entry, ScalarFunction|WindowFunctio $this->pipeline->add(new WindowFunctionTransformer($entry, $reference)); } else { - $this->transform(new ScalarFunctionTransformer($entry, $reference)); + $this->with(new ScalarFunctionTransformer($entry, $reference)); } return $this; diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/DataFrameTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/DataFrameTest.php index 8ffb0415c..e917434c6 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/DataFrameTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/DataFrameTest.php @@ -508,7 +508,7 @@ public function extract(FlowContext $context) : \Generator } } ) - ->transform( + ->with( new class implements Transformer { public function transform(Rows $rows, FlowContext $context) : Rows { @@ -545,7 +545,7 @@ public function extract(FlowContext $context) : \Generator } } ) - ->transform( + ->with( new class implements Transformer { public function transform(Rows $rows, FlowContext $context) : Rows { diff --git a/src/core/etl/tests/Flow/ETL/Tests/Unit/ETLErrorHandlingTest.php b/src/core/etl/tests/Flow/ETL/Tests/Unit/ETLErrorHandlingTest.php index 75e089603..a1f612b17 100644 --- a/src/core/etl/tests/Flow/ETL/Tests/Unit/ETLErrorHandlingTest.php +++ b/src/core/etl/tests/Flow/ETL/Tests/Unit/ETLErrorHandlingTest.php @@ -50,7 +50,7 @@ public function load(Rows $rows, FlowContext $context) : void (data_frame()) ->extract($extractor) ->onError(throw_error_handler()) - ->transform($brokenTransformer) + ->with($brokenTransformer) ->load($loader) ->run(); } @@ -90,7 +90,7 @@ public function load(Rows $rows, FlowContext $context) : void (data_frame()) ->extract($extractor) ->onError(ignore_error_handler()) - ->transform($brokenTransformer) + ->with($brokenTransformer) ->load($loader) ->run(); @@ -152,7 +152,7 @@ public function load(Rows $rows, FlowContext $context) : void (data_frame()) ->extract($extractor) ->onError(skip_rows_handler()) - ->transform($brokenTransformer) + ->with($brokenTransformer) ->load($loader) ->run();