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';

相关推荐
德彪稳坐倒骑驴1 天前
Sqoop入门常用命令
数据库·hadoop·sqoop
俊哥大数据1 天前
【项目6】基于Hadoop+Hive+Springboot+vue新闻资讯大数据仓库项目
数据仓库·hive·hadoop
俊哥大数据1 天前
【实战项目4】Hadoop金融信贷大数据离线分析项目
大数据·hadoop·金融
梦想画家2 天前
从选型到落地:Trino赋能智能制造数据驱动实践
数据仓库·trino·分布式查询·联邦查询
奕成则成2 天前
Flink全面入门指南:从基础认知到BI数据仓库实践
大数据·数据仓库·flink
鹿衔`3 天前
Hadoop HDFS 核心机制与设计理念浅析文档
大数据·hadoop·hdfs
`林中水滴`3 天前
数仓系列:一文读懂仓湖一体架构
数据仓库
Justice Young3 天前
Sqoop复习笔记
hadoop·笔记·sqoop
大厂技术总监下海3 天前
从Hadoop MapReduce到Apache Spark:一场由“磁盘”到“内存”的速度与范式革命
大数据·hadoop·spark·开源
zgl_200537793 天前
ZGLanguage 解析SQL数据血缘 之 Python提取SQL表级血缘树信息
大数据·数据库·数据仓库·hive·hadoop·python·sql