Hive从表中选择复杂类型

时间:2016-09-15 14:05:23

标签: hadoop hive hiveql

考虑基表NoMethodError: undefined method +' for nil:NilClass ./features/step_definitions/my_steps.rb:45:inblock (2 levels) in ' ./features/step_definitions/my_steps.rb:44:in each' ./features/step_definitions/my_steps.rb:44:in/^selecting source table$/' ./features/PG.feature:12:in `Then selecting source table' 1 scenario (1 failed) 1 step (1 failed) 0m0.072s 和从名为employee的员工派生的表,其中包含复杂的数据类型employee_salary_period。如何选择map中的数据并将其插入employee,其中employee_salary_period是一个键值对,即salary_period_map

salary: period

我一直试图弄清楚如何选择数据作为salary_period_map

1 个答案:

答案 0 :(得分:1)

考虑使用hive提供的str_to_map函数。我希望你在地图上只有一个关键(薪水)

select
emp_id
name, 
salary, 
period,
str_to_map(concat(salary,":",period),'&',':')  as  salary_period_map
from employee_salary_period