Hive query select as alias and format date

select as alias

In Hive, in order to use select COL as “Alias” syntax, we cannot use single or double quote. We have to use the special “backtick” symbol -> `

Example: SELECT user_name AS `system user name`, …..

date format

To format date, we need to convert the date to bigint with unix_timestamp function and then convert back using from_unixtime function.

example :

FROM_UNIXTIME(unix_timestamp(TRD_DT), 'MM/dd/yyyy') AS `Trade Date`

Comparing to all these, presto is quite straightforward, alias just need to be wrapped in the double quotes, and format date just using the DATE_FORMAT(date, format) function.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s