While creating table using a file in hue-hive interface we have to specify a delimiter. (Tab, Space, Comma etc.) . But my file delimited by one or more spaces. How to specify delimiter to delimit by one or more spaces.
Asked
Active
Viewed 520 times
1
-
Not sure that it is even possible without writing a UDF. – madbitloman Dec 29 '15 at 14:39
1 Answers
0
You can create table use regex as delimiter via this way:
Data, put data to hdfs
1 2 3 4
a b c d
create table:
//grammar for create table
CREATE TABLE test1(
a string,
b string,
c string,
d string
)
ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe' WITH SERDEPROPERTIES
(
"input.regex" ="([^\\s]*)\\s+([^\\s]*)\\s+([^\\s]*)\\s+([^\\s]*)",
"output.format.string" = "%1$s %2$s %3$s %4$s"
)
LOCATION '/test1/';

Guo
- 1,761
- 2
- 22
- 45