...
TIMESTAMP
(Note: Only available starting with Hive 0.8.0)DATE
(Note: Only available starting with Hive 0.12.0)INTERVAL
(Note: Only available starting with Hive 1.2.0)
String Types
STRING
VARCHAR
(Note: Only available starting with Hive 0.12.0)CHAR
(Note: Only available starting with Hive 0.13.0)
...
Valid casts to/from Date type | Result |
---|---|
cast(date as date) | Same date value |
cast(timestamp as date) | The year/month/day of the timestamp is determined, based on the local timezone, and returned as a date value. |
cast(string as date) | If the string is in the form 'YYYY-MM-DD', then a date value corresponding to that year/month/day is returned. If the string value does not match this formate, then NULL is returned. |
cast(date as timestamp) | A timestamp value is generated corresponding to midnight of the year/month/day of the date value, based on the local timezone. |
cast(date as string) | The year/month/day represented by the Date is formatted as a string in the form 'YYYY-MM-DD'. |
...
Intervals
Supported interval description | Example | meaningMeaning | sinceSince |
---|---|---|---|
Intervals of time units: SECOND / MINUTE / DAY / MONTH / YEAR | INTERVAL '1' DAY | an interval of 1 daysday(s) | Hive 1.2.0 (HIVE-9792). |
Year to month intervals, format: SY-M S: optional sign (+/-) | INTERVAL '1-2' YEAR TO MONTH | shorthand for: INTERVAL '1' YEAR + | Hive 1.2.0 (HIVE-9792). |
Day to second intervals, format: SD H:M:S.nnnnnn S: optional sign (+/-) D: day countH: hoursM: minutes S: seconds nnnnnn: optional nanotime | INTERVAL '1 2:3:4.000005' DAY | shorthand for: INTERVAL '1' DAY+ | Hive 1.2.0 (HIVE-9792). |
Support for intervals with constant numbers | INTERVAL 1 DAY | aids query readability / portability | Hive 2.2.0 (HIVE-13557). |
Support for intervals with expressions: this may involve other functions/ columnscolumns. a number (which is not floatingpointfloating-point) or with a string. | INTERVAL (1+dt) DAY | enables dynamic intervals | Hive 2.2.0 (HIVE-13557). |
Optional usage of interval keyword | 1 DAY | INTERVAL 1 DAY | Hive 2.2.0 (HIVE-13557). |
Add timeunit aliases to aid portability / readability .:
SECONDS / MINUTES / HOURS / DAYS / WEEKS / MONTHS / YEARS | 2 SECONDS | 2 SECOND | Hive 2.2.0 (HIVE-13557). |
Anchor | ||||
---|---|---|---|---|
|
Decimals
Info | ||
---|---|---|
| ||
Decimal datatype was introduced in Hive 0.11.0 (HIVE-2693) and revised in Hive 0.13.0 (HIVE-3976). |
...