1

次のコマンドで、Hive で複数の挿入上書きを実行しようとしています。

INSERT OVERWRITE  table results_3 SELECT NULL, res, NULL, NULL FROM results where field= 'title';

そして、最初のコマンドの後の results_3 テーブルの内容

NULL    Up On Cripple Creek (2000 Digital Remaster) NULL    NULL
NULL    The Weight (2000 Digital Remaster)  NULL    NULL
NULL    Rhythm Of The Rain (LP Version) NULL    NULL
NULL    Who'll Stop the Rain    NULL    NULL
NULL    I Walk the Line NULL    NULL
NULL    Against The Wind    NULL    NULL
NULL    Lyin' Eyes  NULL    NULL
NULL    North To Alaska NULL    NULL
NULL    You Gave Me A Mountain  NULL    NULL
NULL    Night Moves NULL    NULL


INSERT OVERWRITE  table results_3 SELECT NULL, NULL, res, NULL FROM results where field= 'albums';

そして、2 番目のコマンドの後の results_3 テーブルの内容

NULL    NULL    The Band    NULL
NULL    NULL    The Band    NULL
NULL    NULL    The Cascades    NULL
NULL    NULL    Creedence Clearwater Revival    NULL
NULL    NULL    Johnny Cash NULL
NULL    NULL    Bob Seger   NULL
NULL    NULL    The Eagles  NULL
NULL    NULL    Johnny Horton   NULL
NULL    NULL    Marty Robbins   NULL
NULL    NULL    Bob Seger   NULL

しかし、私は2つのことを一緒にマージしたい. どうすればこれに対処できるか分かりますか?

ありがとう

4

2 に答える 2

2

次のように追加できます。

INSERT OVERWRITE TABLE
select col1 ... col2 
from 
(
SELECT col1 ... coln from TABLE  --old data
UNION ALL
SELECT col1 ... col2n from TABLE2 --new data
)
于 2013-08-20T15:03:52.023 に答える
0

Hiveinsertは今のところ追加をサポートしていません。

簡単な方法: insert overwrite2 つのディレクトリ。手動でマージします。または insert into、パーティションが異なるテーブル(ただし、実際にはパーティションが異なるとディレクトリが異なります)。

詳細については、Hive wikiを参照してください。

于 2013-03-21T00:42:56.010 に答える