Skip to content

Commit 5d2ee1d

Browse files
authored
Allow to pass limit as null to not break the pipeline (#1498)
* Allow to pass limit as null to not break the pipeline * CS Fixes
1 parent e5c26ca commit 5d2ee1d

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/core/etl/src/Flow/ETL/DataFrame.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,12 @@ public function joinEach(DataFrameFactory $factory, Expression $on, string|Join
540540
*
541541
* @throws InvalidArgumentException
542542
*/
543-
public function limit(int $limit) : self
543+
public function limit(?int $limit) : self
544544
{
545+
if ($limit === null) {
546+
return $this;
547+
}
548+
545549
$this->pipeline = $this->context->config->optimizer()->optimize(new LimitTransformer($limit), $this->pipeline);
546550

547551
return $this;

src/core/etl/src/Flow/ETL/Transformation/Limit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
final readonly class Limit implements Transformation
1010
{
11-
public function __construct(private int $limit)
11+
public function __construct(private ?int $limit)
1212
{
1313
}
1414

src/core/etl/tests/Flow/ETL/Tests/Integration/DataFrame/LimitTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,21 @@ public function test_limit_below_0() : void
115115
df()->read(from_rows(\Flow\ETL\DSL\rows()))->limit(-1);
116116
}
117117

118+
public function test_limit_null() : void
119+
{
120+
$rows = df()
121+
->read(from_array(
122+
\array_map(
123+
fn (int $id) : array => ['id' => $id],
124+
\range(1, 10)
125+
)
126+
))
127+
->limit(null)
128+
->fetch();
129+
130+
self::assertCount(10, $rows);
131+
}
132+
118133
public function test_limit_when_transformation_is_expanding_rows_extracted_from_extractor() : void
119134
{
120135
$rows = df()

0 commit comments

Comments
 (0)