diff --git a/src/core/etl/src/Flow/ETL/DSL/functions.php b/src/core/etl/src/Flow/ETL/DSL/functions.php index e93040bd0..996f3b417 100644 --- a/src/core/etl/src/Flow/ETL/DSL/functions.php +++ b/src/core/etl/src/Flow/ETL/DSL/functions.php @@ -27,7 +27,28 @@ use Flow\ETL\Row\Schema\Formatter\ASCIISchemaFormatter; use Flow\ETL\Row\Schema\{Definition, Matcher\EvolvingSchemaMatcher, Matcher\StrictSchemaMatcher, SchemaFormatter}; use Flow\ETL\Row\{EntryFactory, EntryReference, Reference, References, Schema}; -use Flow\ETL\{Config, ConfigBuilder, DataFrame, Extractor, Flow, FlowContext, Formatter, Loader, Partition, Pipeline, Row, Rows, Transformer, Window}; +use Flow\ETL\{Config, + ConfigBuilder, + DataFrame, + Extractor, + Flow, + FlowContext, + Formatter, + Join\Comparison, + Join\Comparison\Equal, + Join\Comparison\GreaterThan, + Join\Comparison\GreaterThanEqual, + Join\Comparison\Identical, + Join\Comparison\LessThan, + Join\Comparison\LessThanEqual, + Join\Expression, + Loader, + Partition, + Pipeline, + Row, + Rows, + Transformer, + Window}; /** * Alias for data_frame() : Flow. @@ -1121,3 +1142,53 @@ function print_rows(Rows $rows, int|bool $truncate = false, ?Formatter $formatte { return ($formatter ?? new Formatter\AsciiTableFormatter())->format($rows, $truncate); } + +function identical(Reference|string $left, Reference|string $right) : Identical +{ + return new Identical($left, $right); +} + +function equal(Reference|string $left, Reference|string $right) : Equal +{ + return new Equal($left, $right); +} + +function compare_all(Comparison ...$comparisons) : Comparison\All +{ + return new Comparison\All(...$comparisons); +} + +function compare_any(Comparison ...$comparisons) : Comparison\Any +{ + return new Comparison\Any(...$comparisons); +} + +function greater_than(Reference|string $left, Reference|string $right) : GreaterThan +{ + return new GreaterThan($left, $right); +} + +function greater_than_equal(Reference|string $left, Reference|string $right) : GreaterThanEqual +{ + return new GreaterThanEqual($left, $right); +} + +function less_than(Reference|string $left, Reference|string $right) : LessThan +{ + return new LessThan($left, $right); +} + +function less_than_equal(Reference|string $left, Reference|string $right) : LessThanEqual +{ + return new LessThanEqual($left, $right); +} + +function negation(Comparison $comparison) : Comparison\Not +{ + return new Comparison\Not($comparison); +} + +function join_on(array|Comparison $comparisons, string $joinPrefix = '') : Expression +{ + return Expression::on($comparisons, $joinPrefix); +} diff --git a/src/core/etl/src/Flow/ETL/Join/Expression.php b/src/core/etl/src/Flow/ETL/Join/Expression.php index 8ba8e10f8..b618a06b0 100644 --- a/src/core/etl/src/Flow/ETL/Join/Expression.php +++ b/src/core/etl/src/Flow/ETL/Join/Expression.php @@ -18,7 +18,7 @@ public function __construct( } /** - * @param array|Comparison $comparison + * @param array|array|Comparison $comparison */ public static function on(array|Comparison $comparison, string $joinPrefix = '') : self { @@ -27,6 +27,12 @@ public static function on(array|Comparison $comparison, string $joinPrefix = '') $comparisons = []; foreach ($comparison as $left => $right) { + if ($right instanceof Comparison) { + $comparisons[] = $right; + + continue; + } + if (!\is_string($left)) { throw new RuntimeException('Expected left entry name to be string, got ' . \gettype($left) . ". Example: ['id' => 'id']"); }