|
| 1 | +<!--- |
| 2 | + Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +--> |
| 19 | + |
| 20 | +# Datafusion-Specific Functions |
| 21 | + |
| 22 | +These SQL functions are specific to DataFusion, or they are well known and have functionality which is specific to DataFusion. Specifically, the `to_timestamp_xx()` functions exist due to Arrow's support for multiple timestamp resolutions. |
| 23 | + |
| 24 | +## `to_timestamp` |
| 25 | + |
| 26 | +`to_timestamp()` is similar to the standard SQL function. It performs conversions to type `Timestamp(Nanoseconds, None)`, from: |
| 27 | + |
| 28 | +- Timestamp strings |
| 29 | + - `1997-01-31T09:26:56.123Z` # RCF3339 |
| 30 | + - `1997-01-31T09:26:56.123-05:00` # RCF3339 |
| 31 | + - `1997-01-31 09:26:56.123-05:00` # close to RCF3339 but with a space er than T |
| 32 | + - `1997-01-31T09:26:56.123` # close to RCF3339 but no timezone et specified |
| 33 | + - `1997-01-31 09:26:56.123` # close to RCF3339 but uses a space and timezone offset |
| 34 | + - `1997-01-31 09:26:56` # close to RCF3339, no fractional seconds |
| 35 | +- An Int64 array/column, values are nanoseconds since Epoch UTC |
| 36 | +- Other Timestamp() columns or values |
| 37 | + |
| 38 | +Note that conversions from other Timestamp and Int64 types can also be performed using `CAST(.. AS Timestamp)`. However, the conversion functionality here is present for consistency with the other `to_timestamp_xx()` functions. |
| 39 | + |
| 40 | +## `to_timestamp_millis` |
| 41 | + |
| 42 | +`to_timestamp_millis()` does conversions to type `Timestamp(Milliseconds, None)`, from: |
| 43 | + |
| 44 | +- Timestamp strings, the same as supported by the regular timestamp() function (except the output is a timestamp of Milliseconds resolution) |
| 45 | + - `1997-01-31T09:26:56.123Z` # RCF3339 |
| 46 | + - `1997-01-31T09:26:56.123-05:00` # RCF3339 |
| 47 | + - `1997-01-31 09:26:56.123-05:00` # close to RCF3339 but with a space er than T |
| 48 | + - `1997-01-31T09:26:56.123` # close to RCF3339 but no timezone et specified |
| 49 | + - `1997-01-31 09:26:56.123` # close to RCF3339 but uses a space and timezone offset |
| 50 | + - `1997-01-31 09:26:56` # close to RCF3339, no fractional seconds |
| 51 | +- An Int64 array/column, values are milliseconds since Epoch UTC |
| 52 | +- Other Timestamp() columns or values |
| 53 | + |
| 54 | +Note that `CAST(.. AS Timestamp)` converts to Timestamps with Nanosecond resolution; this function is the only way to convert/cast to millisecond resolution. |
| 55 | + |
| 56 | +## `to_timestamp_micros` |
| 57 | + |
| 58 | +`to_timestamp_micros()` does conversions to type `Timestamp(Microseconds, None)`, from: |
| 59 | + |
| 60 | +- Timestamp strings, the same as supported by the regular timestamp() function (except the output is a timestamp of microseconds resolution) |
| 61 | + - `1997-01-31T09:26:56.123Z` # RCF3339 |
| 62 | + - `1997-01-31T09:26:56.123-05:00` # RCF3339 |
| 63 | + - `1997-01-31 09:26:56.123-05:00` # close to RCF3339 but with a space er than T |
| 64 | + - `1997-01-31T09:26:56.123` # close to RCF3339 but no timezone et specified |
| 65 | + - `1997-01-31 09:26:56.123` # close to RCF3339 but uses a space and timezone offset |
| 66 | + - `1997-01-31 09:26:56` # close to RCF3339, no fractional seconds |
| 67 | +- An Int64 array/column, values are microseconds since Epoch UTC |
| 68 | +- Other Timestamp() columns or values |
| 69 | + |
| 70 | +Note that `CAST(.. AS Timestamp)` converts to Timestamps with Nanosecond resolution; this function is the only way to convert/cast to microsecond resolution. |
| 71 | + |
| 72 | +## `to_timestamp_seconds` |
| 73 | + |
| 74 | +`to_timestamp_seconds()` does conversions to type `Timestamp(Seconds, None)`, from: |
| 75 | + |
| 76 | +- Timestamp strings, the same as supported by the regular timestamp() function (except the output is a timestamp of secondseconds resolution) |
| 77 | + - `1997-01-31T09:26:56.123Z` # RCF3339 |
| 78 | + - `1997-01-31T09:26:56.123-05:00` # RCF3339 |
| 79 | + - `1997-01-31 09:26:56.123-05:00` # close to RCF3339 but with a space er than T |
| 80 | + - `1997-01-31T09:26:56.123` # close to RCF3339 but no timezone et specified |
| 81 | + - `1997-01-31 09:26:56.123` # close to RCF3339 but uses a space and timezone offset |
| 82 | + - `1997-01-31 09:26:56` # close to RCF3339, no fractional seconds |
| 83 | +- An Int64 array/column, values are seconds since Epoch UTC |
| 84 | +- Other Timestamp() columns or values |
| 85 | + |
| 86 | +Note that `CAST(.. AS Timestamp)` converts to Timestamps with Nanosecond resolution; this function is the only way to convert/cast to seconds resolution. |
0 commit comments