-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARROW-11055: [Rust] [DataFusion] Support date_trunc function #9040
Conversation
Cool! A few small comments:
|
The full set of Rust CI tests did not run on this PR :( Can you please rebase this PR against apache/master to pick up the changes in #9056 so that they do? I apologize for the inconvenience. |
12914e8
to
d12c12f
Compare
Hey @jhorstmann ! Thanks for the review!
I've swapped arguments order. It's 50/50 among databases however agree Postgres order is a little bit more common.
I've added some tests at the beginning of the year. Is it something you were looking for?
Yep. Agree it's out of scope for this PR. @alamb I rebased it against the latest master. |
Codecov Report
@@ Coverage Diff @@
## master #9040 +/- ##
========================================
Coverage 82.56% 82.56%
========================================
Files 203 203
Lines 50042 50236 +194
========================================
+ Hits 41315 41476 +161
- Misses 8727 8760 +33
Continue to review full report at Codecov.
|
f7b53f2
to
7a1a618
Compare
if array.is_null(i) { | ||
Ok(0_i64) | ||
} else { | ||
let date_time = match granularity_array.value(i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This list seems consistent with https://www.postgresql.org/docs/9.1/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC 👍 I think it is fine that we don't yeet support some of the more esoteric stuff (like milleniumm')
string_builder.append_value("week")?; | ||
|
||
ts_builder.append_value("2020-01-01T13:42:29.190855Z")?; | ||
truncated_builder.append_value("2019-12-30T00:00:00.000000Z")?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -35,6 +35,8 @@ pub(crate) enum GroupByScalar { | |||
Int32(i32), | |||
Int64(i64), | |||
Utf8(Box<String>), | |||
TimeMicrosecond(i64), | |||
TimeNanosecond(i64), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @paveltiunov -- this looks like a great initial addition.
The only thing I think might be worthwhile (as a follow on PR) would be a sql level test in https://github.com/apache/arrow/blob/master/rust/datafusion/tests/sql.rs (to ensure everything was hooked up correctly)
Again, thanks again
@alamb Gotcha. I actually added SQL test however it went to |
`date_trunc` SQL function implementation and GROUP BY timestamp support. Closes apache#9040 from paveltiunov/date-trunc Authored-by: Pavel Tiunov <pavel.tiunov@gmail.com> Signed-off-by: Andrew Lamb <andrew@nerdnetworks.org>
date_trunc
SQL function implementation and GROUP BY timestamp support.