Skip to content

Commit c19260d

Browse files
compheadalamb
andauthored
Document timestamp input limits (#8369)
* document timestamp input limis * fix text * prettier * remove doc for nanoseconds * Update datafusion/physical-expr/src/datetime_expressions.rs Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org> --------- Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
1 parent e19c669 commit c19260d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

datafusion/physical-expr/src/datetime_expressions.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ fn string_to_timestamp_nanos_shim(s: &str) -> Result<i64> {
130130
}
131131

132132
/// to_timestamp SQL function
133+
///
134+
/// Note: `to_timestamp` returns `Timestamp(Nanosecond)` though its arguments are interpreted as **seconds**. The supported range for integer input is between `-9223372037` and `9223372036`.
135+
/// Supported range for string input is between `1677-09-21T00:12:44.0` and `2262-04-11T23:47:16.0`.
136+
/// Please use `to_timestamp_seconds` for the input outside of supported bounds.
133137
pub fn to_timestamp(args: &[ColumnarValue]) -> Result<ColumnarValue> {
134138
handle::<TimestampNanosecondType, _, TimestampNanosecondType>(
135139
args,

docs/source/user-guide/sql/scalar_functions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,9 @@ Strings are parsed as RFC3339 (e.g. '2023-07-20T05:44:00')
14621462
Integers, unsigned integers, and doubles are interpreted as seconds since the unix epoch (`1970-01-01T00:00:00Z`)
14631463
return the corresponding timestamp.
14641464

1465+
Note: `to_timestamp` returns `Timestamp(Nanosecond)`. The supported range for integer input is between `-9223372037` and `9223372036`.
1466+
Supported range for string input is between `1677-09-21T00:12:44.0` and `2262-04-11T23:47:16.0`. Please use `to_timestamp_seconds` for the input outside of supported bounds.
1467+
14651468
```
14661469
to_timestamp(expression)
14671470
```

0 commit comments

Comments
 (0)