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

相关推荐
mn_kw1 小时前
Hive 统计信息自动收集机制深度解析
数据仓库·hive·hadoop
en-route1 小时前
数据仓库中的维度、指标、度量与属性
大数据·数据仓库
她说彩礼65万1 小时前
WPF 样式
大数据·hadoop·wpf
世界尽头与你2 小时前
Hadoop 未授权访问漏洞
大数据·hadoop·分布式
mn_kw2 小时前
Hive On Spark 统计信息收集深度解析
hive·hadoop·spark
她说彩礼65万2 小时前
WPF Binding Source
大数据·hadoop·wpf
克喵的水银蛇4 小时前
Flutter 本地存储实战:SharedPreferences+Hive+SQLite
hive·flutter·sqlite
心止水j11 小时前
数据采集 案例
数据仓库
早睡早起早日毕业17 小时前
大数据管理与应用系列丛书《大数据平台架构》之吃透HBase:从原理到架构的深度解剖
hadoop·hbase