Hadoop 配置单元中的外部表-从原始数据集中转义双引号

Hadoop 配置单元中的外部表-从原始数据集中转义双引号,hadoop,hive,Hadoop,Hive,我有一个包含字符串和int值的文件。所有字符串都使用 int_value1, "string_value2", int_value3, "string_value4" 在配置单元中创建外部表时,我需要使用什么参数来获取所有字符串 问候 Pawel你可以使用它,也可以实现你想要的东西。你能试试这个吗?。根据需要将表更改为外部 input.txt 100, "string1", 200, "string2" 300, "string3", 400, "string4" hive>

我有一个包含字符串和int值的文件。所有字符串都使用

int_value1, "string_value2", int_value3, "string_value4"
在配置单元中创建外部表时,我需要使用什么参数来获取所有字符串

问候
Pawel

你可以使用它,也可以实现你想要的东西。

你能试试这个吗?。根据需要将表更改为外部

input.txt
100,  "string1", 200,  "string2"
300,  "string3", 400,  "string4"

hive> CREATE TABLE test_regex(  
    > ivalue1 STRING,  
    > svalue1 STRING,  
    > ivalue2 STRING,  
    > svalue2 STRING)  
    > ROW FORMAT SERDE 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'  
    > WITH SERDEPROPERTIES ("input.regex" = "^([0-9]+),\\s+\"(.*)\",\\s+([0-9]+),\\s+\"(.*)\"$","output.format.string" = "%1$s %2$s %3$s %4$s") 
    > STORED AS TEXTFILE;
OK
Time taken: 1.091 seconds

hive> load data local inpath 'input.txt' overwrite into table test_regex;
OK
Time taken: 0.391 seconds

hive> select *from test_regex;
OK
100 string1 200 string2
300 string3 400 string4
Time taken: 0.212 seconds
hive>