2017-04-05 7 views
2

IS RCONまたはORCファイル形式のJSON serdeを使用できますか?私は、ファイル形式ORCでHiveテーブルに挿入しようとしていて、シリアル化されたJSONに空白のBLOBを格納しようとしています。で失敗ORCまたはRC形式のHive Json SerDE

create external table mytable (myint int,mystring string) 
row format serde 'org.apache.hive.hcatalog.data.JsonSerDe' 
stored as orc 
location 'file:///home/cloudera/local/mytable' 
; 

ミン用のMyString

答えて

1
明らか

ない

insert overwrite local directory '/home/cloudera/local/mytable' 
stored as orc 
select '{"mycol":123,"mystring","Hello"}' 
; 

create external table verify_data (rec string) 
stored as orc 
location 'file:////home/cloudera/local/mytable' 
; 

select * from verify_data 
; 

REC
{123 "のMyString"、 "こんにちは"、 "mycol"}例外java.io.IOException:java.lang.ClassCastException:
org.apache.hadoop.hive.ql.io.orc.OrcStructがorg.apache.hadoop.io.Text

JsonSerDe.javaにキャストすることはできません。

... 
import org.apache.hadoop.io.Text; 
... 

    @Override 
    public Object deserialize(Writable blob) throws SerDeException { 

    Text t = (Text) blob; 
    ... 
0

あなたが使用して行うことができますバケットを作成した後、ターゲットディレクトリにORCファイルを生成し、同じスキーマを持つハイブテーブルをマウントするバケット化ステップのような、ある種の変換ステップ。以下のように。

CREATE EXTERNAL TABLE my_fact_orc 
(
    mycol STRING, 
    mystring INT 
) 
PARTITIONED BY (dt string) 
CLUSTERED BY (some_id) INTO 64 BUCKETS 
STORED AS ORC 
LOCATION 's3://dev/my_fact_orc' 
TBLPROPERTIES ('orc.compress'='SNAPPY'); 

ALTER TABLE my_fact_orc ADD IF NOT EXISTS PARTITION (dt='2017-09-07') LOCATION 's3://dev/my_fact_orc/dt=2017-09-07'; 

ALTER TABLE my_fact_orc PARTITION (dt='2017-09-07') SET FILEFORMAT ORC; 

SELECT * FROM my_fact_orc WHERE dt='2017-09-07' LIMIT 5;