Created
January 28, 2016 13:25
-
-
Save thanoojgithub/8af9d7938143c1096c3a to your computer and use it in GitHub Desktop.
Casting in Hive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hive> set hive.cli.print.header=true; | |
hive> select * from raw; | |
OK | |
raw.id raw.name raw.dt | |
1 sriram 2015-10-12 | |
2 seetamma 2015-09-12 | |
3 lakshmana 2015-11-12 | |
4 bharatha 2015-12-12 | |
5 Shatrughna 2015-12-12 | |
6 hanuma 2015-11-12 | |
Time taken: 0.066 seconds, Fetched: 6 row(s) | |
hive> SELECT id,name,dt doj FROM raw WHERE cast(dt AS DATE) > '2015-11-12'; | |
OK | |
id name doj | |
4 bharatha 2015-12-12 | |
5 Shatrughna 2015-12-12 | |
Time taken: 0.072 seconds, Fetched: 2 row(s) | |
hive> SELECT id,name,dt doj FROM raw WHERE cast(dt AS DATE) < '2015-11-12'; | |
OK | |
id name doj | |
1 sriram 2015-10-12 | |
2 seetamma 2015-09-12 | |
Time taken: 0.074 seconds, Fetched: 2 row(s) | |
hive> SELECT id,name,dt doj FROM raw WHERE cast(dt AS DATE) = '2015-11-12'; | |
OK | |
id name doj | |
3 lakshmana 2015-11-12 | |
6 hanuma 2015-11-12 | |
Time taken: 0.065 seconds, Fetched: 2 row(s) | |
hive> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment