- Subscribe to RSS Feed
- Mark Question as New
- Mark Question as Read
- Float this Question for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Load data to external table using date field as partitioned
- Labels:
-
Apache Hadoop
-
Apache Hive
Created ‎06-09-2017 10:41 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have data having date fields "yyyymmddhhmmss".
I would like to load this data to extrnal table but with a formatted date field "yyyymmdd" using hive.
can someone help please.
Created ‎06-09-2017 10:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi @Dinesh Das
If you load your data as a String initially into a staging table, you can use the unix_timestamp() function to get easy date formatting:
select from_unixtime(unix_timestamp(origDateColumn ,'yyyyMMddhhmmss'), 'yyyyMMdd') from StagingTable
Alternatively, you can create a custom UDF to handle it for you.
As always, if you find this post useful, please "Accept" the answer.
Created ‎06-09-2017 10:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi @Dinesh Das
If you load your data as a String initially into a staging table, you can use the unix_timestamp() function to get easy date formatting:
select from_unixtime(unix_timestamp(origDateColumn ,'yyyyMMddhhmmss'), 'yyyyMMdd') from StagingTable
Alternatively, you can create a custom UDF to handle it for you.
As always, if you find this post useful, please "Accept" the answer.
Created ‎06-10-2017 09:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Perfect answer!
