ektravel commented on code in PR #16900: URL: https://github.com/apache/druid/pull/16900#discussion_r1723998616
########## docs/querying/sql-functions.md: ########## @@ -2279,19 +2422,62 @@ Returns whether a timestamp is contained within a particular interval, formatted ## TIME_PARSE -`TIME_PARSE(<string_expr>, [<pattern>, [<timezone>]])` +Parses a string into a timestamp using a given [Joda DateTimeFormat pattern](http://www.joda.org/joda-time/apidocs/org/joda/time/format/DateTimeFormat.html), or ISO 8601 if the pattern is not provided. Returns NULL if string cannot be parsed. If provided, `timezone`, should be a time zone name like `America/Los_Angeles` or an offset like `-08:00`. -**Function type:** [Scalar, date and time](sql-scalar.md#date-and-time-functions) +* **Syntax:** `TIME_PARSE(string_expr[, pattern[, timezone]])` +* **Function type:** Scalar, date and time + +<details><summary>Example</summary> + +The following example parses the `FlightDate` column from the `flight-carriers` datasource, which is stored as a `string`, into a valid timestamp with an offset of `-05:00` hours. + +```sql +SELECT + "FlightDate" AS "original_string", + TIME_PARSE("FlightDate", 'YYYY-MM-dd', '-05:00') AS "timestamp" +FROM "flight-carriers" +LIMIT 1 +``` + +Returns the following: + +| `original_string` | `timestamp` | +| -- | -- | +| `2005-11-01` | `2005-11-01T05:00:00.000Z` | + +</details> -Parses a string into a timestamp. +[Learn more](sql-scalar.md#date-and-time-functions) ## TIME_SHIFT -`TIME_SHIFT(<TIMESTAMP>, <period>, <step>, [<timezone>])` +Shifts a timestamp by a given number of time units. Period can be any ISO 8601 period. Step may be negative. If provided, `timezone`, should be a time zone name like `America/Los_Angeles` or an offset like `-08:00`. Review Comment: ```suggestion Shifts a timestamp by a given number of time units. Period can be any ISO 8601 period. `step` can be a negative value. If provided, `timezone` should be a time zone name like `America/Los_Angeles` or an offset like `-08:00`. ``` -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
