2016-09-15 5 views
1

ハイブテーブルからsnappy.parquetファイルを作成しようとしています。その大きなパーティションテーブルはちょっとだけ必要です。これを行う:ハイブ結果が寄木細工ファイルとして保存されます

message hive_schema { 
optional int32 _col0; 
optional binary _col1 (UTF8); 
optional binary _col2 (UTF8); 
optional binary _col3 (UTF8); 
optional binary _col4 (UTF8); 
optional binary _col5 (UTF8); 
optional binary _col6 (UTF8); 
optional binary _col7 (UTF8); 
optional int64 _col8; 
optional int64 _col9; 
optional int64 _col10; 
) 

SOURCE_TABLEからすべての列名を失う:それは次のスキーマと000000_0ファイルを作成します

set parquet.compression=SNAPPY; 
set hive.exec.compress.output=true; 
set hive.exec.compress.intermediate=true; 
set hive.exec.parallel=true; 
set mapred.output.compress=true; 
set mapreduce.output.fileoutputformat.compress=true; 
set mapred.compress.map.output=true; 
set mapreduce.map.output.compress=true; 
set mapred.output.compression.type=BLOCK; 
set mapreduce.output.fileoutputformat.compress.type=BLOCK; 
set io.seqfile.compression.type = BLOCK; 
insert overwrite directory 'EXTERNAL_DIRECTORY' STORED AS PARQUET select * from SOURCE_TABLE; 

。私はそれを適切に保存するので、後でハイブテーブルとして使用できますか?

+0

大規模なソースデータセットの1つのパーティションからのみ取得する新しいデータセットを作成しようとしているようですね。もしそうなら、私はちょうど後にある特定のテーブルからすべてのデータを選択している新しい外部ハイブテーブルを作成します。その後、テーブルとディレクトリ/ファイルを利用できるようになります。 – Jared

+0

さて、私は大きなテーブルのカップルパーティションから小さなデータセットを作成しようとしています。私は新しいハイブテーブルを最初に作成してそれを選択しようとします – lacerated

答えて

0

私はあなたの後のソースパーティションからすべてのデータを選択することによって、あなたのデータセット用の新しい外部テーブルを作成します。次に、利用できるテーブルとファイルがあります。今のように外部表でselect文としてcreate tableを実行することはできないため、まず表を作成してからデータをロードする必要があります。

create external table yourNewTable (use your source table DDL...) 
    stored as parquet location '/yourNewLocation'; 

insert into yourNewTable 
    select * from yourSourceTable where yourPartitionedFieldNames = 'desiredPartitionName'; 
+0

'ハイブクエリの実行中にエラーが発生しました:ステートメントのコンパイル中にエラーが発生しました:FAILED:SemanticException [エラー10071]:外部テーブルへの挿入が許可されていません – lacerated

+0

同じエラーでOVERWRITEテーブルを挿入しようとしました。何か間違っているのですか? – lacerated

+0

プロパティセットがhive.insert.into.external.tables = true – Jared

関連する問題