Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • arrays: ARRAY<data_type>
  • maps: MAP<primitive_type, data_type>
  • Wiki Markup
    structs: {{STRUCT<col_name : data_type \[COMMENT col_comment\], ...>}}
  • union: UNIONTYPE<data_type, data_type, ...>

...

Info
titleVersion

Dates were introduced in Hive 0.12.0 (HIVE-4055).

Casting 

Date types can only be converted to/from Date, Timestamp, or String types.

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

Decimals

Anchor
decimal
decimal

...