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';

以及第二条命令后 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

但我想将这两件事合并在一起。你知道我该如何解决这个问题吗?

谢谢

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 overwrite两个目录。手动合并它。或者 insert into不同分区的表(但实际上不同的分区有不同的目录)。

请参阅hive wiki了解更多信息。

于 2013-03-21T00:42:56.010 回答