Function tips for date and string

The to_date(...) function removes hours, minutes, and seconds from a date. This is useful when we need to check whether the values of date/time type columns are within the data range, such as to_date(update_datetime) between 2014-11-01 and 2014-11-31. to_date(...) can be used as follows:

> SELECT TO_DATE(FROM_UNIXTIME(UNIX_TIMESTAMP())) as currentdate;+---------------+| currentdate   |+---------------+| 2018-05-15    |+---------------+1 row selected (0.153 seconds)

The reverse(...) function reverses the order of each letter in a string. The split(...) function tokenizes the string using a specified tokenizer. Here is an example of using both of them to get the filename from a path:

> SELECT> reverse(split(reverse('/home/user/employee.txt'),'/')[0]) ...

Get Apache Hive Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.