在表格A
中,我的日期从2014-01-01
到2014-12-31
action_date
2014-01-01
2014-01-02
2014-01-03
...
2014-12-31
在表格B
中,我有一些信息,如
id name action_date deletion_date
1 nik 2013-01-01 2014-02-03
2 tom 2014-06-02 2014-06-30
3 lola 2013-12-30 2014-01-01
4 pete 2014-12-29 1970-01-01
如果A
activation_date<=action_date AND (action_date<=deletion_date OR deletion_date='1970-01-01')
表格行
e.g。
action_date id name action_date deletion_date
2014-01-01 1 nik 2013-01-01 2014-02-03
2014-01-01 3 lola 2013-12-30 2014-01-01
2014-01-02 1 nik 2013-01-01 2014-02-03
2014-01-03 1 nik 2013-01-01 2014-02-03
[...]
2014-02-03 1 nik 2013-01-01 2014-02-03
2014-06-02 2 tom 2014-06-02 2014-06-30
2014-06-03 2 tom 2014-06-02 2014-06-30
[...]
2014-06-03 2 tom 2014-06-02 2014-06-30
2014-12-29 4 pete 2014-12-29 1970-01-01
2014-12-30 4 pete 2014-12-29 1970-01-01
2014-12-31 4 pete 2014-12-29 1970-01-01
我尝试在Hive和PostgreSQL中使用下一个查询。
SELECT a.action_date, b.*
FROM b
JOIN a ON action_date>= activation_date
AND (action_date<=deletion_date OR deletion_date='1970-01-01')
在PostgreSQL中,它工作正常,但在Hive中返回
semanticexception [error 10017]: line 16:3 both left and right aliases encountered in join 'action_date'
如何在Hive中解决这个问题?
答案 0 :(得分:0)
根据错误,由于两个表中的列名相同而发生问题。使用别名表和条件,给别名..这将解决问题。