簡體   English   中英

配置單元沒有分隔符的數據

[英]Hive with data that does not have a delimiter

我在HDFS中有一些沒有定界符的數據。 即,各個數據字段通過它們在行中的位置來標識。

例如,

CountryXTOWNYCRIMEVALUEZ

因此,在此國家/地區的排名為0到7,城鎮為8到12,犯罪統計數字為13到23。

有沒有辦法將這樣組織的數據直接導入Hive? 我想一個可行的方法是設計一個界定數據的map reduce作業,但是我想知道是否有一個Hive命令可用於直接導入數據?

RegexSerDe

create external table mytable 
( 
    country         string
   ,town            string
   ,crime_statistic string 
)
row format serde 'org.apache.hadoop.hive.contrib.serde2.RegexSerDe'
with serdeproperties  
(
    'input.regex' = '^(.{8})(.{5})(.*)$'
)
location '/...location of the data...'
;

select * from mytable
;

+----------+-------+-----------------+
| country  | town  | crime_statistic |
+----------+-------+-----------------+
| CountryX | TOWNY | CRIMEVALUEZ     |
+----------+-------+-----------------+

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM