Support Questions

Find answers, ask questions, and share your expertise
Announcements
Check out our newest addition to the community, the Cloudera Data Analytics (CDA) group hub.

[Load special file to Hive]

New Contributor

Hi all,

In folder "A" have many file, I need load into external table Hive:

1. ads_creatives_2018-05-01.json

2. ads_creatives_audit_content_2018-05-01.json

3. video_hash_2018-05-01.json

I need load file 1 into table 1, file 2 into table 2...v.. But I don't want restructuring folder "A".

I think Hive (location) has regex to load special file in a folder. But I can't find it.

I try use "load data inpath" but which remove file source. I don't know which has option don't remove file source.?

Can you help me? I need a solution.

Thanks all. :))

1 REPLY 1

Super Collaborator

I am not sure if I got you right, but what you want is to create three external hive tables where each of them has exactly 1 file as the data? Or do you need a filename pattern?

If you used 'LOAD DATA INPATH...' as a command it is the expected behaviour that it will move a hdfs path into the hive controlled path of hdfs: https://cwiki.apache.org/confluence/display/Hive/GettingStarted

To create the schema based on a file outside the hive controlled hdfs path you need to use the CREATE EXTERNAL TABLE with the json serde and provide the file name as location.

If you need a regex as the filename pattern, try using WITH SERDEPROPERTIES ( "input.regex" = "*.json") and provide only the path as the location.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.