user720694
user720694

Reputation: 2075

HIVE: apply delimiter until a specified column

I am trying to move data from a file into a hive table. The data in the file looks something like this:-

StringA StringB StringC StringD StringE

where each string is separated by a space. The problem is that i want separate columns for StringA, StringB and StringC and one column for StringD onwards i.e. StringD and String E should be part of the same column. If i use ROW DELIMITED BY FIELDS TERMINATED BY ' ', Hive would produce separate columns for StringD and StringE. (StringD and StringE contain space within themselves whereas other strings do not contain spaces within themselves)

Is there any special syntax in hive to achieve this or do i need to pre-process my data file in some way?

Upvotes: 0

Views: 749

Answers (1)

Pronix
Pronix

Reputation: 967

Use regular expresion https://cwiki.apache.org/confluence/display/Hive/GettingStarted#GettingStarted-ApacheWeblogData you can define when use space as delimiter and when part of data

Upvotes: 1

Related Questions