alamb commented on a change in pull request #1030:
URL: https://github.com/apache/arrow-datafusion/pull/1030#discussion_r712908010



##########
File path: datafusion/src/logical_plan/expr.rs
##########
@@ -1360,24 +1360,63 @@ pub fn in_list(expr: Expr, list: Vec<Expr>, negated: 
bool) -> Expr {
 pub trait Literal {
     /// convert the value to a Literal expression
     fn lit(&self) -> Expr;
+
+    /// convert the number to literal expression of timestamp in nanosecond
+    fn lit_timestamp_nanosecond(&self) -> Expr;

Review comment:
       I was thinking perhaps calling this `lit_timestamp_nano` or something 
would be more consistent with chrono, but when I looked, `chrono` appears to be 
inconsistent on this point (uses both `nano` and `nanosecond`) 
https://docs.rs/chrono/0.4.19/chrono/?search=nano

##########
File path: datafusion/src/logical_plan/expr.rs
##########
@@ -1387,6 +1426,11 @@ macro_rules! make_literal {
             fn lit(&self) -> Expr {
                 Expr::Literal(ScalarValue::$SCALAR(Some(self.clone())))
             }
+
+            fn lit_timestamp_nanosecond(&self) -> Expr {
+                let scalar = ScalarValue::$SCALAR(Some(self.clone()));
+                scalar.lit_timestamp_nanosecond()

Review comment:
       +1

##########
File path: datafusion/src/logical_plan/expr.rs
##########
@@ -1408,6 +1452,11 @@ pub fn lit<T: Literal>(n: T) -> Expr {
     n.lit()
 }
 
+/// Create a literal timestamp expression
+pub fn lit_timestamp_nanosecond<T: Literal>(n: T) -> Expr {

Review comment:
       I think it would be nice to try and parse `str` into timestamps, though 
that would require making this function fallible, which might be kind of messy. 
🤔 




-- 
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]


Reply via email to