gpt4 book ai didi

hadoop - Hive 从表中选择复杂类型

转载 作者:可可西里 更新时间:2023-11-01 16:42:29 25 4
gpt4 key购买 nike

考虑一个基表 employee 和一个从名为 employee_salary_period 的员工派生的表,其中包含一个复杂的数据类型 map。如何从 employee 选择数据并将其插入到 employee_salary_period 中,其中 salary_period_map 是键值对,即 salary: period

CREATE TABLE employee(
emp_id bigint,
name string,
address string,
salary double,
period string,
position string
)
PARTITIONED BY (
dept_id bigint)
STORED AS PARQUET


CREATE TABLE employee_salary_period(
emp_id
name string,
salary string,
period string,
salary_period_map Map<String,String>,
)
PARTITIONED BY (
dept_id bigint)
STORED AS PARQUET

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

最佳答案

考虑使用hive提供的str_to_map函数。我希望你的 map 中只有一个键(薪水)

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

关于hadoop - Hive 从表中选择复杂类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39513189/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com