如何使用CTE更新表- Hive



我是新的hive,并试图更新一个表(table_A)与基于从另一个表(table_B)检索值的新列。table_B用作分类变量描述的查找表。

例:table_A

field_ySHS

你需要两个连接(INNER或LEFT)与table_B

CREATE TABLE table_C AS 
SELECT a.index,
a.field_x, 
x.variable_category_description AS field_x_description,
a.field_y, 
y.variable_category_description AS field_y_description
FROM table_A
LEFT JOIN table_B x ON x.variable_name  = 'field_x' 
and x.variable_category = a.field_x
LEFT JOIN table_B y ON y.variable_name  = 'field_y' 
and y.variable_category = a.field_y
;

相关内容

  • 没有找到相关文章

最新更新