【问题标题】:Hive table creation using hue interface using space delimiter使用空间分隔符使用 Hue 界面创建 Hive 表
【发布时间】:2015-12-30 13:32:14
【问题描述】:

在使用 hue-hive 界面中的文件创建表时,我们必须指定分隔符。 (制表符、空格、逗号等)。但是我的文件由一个或多个空格分隔。如何指定分隔符以一个或多个空格分隔。

【问题讨论】:

  • 不确定是否可以不编写 UDF。

标签: regex hadoop hiveql hue apache-hive


【解决方案1】:

您可以通过这种方式创建使用正则表达式作为分隔符的表:

数据,把数据放到hdfs

1  2 3   4
a   b  c d

创建表:

//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/';

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-01
    • 2021-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多