I have a file with id and year. My fields are separated by , and .. Is there any chance I can in the place of fields terminated by can I use , and .? 
            Asked
            
        
        
            Active
            
        
            Viewed 319 times
        
    1
            
            
        
        leftjoin
        
- 36,950
 - 8
 - 57
 - 116
 
        user2815076
        
- 29
 - 7
 
- 
                    What kind of delimited file would have 2 separate delimiters ? – philantrovert Dec 22 '17 at 08:45
 
1 Answers
1
            This is possible using RegexSerDe.
hive> CREATE EXTERNAL TABLE citiesr1 (id int, city_org string, ppl float) 
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe' 
WITH SERDEPROPERTIES ('input.regex'='^(\\d+)\\.(\\S+),(\\d++.\\d++)\\t.*')
LOCATION '/user/it1/hive/serde/regex';
In the regex above three regex groups are defined.
(\\d+) leading digits is the int id column
dot . is a separator
(\\S+) - string without spaces is the city_org string column
comma , is a separator
(\\d++.\\d++) - float column
\\t - tab separator
See details here: https://community.hortonworks.com/articles/58591/using-regular-expressions-to-extract-fields-for-hi.html
        leftjoin
        
- 36,950
 - 8
 - 57
 - 116