Hive 如何向此配置单元命令添加更多表?
此查询用于从两个表(表1和表2)中获取内容,这两个表是来自不同表的不同字段。如果我想从另一个表中获得一个字段,表3以相同的“mid”字段为条件,我是否应该将查询更改为以下形式:Hive 如何向此配置单元命令添加更多表?,hive,Hive,此查询用于从两个表(表1和表2)中获取内容,这两个表是来自不同表的不同字段。如果我想从另一个表中获得一个字段,表3以相同的“mid”字段为条件,我是否应该将查询更改为以下形式: dt1=$1 desfile="data_$dt1" hql=" select DISTINCT b.mid, b.create_time, d.content from (select mid, create_time, to_id, dt from table_1 w
dt1=$1
desfile="data_$dt1"
hql="
select DISTINCT b.mid, b.create_time, d.content from
(select mid, create_time, to_id, dt from table_1 where dt>=$dt1 and to_id='1042015' ) b
join
(select mid, content from table_2 where dt>=$dt1) d
on(b.mid=d.mid)
"
hive -e "$hql"> $desfile
不能同时联接所有三个表,但应先联接b和d,然后再联接a
hql="
select DISTINCT a.off_time, b.mid, b.create_time, d.content from
(select mid, create_time, to_id, dt from table_1 where dt>=$dt1 and to_id='1042015' ) b
join
(select mid, content from table_2 where dt>=$dt1) d
join
(select mid, off_time from table_3 where dt>=dt1) a
on(b.mid=d.mid=a.mid)
"
select DISTINCT a.off_time, b.mid, b.create_time, d.content from
(select mid, create_time, to_id, dt from table_1 where dt>=$dt1 and to_id='1042015') b
join
(select mid, content from table_2 where dt>=$dt1) d
on(b.mid = d.mid)
join
(select mid, off_time from table_3 where dt>=$dt1) a
on(b.mid = a.mid)