alamb commented on code in PR #8369:
URL: https://github.com/apache/arrow-datafusion/pull/8369#discussion_r1411325133


##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -157,6 +161,10 @@ pub fn to_timestamp_micros(args: &[ColumnarValue]) -> 
Result<ColumnarValue> {
 }
 
 /// to_timestamp_nanos SQL function
+///
+/// Note: `to_timestamp_nanos` returns `Timestamp(Nanosecond)`. The supported 
range for integer input is between `-9223372037` and `9223372036`.

Review Comment:
   this doesn't seem right. I think the argument is treated as nanoseconds, so 
the range is really `-i64::MIN` to `i64::MAX`
   
   For example, this works just fine
   
   ```
   ❯ select to_timestamp_nanos(92233720360000)
   ;
   +-------------------------------------------+
   | to_timestamp_nanos(Int64(92233720360000)) |
   +-------------------------------------------+
   | 1970-01-02T01:37:13.720360                |
   +-------------------------------------------+
   1 row in set. Query took 0.000 seconds.
   ```



##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -1497,6 +1500,9 @@ return the corresponding timestamp.
 to_timestamp_nanos(expression)
 ```
 
+Note: `to_timestamp_nanos` returns `Timestamp(Nanosecond)`. The supported 
range for integer input is between `-9223372037` and `9223372036`.

Review Comment:
   👍 



##########
docs/source/user-guide/sql/scalar_functions.md:
##########
@@ -1497,6 +1500,9 @@ return the corresponding timestamp.
 to_timestamp_nanos(expression)
 ```
 
+Note: `to_timestamp_nanos` returns `Timestamp(Nanosecond)`. The supported 
range for integer input is between `-9223372037` and `9223372036`.

Review Comment:
   👍 



##########
datafusion/physical-expr/src/datetime_expressions.rs:
##########
@@ -157,6 +161,10 @@ pub fn to_timestamp_micros(args: &[ColumnarValue]) -> 
Result<ColumnarValue> {
 }
 
 /// to_timestamp_nanos SQL function
+///
+/// Note: `to_timestamp_nanos` returns `Timestamp(Nanosecond)`. The supported 
range for integer input is between `-9223372037` and `9223372036`.

Review Comment:
   this doesn't seem right. I think the argument is treated as nanoseconds, so 
the range is really `-i64::MIN` to `i64::MAX`
   
   For example, this works just fine
   
   ```
   ❯ select to_timestamp_nanos(92233720360000)
   ;
   +-------------------------------------------+
   | to_timestamp_nanos(Int64(92233720360000)) |
   +-------------------------------------------+
   | 1970-01-02T01:37:13.720360                |
   +-------------------------------------------+
   1 row in set. Query took 0.000 seconds.
   ```



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