1
CREATE EXTERNAL TABLE old_events
(day STRING, foo STRING, count STRING, internal_id STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LOCATION '${INPUT}';;

CREATE EXTERNAL TABLE events
(internal_id, foo STRING, count STRING)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LOCATION '${OUTPUT}';;

INSERT OVERWRITE TABLE events
SELECT internal_id, e2.foo, count(e1.foo)
FROM old_events e2
LEFT OUTER JOIN old_events e1
ON e1.foo = e2.foo
WHERE e1.event = 'event1'
AND e2.event = 'event2'
GROUP BY e2.foo;

我收到以下错误,如果 internal_id 是 select 子句的一部分 FAILED: Error in semantic analysis: line 5:8 Expression Not In Group By Key internal_id

为了避免这种情况,我将 internal_id 添加到 GROUP BY 列,它会导致以下错误。失败:语义分析错误:在多个表/子查询中找到列 internal_id

我该如何解决这个问题?

4

1 回答 1

3

Brisi e1, e2 都有 internal_id 列,因此您必须指出您想要的列,例如:

INSERT OVERWRITE TABLE events
SELECT e2.internal_id, e2.foo, count(e1.foo)
FROM old_events e2
LEFT OUTER JOIN old_events e1
ON e1.foo = e2.foo
AND e1.event = 'event1'
WHERE e2.event = 'event2'
GROUP BY e2.internal_id, e2.foo;
于 2013-05-15T08:58:43.617 回答