Brisi
Brisi

Reputation: 1831

FAILED: SemanticException Column line_id Found in more than One Tables/Subqueries

I got the following error while the running this hive script.

INSERT OVERWRITE TABLE foo_test PARTITION (ds='${DAY}')
SELECT dt1.time, dt1.line_id, dt1.foo_id, dt1.bar_code
FROM test_logs dt1
JOIN
    ( SELECT MIN(time) as foo_time, line_id, foo_id
      FROM test_logs
      WHERE ( ds >= '2015-02-10') AND ds <= '2015-02-16') AND line_id IN ('2609', '2610', '2763')
      GROUP BY line_id, foo_id ) dt2

ON dt1.time = dt2.foo_time
WHERE ( dt1.ds >= '2015-02-10') AND dt1.ds <= '2015-02-16') AND line_id IN ('2609', '2610', '2763')

How to I run this hive script without error?

Upvotes: 0

Views: 5516

Answers (1)

Jeremy Beard
Jeremy Beard

Reputation: 2725

Your WHERE clause references line_id, which is ambiguous because it could either be from dt1 or dt2. You will need to change it to either dt1.line_id or dt2.line_id, depending on which you intended to refer to.

Upvotes: 1

Related Questions