hive案例

ods

create table house_ods_table(

region string,

subway_station string,

type string,

area int,

floor_level string,

total_price int,

unit_price int,

distance string)

row format delimited fields terminated by '\t'

location '/hive';

load data local inpath '/opt/datas/house.txt'

overwrite into table house_ods_table;

dwd

create table house_dwd_table (

subway_station string,

type string,

area double,

floor_level string,

total_floor int,

total_price int,

unit_price int,

distance string

)

partitioned by (region string)

row format delimited

fields terminated by '\t';

set hive.exec.dynamic.partition=true;

set hive.exec.dynamic.partition.mode=nonstrict;

INSERT INTO table house_dwd_table PARTITION(region)

SELECT

subway_station,

type,

area,

substring_index(floor_level,'(',1) as floor_level, substring_index(substring_index(floor_level,'共',-1),'层',1) as total_floor,

total_price,

unit_price,

distance,

region

FROM house_ods_database.house_ods_table;

dws

create table priceavg_dws_table(

priceavg double,

type string,

area double,

floor_leval string,

distance string,

group_type string)

row format delimited fields terminated by'\t';

insert into table priceavg_dws_table

select avg(unit_price) priceavg,type,-1 as area,'-1' as floor_level,'-1' as distance,'1' as group_type

from house_dwd_database.house_dwd_table

where region='CPQ'

group by type;

dws

create table salenum_dws_table(

salenum double,

type string,

area double,

floor_leval string,

distance string,

group_type string)

row format delimited fields terminated by'\t';

相关推荐
我要用代码向我喜欢的女孩表白18 小时前
hdfs获取所有路径大小的脚本
大数据·hadoop·hdfs
ha_lydms21 小时前
使用DataWorks导入 Maxcompute 数据
大数据·数据仓库·dataworks·maxcompute·hologres·odps·数据同步
ZCBUS实时计算2 天前
金融证券实时数仓建设实践:轻量化实时计算平台落地,实现交易数据端到端秒级处理
大数据·数据库·数据仓库·金融·flink·dba·etl
fastjson_2 天前
Hadoop之Yarn
大数据·hadoop·npm
爱看报的猿2 天前
【金仓数据库征文】MySQL至金仓KES异构数据库平滑迁移与性能深度调优实战
数据库·数据仓库·mysql·金仓数据库征文
fastjson_2 天前
Hive的介绍和使用
数据仓库·hive·hadoop
光电的一只菜鸡4 天前
小白从零开始学agent(二)——如何高效编写 Prompt 与 Skill
hadoop·microsoft·prompt
德昂信息dataondemand4 天前
数仓ETL避坑指南:如何攻克时序指标中的数据问题
数据仓库·商务智能
哥本哈士奇4 天前
dbt+SQLServer构建数据仓库(3):dbt_project.yml配置精讲
数据仓库·sqlserver
哥本哈士奇4 天前
dbt+SQLServer构建数据仓库(4):分层建模实战
数据仓库·sqlserver