I have raw files in HDFS in the format
name=ABC age=10 Location=QWERTY
name=DEF age=15 Location=IWIORS
How do I import data from these flat files into a Hive table with columns 'name' and 'location' only.
I have raw files in HDFS in the format
name=ABC age=10 Location=QWERTY
name=DEF age=15 Location=IWIORS
How do I import data from these flat files into a Hive table with columns 'name' and 'location' only.
You can do the following.
In table declaration, use:
ROW FORMAT DELIMITED
FIELDS TERMINATED BY ' ' --space
MAP KEYS TERMINATED BY '='
Also your table will have a single column with data type as Map.
So when you can retireve data from the single column using the key.
Other option: Write your own SerDe. Link below explain the process for JSON data. I am sure you can customize it for your requirements: http://blog.cloudera.com/blog/2012/12/how-to-use-a-serde-in-apache-hive/