2626 SortingPipeline ,
2727 VoidPipeline };
2828use Flow \ETL \Row \{Reference , References , Schema , Schema \Definition };
29- use Flow \ETL \Transformer \{
30- AutoCastTransformer ,
29+ use Flow \ETL \Transformer \{AutoCastTransformer ,
3130 CallbackRowTransformer ,
3231 CrossJoinRowsTransformer ,
3332 DropDuplicatesTransformer ,
3433 DropEntriesTransformer ,
3534 DropPartitionsTransformer ,
35+ DuplicateRowTransformer ,
3636 EntryNameStyleConverterTransformer ,
3737 JoinEachRowsTransformer ,
3838 LimitTransformer ,
4646 ScalarFunctionTransformer ,
4747 SelectEntriesTransformer ,
4848 UntilTransformer ,
49- WindowFunctionTransformer
50- };
49+ WindowFunctionTransformer };
5150use Flow \Filesystem \Path \Filter ;
5251
5352final class DataFrame
@@ -259,6 +258,13 @@ public function dropPartitions(bool $dropPartitionColumns = false) : self
259258 return $ this ;
260259 }
261260
261+ public function duplicateRow (mixed $ condition , WithEntry ...$ entries ) : self
262+ {
263+ $ this ->pipeline ->add (new DuplicateRowTransformer ($ condition , ...$ entries ));
264+
265+ return $ this ;
266+ }
267+
262268 /**
263269 * Be aware that fetch is not memory safe and will load all rows into memory.
264270 * If you want to safely iterate over Rows use oe of the following methods:.
@@ -776,7 +782,7 @@ public function sortBy(Reference ...$entries) : self
776782 *
777783 * @lazy
778784 */
779- public function transform (Transformer |Transformation |Transformations $ transformer ) : self
785+ public function transform (Transformer |Transformation |Transformations | WithEntry $ transformer ) : self
780786 {
781787 return $ this ->with ($ transformer );
782788 }
@@ -823,7 +829,7 @@ public function void() : self
823829 /**
824830 * @lazy
825831 */
826- public function with (Transformer |Transformation |Transformations $ transformer ) : self
832+ public function with (Transformer |Transformation |Transformations | WithEntry $ transformer ) : self
827833 {
828834 if ($ transformer instanceof Transformer) {
829835 $ this ->pipeline ->add ($ transformer );
@@ -837,18 +843,28 @@ public function with(Transformer|Transformation|Transformations $transformer) :
837843 return $ this ;
838844 }
839845
846+ if ($ transformer instanceof WithEntry) {
847+ $ this ->withEntry ($ transformer ->name , $ transformer ->function );
848+
849+ return $ this ;
850+ }
851+
840852 return $ transformer ->transform ($ this );
841853 }
842854
843855 /**
844856 * @lazy
845857 *
846- * @param array<string, ScalarFunction|WindowFunction> $references
858+ * @param array<string, ScalarFunction|WindowFunction|WithEntry > $references
847859 */
848860 public function withEntries (array $ references ) : self
849861 {
850862 foreach ($ references as $ entryName => $ ref ) {
851- $ this ->withEntry ($ entryName , $ ref );
863+ if ($ ref instanceof WithEntry) {
864+ $ this ->withEntry ($ ref ->name , $ ref ->function );
865+ } else {
866+ $ this ->withEntry ($ entryName , $ ref );
867+ }
852868 }
853869
854870 return $ this ;
0 commit comments