Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

Any way to create External Table with Specific Set of Files

avatar

Hi,

We are copying files from our upstream system which are in JSON GZ format. They are following a pattern for very daily slice say YYYYMMDDHH (2018053100) they are maintianing two folders DATA and METADATA. Where DATA holds actual data and METADATA holds RowCount of that day's data.We need to create external table on top of copied data, where it only consider *.json.gz extension files only, excluding other file extensions. We dont want to copy files into another location since they are large in size. We also tried INPUT_ FILENAME .... virtual column, it didn't work. Any suggesstion for this scnearios ?

1 ACCEPTED SOLUTION

avatar

Hey @Mahender S!
You can try a solution with hive + regex, using RegexSerde
Here's an example:

CREATE EXTERNAL TABLE Vini (name STRING) 
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' 
WITH SERDEPROPERTIES  ( "input.regex" = "*.json.gz")
LOCATION 'hdfs://myHDFSwithHA/user/hive/warehouse/test.db/vini'
Hope this helps ! 🙂

View solution in original post

3 REPLIES 3

avatar

Hey @Mahender S!
You can try a solution with hive + regex, using RegexSerde
Here's an example:

CREATE EXTERNAL TABLE Vini (name STRING) 
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' 
WITH SERDEPROPERTIES  ( "input.regex" = "*.json.gz")
LOCATION 'hdfs://myHDFSwithHA/user/hive/warehouse/test.db/vini'
Hope this helps ! 🙂

avatar

Thanks Vinicius. It worked.

avatar

Awesome @Mahender S
As the issue is resolved, hence it will be also great if you can mark this HCC thread as Answered by clicking on the "Accept" Button. That way other HCC users can quickly find the solution when they encounter the same issue.!
Thanks 🙂