- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
How to set variable in hive partition ?
- Labels:
-
Apache Hive
Created ‎07-12-2017 05:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello all,
How to set variable in hive and insert value as partition? I have below commands and the partition is not getting from the variable that I set but getting constant "var" instead datetime.
set hiveVar:var= from_unixtime(unix_timestamp()-1*60*60*4, 'yyyyMMddHH');
INSERT INTO TABLE tmp Partition (datehour='${hiveVar:var}') SELECT * FROM tmp2;
Please help.
Thanks
JN
Created ‎07-12-2017 08:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just omit the quotes and fire the insert.
INSERT INTO TABLE tmp Partition (datehour=${hiveVar:var}) SELECT * FROM tmp2;
You can also test before firing the insert like this:
select ${hiveVar:var};
You should be good.
Thanks
Created ‎07-12-2017 08:17 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just omit the quotes and fire the insert.
INSERT INTO TABLE tmp Partition (datehour=${hiveVar:var}) SELECT * FROM tmp2;
You can also test before firing the insert like this:
select ${hiveVar:var};
You should be good.
Thanks
Created ‎07-19-2017 04:42 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You might want to close the thread by accepting the answer.
