Hadoop 使用数据验证合并配置单元中的两个表

Hadoop 使用数据验证合并配置单元中的两个表,hadoop,hive,hiveql,Hadoop,Hive,Hiveql,我有两个具有类似列的表。说, 表X具有id、名、姓 表Y有id、电子邮件id、名字 但是,这两个表都不完善,因此我需要从另一个表中的数据(使用一些键(eg中的id))填充这两个表中的空值,并将其推送到另一个表中 如何有效地执行此操作?只需连接表,然后编写一个case语句 示例0: select x.id as id , case when x.first_name is null then y.first_name else x.first_name end as first_name

我有两个具有类似列的表。说,
表X
具有
id、名、姓

表Y
id、电子邮件id、名字

但是,这两个表都不完善,因此我需要从另一个表中的数据(使用一些键(eg中的id))填充这两个表中的空值,并将其推送到另一个表中


如何有效地执行此操作?

只需连接表,然后编写一个
case
语句

示例0

select x.id as id
  , case when x.first_name is null then y.first_name else x.first_name end as first_name
  , x.last_name as last_name
  , y.email_id as email_id
from db.tableX x
join db.tableY y
on y.id = x.id
select x.id as id
  , if(x.first_name is null, y.first_name, x.first_name) as first_name
  , x.last_name as last_name
  , y.email_id as email_id
from db.tableX x
join db.tableY y
on y.id = x.id
或者,您也可以使用
if
语句执行大致相同的操作

示例1

select x.id as id
  , case when x.first_name is null then y.first_name else x.first_name end as first_name
  , x.last_name as last_name
  , y.email_id as email_id
from db.tableX x
join db.tableY y
on y.id = x.id
select x.id as id
  , if(x.first_name is null, y.first_name, x.first_name) as first_name
  , x.last_name as last_name
  , y.email_id as email_id
from db.tableX x
join db.tableY y
on y.id = x.id