本文介绍了HIVE中的外部表格 - 从原始数据集中转义双引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个带有字符串和整型值的文件。所有的字符串都是用括起来的。


I have a file with string and int values. All strings are in enclosed using " "

int_value1, "string_value2", int_value3, "string_value4"

在HIVE中创建 EXTERNAL TABLE 时需要使用哪个参数所有字符串没有?

What parameter do I need to use while creating EXTERNAL TABLE in HIVE to get all string without " ?

问候

Pawel

Regards
Pawel

推荐答案

您可以试试这个吗?。根据您的需要将表格更改为外部。

Can you try this?. change the table to external as per your need.

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> 

这篇关于HIVE中的外部表格 - 从原始数据集中转义双引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 04:43