我在s3中有多个子目录包含.orc文件。我正在尝试创建一个配置单元元存储,以便使用presto/hive等查询数据。数据的结构很差(没有一致的分隔符、难看的字符等)。这是一个擦洗过的样品:
1488736466 199.199.199.199 0_b.www.sphericalcow.com.f9b1.qk-g6m6z24tdr.v4.url.name.com TXT IN: NXDOMAIN/0/143
1488736466 6.6.5.4 0.3399.186472.4306.6668.638.cb5a.names-things.update.url.name.com TXT IN: NOERROR/3/306 0\009253\009http://az.blargi.ng/%D3%AB%EF%BF%BD%EF%BF%BD/\009 0\009253\009http://casinoroyal.online/\009 0\009253\009http://d2njbfxlilvpsq.cloudfront.net/b_zq_ym_bangvideo/bangvideo0826.apk\009
我能够使用serde regex创建一个指向其中一个子目录的表,并且字段解析正确,但据我所知,一次只能加载一个子文件夹。
如何向现有配置单元元存储添加更多数据?
下面是一个带有regex serde位的hive metastore create语句示例:
DROP TABLE IF EXISTS test;
CREATE EXTERNAL TABLE test (field1 string, field2 string, field3 string, field4 string)
COMMENT 'fill all the tables with the datas.'
ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.RegexSerDe'
WITH SERDEPROPERTIES (
"input.regex" = "([0-9]{10}) ([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}) (\\S*) (.*)",
"output.format.string" = "%1$s %2$s %3$s %4$s"
)
STORED AS ORC
LOCATION 's3://path/to/one/of/10/folders/'
tblproperties ("orc.compress" = "SNAPPY", "skip.header.line.count"="2");
select * from test limit 10;
我意识到可能有一个非常简单的解决方案,但是我尝试了insert into来代替create external table,但是它抱怨输入是可以理解的,我查看了hive和serde文档以获得帮助,但是找不到添加到现有存储的引用。
2条答案
按热度按时间wmomyfyw1#
使用分区的可能解决方案。
qjp7pelc2#
为@角色(op)
似乎不需要regexserde,因为列由空格('')分隔。
注意使用
tblproperties ("serialization.last.column.takes.rest"="true")
```create external table test
(
field1 bigint
,field2 string
,field3 string
,field4 string
)
row format delimited
fields terminated by ' '
tblproperties ("serialization.last.column.takes.rest"="true")
;