Skip to content

Commit

Permalink
Changed default value for format in toDate scalar function (#809)
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech authored Nov 20, 2023
1 parent 2c42e5f commit 6ead603
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/topics/aggregations/daily_revenue.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
$flow = (new Flow())
->read(Parquet::from(__FLOW_DATA__ . '/orders_flow.parquet'))
->select('created_at', 'total_price', 'discount')
->withEntry('created_at', ref('created_at')->toDate(\DateTime::RFC3339)->dateFormat('Y/m'))
->withEntry('created_at', ref('created_at')->toDate()->dateFormat('Y/m'))
->withEntry('revenue', ref('total_price')->minus(ref('discount')))
->select('created_at', 'revenue')
->groupBy('created_at')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function test_writing_with_partitioning() : void
$this->createRow(1, new \DateTimeImmutable('2020-01-02 00:02:00')),
$this->createRow(1, new \DateTimeImmutable('2020-01-03 00:01:00')),
)))
->withEntry('date', ref('datetime')->toDate(\DateTimeInterface::RFC3339)->dateFormat())
->withEntry('date', ref('datetime')->toDate()->dateFormat())
->partitionBy(ref('date'))
->write(Parquet::to($path))
->run();
Expand Down
2 changes: 1 addition & 1 deletion src/core/etl/src/Flow/ETL/Function/EntryScalarFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ public function strReplace(string|array $search, string|array $replace) : Scalar
*
* @return ScalarFunction
*/
public function toDate(string $format = 'Y-m-d', \DateTimeZone $timeZone = new \DateTimeZone('UTC')) : ScalarFunction|EntryReference
public function toDate(string $format = \DateTimeInterface::RFC3339, \DateTimeZone $timeZone = new \DateTimeZone('UTC')) : ScalarFunction|EntryReference
{
return new ScalarFunctions(new Function\ToDate($this, $format, $timeZone));
}
Expand Down

0 comments on commit 6ead603

Please sign in to comment.