Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Load data to external table using date field as partitioned

Solved Go to solution
Highlighted

Load data to external table using date field as partitioned

Rising Star

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Load data to external table using date field as partitioned

Guru

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.

View solution in original post

2 REPLIES 2
Highlighted

Re: Load data to external table using date field as partitioned

Guru

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.

View solution in original post

Re: Load data to external table using date field as partitioned

Contributor

Perfect answer!

Don't have an account?
Coming from Hortonworks? Activate your account here