如何在Hive中创建事实表并将表中的原始值替换为键(ID)值

时间:2020-05-19 14:05:03

标签: hadoop hive hiveql hue

我想创建的内容在下面解释。在Hive中可以做到吗?

我可以使用Pandas在Python中做到这一点并替换列,但是我想知道Hive中的查询可以做到吗?

我已经在Hive中上载了Source表并在Cloudera HUE中也创建了如下所示的维表,因此可以通过使用维表 id 值并在源表?

我有“源”表:

SOURCE TABLE

我从源表创建维表:

enter image description here enter image description here enter image description here

我想创建事实表:

enter image description here

1 个答案:

答案 0 :(得分:1)

通过源表中的值联接并选择ID:

insert overwrite table fact
select pr.id as property, t.id as type, pl.id as place, s.price
 from source_table s 
      left join property_dim pr on s.property=pr.property
      left join type_dim     t  on s.type=t.type
      left join place_dim    pl on s.place=pl.place
相关问题