alamb commented on a change in pull request #1381:
URL: https://github.com/apache/arrow-datafusion/pull/1381#discussion_r758777697
##########
File path: datafusion/src/physical_plan/datetime_expressions.rs
##########
@@ -434,6 +438,11 @@ mod tests {
"week",
"2019-12-30T00:00:00.000000Z",
),
+ (
+ "2020-01-01T13:42:29.190855Z",
Review comment:
I recommend at least one other test that shows a quarter other than `Q1`
-- for example
```
"2020-05-023T13:42:29.190855Z",
```
I would expect the result to be `2020-04-01`.
FYI you can test expected answers in `postgres` using `pswl` with queries
such as
```sql
alamb=# select date_trunc('quarter', cast('2020-05-023T13:42:29.190855Z' as
timestamp));
date_trunc
---------------------
2020-04-01 00:00:00
(1 row)
alamb=# select date_trunc('quarter', cast('2020-10-023T13:42:29.190855Z' as
timestamp));
date_trunc
---------------------
2020-10-01 00:00:00
(1 row)
```
##########
File path: datafusion/src/physical_plan/datetime_expressions.rs
##########
@@ -203,6 +203,10 @@ fn date_trunc_single(granularity: &str, value: i64) ->
Result<i64> {
.and_then(|d| d.with_minute(0))
.and_then(|d| d.with_hour(0))
.and_then(|d| d.with_day0(0)),
+ "quarter" => value
Review comment:
I don't fully understand how this code will truncate the timestamp to
the calendar quarter. It seems like it will truncate to "day".
I have suggested some tests that would show its behavior one way or the other
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]