You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/11/01 09:24:07 UTC

[GitHub] [arrow-datafusion] naosense commented on a diff in pull request #4054: Implement `current_time` scalar function

naosense commented on code in PR #4054:
URL: https://github.com/apache/arrow-datafusion/pull/4054#discussion_r1010241100


##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -200,6 +200,20 @@ pub fn make_current_date(
     move |_arg| Ok(ColumnarValue::Scalar(ScalarValue::Date32(days)))
 }
 
+/// Create an implementation of `current_time()` that always returns the
+/// specified current time.
+///
+/// The semantics of `current_time()` require it to return the same value
+/// wherever it appears within a single statement. This value is
+/// chosen during planning time.
+pub fn make_current_time(
+    now_ts: DateTime<Utc>,
+) -> impl Fn(&[ColumnarValue]) -> Result<ColumnarValue> {
+    let nano =
+        Duration::seconds(now_ts.num_seconds_from_midnight() as i64).num_nanoseconds();

Review Comment:
   I found a bug, nanoseconds less than a second will be loss if `num_seconds_from_midnight()` is used,     I will do  this in another way



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org