HIVE创建分区,添加数据

执行语句前:

先配置以下条件

set hive.exec.dynamic.partition=true;
set hive.exec.dynamic.partition.mode=nonstrict;
set spark.executor.instances=6;
set spark.serializer=org.apache.spark.serializer.KryoSerializer;
set hive.exec.max.dynamic.partitions.pernode=99999;
set hive.exec.max.dynamic.partitions=999999;
set hive.exec.max.created.files=999999;
set hive.map.aggr=true;
set hive.groupby.skewindata=true;
set hive.log.explain.output=false;

set hive.map.aggr= false;

 

一、 小区均价表

1.1、创建小区均价表

CREATE TABLE `lj_city_cmnt_price_temp`(
`pk_id` int COMMENT '唯一id',
`lj_prov` string COMMENT '省',
`lj_city` string COMMENT '市_原始',
`lj_area_orig` string COMMENT '行政区县_原始',
`lj_comm_id_orig` string COMMENT '小区ID',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名_原始',
`lj_comm_addr_orig` string COMMENT '小区地址_原始',
`get_method` string COMMENT '获取方式',
`lj_cnmt` string COMMENT '链家小区名',
`lj_cnmt_url` string COMMENT '链家小区RUL',
`lj_cnmt_per_pr` string COMMENT '链家小区挂牌价',
`lj_cmnt_area` string,
`lj_cmnt_loc` string,
`lj_cmnt_crawl_tm` string COMMENT '链家房源爬取时间',
`batch_id` string COMMENT '批次号')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',', 'serialization.format'=',')STORED AS TEXTFILE;

1.2 创建小区均价分区表

CREATE TABLE `ods_lj_cmnt_pr_crawl`(
`pk_id` string COMMENT '唯一id',
`lj_area_orig` string COMMENT '行政区县_原始',
`lj_comm_id_orig` string COMMENT '小区ID',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名_原始',
`lj_comm_addr_orig` string COMMENT '小区地址_原始',
`get_method` string COMMENT '获取方式',
`lj_cnmt` string COMMENT '链家小区名',
`lj_cnmt_url` string COMMENT '链家URL',
`lj_cnmt_per_pr` string COMMENT '链家小区挂牌价',
`lj_cmnt_crawl_tm` timestamp COMMENT '链家房源爬取时间',
`batch_id` string COMMENT '批次号',
`lj_cmnt_area` string COMMENT '链家小区区域',
`lj_cmnt_loc` string COMMENT '链家小区大致位置')
PARTITIONED BY (
`lj_prov` string COMMENT '省',
`lj_city_orig` string COMMENT '市_原始')
row format delimited fields terminated by ","
stored as textfile;

 

1.3 插入数据

insert into ods_data_collection.lj_city_cmnt_price_temp select uuid(),
lj_area_orig ,lj_comm_id_orig ,lj_comm_name_orig ,lj_alias_name_orig ,lj_comm_addr_orig ,
get_method ,lj_cnmt ,lj_cnmt_url ,lj_cnmt_per_pr ,lj_cmnt_crawl_tm ,batch_id ,lj_cmnt_area ,
lj_cmnt_loc ,lj_prov ,lj_city
from test_spider.ods_lj_cmnt_pr_crawl where batch_id='202101101000';

 

二、小区详情表

2.1 创建小区详情表

CREATE TABLE `ods_lj_cmnt_detail_temp`(
`pk_id` int COMMENT '唯一主键',
`lj_province` string COMMENT '省',
`lj_city_orig` string COMMENT '\t市_原始\t',
`lj_area_orig` string COMMENT '\t区_原始\t',
`lj_comm_id_orig` string COMMENT '\t小区ID_原始\t',
`lj_comm_name_orig` string COMMENT '\t小区名_原始\t',
`lj_alias_name_orig` string COMMENT '\t小区别名_原始',
`lj_comm_addr_orig` string COMMENT '\t小区地址_原始',
`get_method` string COMMENT '\t获取方式',
`lj_dist` string COMMENT '\t行政区',
`lj_biz_dist` string COMMENT '\t所属商圈',
`lj_cmnt` string COMMENT '\t小区名',
`lj_cmnt_url` string COMMENT '\t链家小区URL地址\t',
`lj_cmnt_sub_title` string COMMENT '\t链家小区标题(小)',
`lj_cmnt_list_pr` string COMMENT '\t链家小区挂牌单价\t',
`lj_cmnt_bld_year` string COMMENT '\t链家小区建筑年代\t',
`lj_cmnt_bld_stru` string COMMENT '\t链家小区建筑类型',
`lj_cmnt_hoa_fee` string COMMENT '\t链家小区物业费用',
`lj_cmnt_hoa_nm` string COMMENT '\t链家小区物业公司',
`lj_cmnt_dev_nm` string COMMENT '\t链家小区开发商\t',
`lj_cmnt_bld_ttl` string COMMENT '\t链家小区楼栋总数',
`lj_cmnt_hse_ttl` string COMMENT '\t链家小区房屋总数',
`lj_cmnt_crawl_tm` timestamp COMMENT '\t链家房源爬取时间',
`lj_cmnt_loc` string COMMENT '\t链家房源位置',

`LJ_CMNT_SELL` string COMMENT '链家房源在售数量',
`batch_id` string COMMENT '\t批次号')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

2.2 创建小区详情分区表

CREATE TABLE `ods_lj_cmnt_detail_crawl`(
`pk_id` string COMMENT '唯一主键',
`lj_area_orig` string COMMENT '区_原始',
`lj_comm_id_orig` string COMMENT '小区ID_原始',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名_原始',
`lj_comm_addr_orig` string COMMENT '小区地址_原始',
`get_method` string COMMENT '获取方式',
`lj_dist` string COMMENT '行政区',
`lj_biz_dist` string COMMENT '所属商圈',
`lj_cmnt` string COMMENT '小区名',
`lj_cmnt_url` string COMMENT '链家小区URL地址',
`lj_cmnt_sub_title` string COMMENT '链家小区标题(小)',
`lj_cmnt_list_pr` string COMMENT '链家小区挂牌单价',
`lj_cmnt_bld_year` string COMMENT '链家小区建筑年代',
`lj_cmnt_bld_stru` string COMMENT '链家小区建筑类型',
`lj_cmnt_hoa_fee` string COMMENT '链家小区物业费用',
`lj_cmnt_hoa_nm` string COMMENT '链家小区物业公司',
`lj_cmnt_dev_nm` string COMMENT '链家小区开发商',
`lj_cmnt_bld_ttl` string COMMENT '链家小区楼栋总数',
`lj_cmnt_hse_ttl` string COMMENT '链家小区房屋总数',
`lj_cmnt_crawl_tm` timestamp COMMENT '链家房源爬取时间',
`lj_cmnt_loc` string COMMENT '链家房源位置',

`LJ_CMNT_SELL` string COMMENT '链家房源在售数量',
`batch_id` string COMMENT '批次号')
PARTITIONED BY (
`lj_prov` string COMMENT '省',
`lj_city_orig` string COMMENT '市_原始')
row format delimited fields terminated by ","
stored as textfile;

2.3 插入数据

insert into ods_data_collection.ods_lj_cmnt_detail_crawl select uuid(),
lj_area_orig ,lj_comm_id_orig ,lj_comm_name_orig ,lj_alias_name_orig ,lj_comm_addr_orig ,get_method ,lj_dist ,lj_biz_dist ,
lj_cmnt ,lj_cmnt_url ,lj_cmnt_sub_title ,lj_cmnt_list_pr ,lj_cmnt_bld_year ,lj_cmnt_bld_stru ,lj_cmnt_hoa_fee ,lj_cmnt_hoa_nm ,lj_cmnt_dev_nm ,
lj_cmnt_bld_ttl ,lj_cmnt_hse_ttl ,lj_cmnt_crawl_tm ,lj_cmnt_loc ,lj_cmnt_sell ,batch_id ,lj_province ,lj_city_orig
from test_spider.ods_lj_cmnt_detail_temp where batch_id='202101101000';

#创建新楼盘小区详情表

create table ods_lj_new_cmnt
(
PK_ID string comment '唯一主键',
LJ_PROVINCE string comment '省',
LJ_CITY_ORIG string comment '市_原始',
LJ_AREA_ORIG string comment '区_原始',
LJ_COMM_ID_ORIG string comment '小区ID_原始',
LJ_COMM_NAME_ORIG string comment '小区名_原始',
LJ_ALIAS_NAME_ORIG string comment '小区别名_原始',
LJ_COMM_ADDR_ORIG string comment '小区地址_原始',
GET_METHOD string comment '获取方式',
LJ_DIST string comment '行政区',
LJ_BIZ_DIST string comment '所属商圈',
LJ_CMNT string comment '小区名',
LJ_CMNT_URL string comment '小区URL地址',
LJ_CMNT_TYPE string comment '小区类型',
LJ_CMNT_SALE_STU string comment '销售状态',
LJ_CMNT_TAG string comment '小区标签',
LJ_CMNT_ROOM_NUM string comment '小区户型',
LJ_CMNT_ROOM_AREA string comment '小区面积',
LJ_CMNT_LIST_PR string comment '小区挂牌均价',
LJ_CMNT_ROOM_PR string comment '小区房屋总价',
LJ_STA_SPC_TAG string comment '状态特殊标签',
LJ_PRO_LOC string comment '项目地址',
LJ_ROOM_INFO string comment '户型信息',
LJ_CMNT_CRAWL_TM string comment '房源爬取时间',
BATCH_ID string comment '批次号'
row format delimited fields terminated by ","
stored as textfile;

 

# 创建新楼盘小区详情分区表

create table ods_lj_new_cmnt_fq
(
PK_ID string comment '唯一主键',
LJ_CITY_ORIG string comment '市_原始',
LJ_AREA_ORIG string comment '区_原始',
LJ_COMM_ID_ORIG string comment '小区ID_原始',
LJ_COMM_NAME_ORIG string comment '小区名_原始',
LJ_ALIAS_NAME_ORIG string comment '小区别名_原始',
LJ_COMM_ADDR_ORIG string comment '小区地址_原始',
GET_METHOD string comment '获取方式',
LJ_DIST string comment '行政区',
LJ_BIZ_DIST string comment '所属商圈',
LJ_CMNT string comment '小区名',
LJ_CMNT_URL string comment '小区URL地址',
LJ_CMNT_TYPE string comment '小区类型',
LJ_CMNT_SALE_STU string comment '销售状态',
LJ_CMNT_TAG string comment '小区标签',
LJ_CMNT_ROOM_NUM string comment '小区户型',
LJ_CMNT_ROOM_AREA string comment '小区面积',
LJ_CMNT_LIST_PR string comment '小区挂牌均价',
LJ_CMNT_ROOM_PR string comment '小区房屋总价',
LJ_STA_SPC_TAG string comment '状态特殊标签',
LJ_PRO_LOC string comment '项目地址',
LJ_ROOM_INFO string comment '户型信息',
LJ_CMNT_CRAWL_TM string comment '房源爬取时间'
)partitioned by (

BATCH_ID string comment '批次号'

LJ_PROVINCE string comment '省',
LJ_CITY_ORIG string comment '市_原始')
row format delimited fields terminated by ","
stored as textfile;

 # 插入数据

insert into ods_lj_new_cmnt_crl
select uuid(),
LJ_AREA_ORIG,
LJ_COMM_ID_ORIG,
LJ_COMM_NAME_ORIG,
LJ_ALIAS_NAME_ORIG,
LJ_COMM_ADDR_ORIG,
GET_METHOD,
LJ_DIST,
LJ_BIZ_DIST,
LJ_CMNT,
LJ_CMNT_URL,
LJ_CMNT_TYPE,
LJ_CMNT_SALE_STU,
LJ_CMNT_TAG,
LJ_CMNT_ROOM_NUM,
LJ_CMNT_ROOM_AREA,
LJ_CMNT_LIST_PR,
LJ_CMNT_ROOM_PR,
LJ_STA_SPC_TAG,
LJ_PRO_LOC,
LJ_ROOM_INFO,
LJ_CMNT_CRAWL_TM,
BATCH_ID,
LJ_PROVINCE,
LJ_CITY_ORIG from crl_test_db.ods_lj_new_cmnt;

 

三、挂牌均价表

3.1 创建挂牌均价表

CREATE TABLE `ods_lj_hse_list_pr_temp`(
`id` string COMMENT '唯一主键',
`lj_prov` string COMMENT '省',
`lj_city_orig` string COMMENT '市_原始',
`lj_area_orig` string COMMENT '行政区县_原始',
`lj_comm_id_orig` string COMMENT '小区ID',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名_原始',
`lj_comm_addr_orig` string COMMENT '小区地址_原始',
`get_method` string COMMENT '获取方式',
`lj_title` string COMMENT '链家房源标题',
`lj_hse_url` string COMMENT '链家房源URL地址',
`lj_hse_list_pr` string COMMENT '链家房源挂牌价',
`lj_hse_sq_list_pr` string COMMENT '链家房源挂牌单价',
`lj_hse_type` string COMMENT '链家房源户型',
`lj_hse_area` string COMMENT '链家房源面积',
`lj_hse_twd` string COMMENT '链家房源朝向',
`lj_hse_deg_dect` string COMMENT '链家房源装修程度',
`lj_hse_flr_type` string COMMENT '链家房源楼层',
`lj_hse_ttl_flr` string COMMENT '链家房源总楼层',
`lj_hse_bld_year` string COMMENT '链家房源建成年份',
`lj_hse_bld_stru` string COMMENT '链家房源建筑结构',
`lj_hse_crawl_tm` timestamp COMMENT '链家房源爬取时间',
`lj_hse_loc` string COMMENT '链家房源位置',
`batch_id` string COMMENT '批次号')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

 

3.3 创建挂牌均价分区表

CREATE TABLE `ods_lj_hse_list_pr_crawl`(
`pk_id` string COMMENT '唯一主键',
`lj_area_orig` string COMMENT '行政区县_原始',
`lj_comm_id_orig` string COMMENT '小区ID',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名_原始',
`lj_comm_addr_orig` string COMMENT '小区地址_原始',
`get_method` string COMMENT '获取方式',
`lj_title` string COMMENT '链家房源标题',
`lj_hse_url` string COMMENT '链家房源URL地址',
`lj_hse_list_pr` string COMMENT '链家房源挂牌价',
`lj_hse_sq_list_pr` string COMMENT '链家房源挂牌单价',
`lj_hse_type` string COMMENT '链家房源户型',
`lj_hse_area` string COMMENT '链家房源面积',
`lj_hse_twd` string COMMENT '链家房源朝向',
`lj_hse_deg_dect` string COMMENT '链家房源装修程度',
`lj_hse_flr_type` string COMMENT '链家房源楼层',
`lj_hse_ttl_flr` string COMMENT '链家房源总楼层',
`lj_hse_bld_year` string COMMENT '链家房源建成年份',
`lj_hse_bld_stru` string COMMENT '链家房源建筑结构',
`lj_hse_crawl_tm` timestamp COMMENT '链家房源爬取时间',
`lj_hse_loc` string COMMENT '链家房源位置',
`batch_id` string COMMENT '批次号')
PARTITIONED BY (
`lj_prov` string COMMENT '省',
`lj_city_orig` string COMMENT '市_原始')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

3.3 插入数据

insert into ods_lj_hse_list_pr_crawl_temp

select uuid(),LJ_AREA_ORIG,LJ_COMM_ID_ORIG,LJ_COMM_NAME_ORIG,LJ_ALIAS_NAME_ORIG,LJ_COMM_ADDR_ORIG,GET_METHOD,
LJ_TITLE,LJ_HSE_URL,LJ_HSE_LIST_PR,LJ_HSE_SQ_LIST_PR,LJ_HSE_TYPE,LJ_HSE_AREA,LJ_HSE_TWD,LJ_HSE_DEG_DECT,
LJ_HSE_FLR_TYPE,LJ_HSE_TTL_FLR,LJ_HSE_BLD_YEAR,LJ_HSE_BLD_STRU,LJ_HSE_CRAWL_TM,LJ_HSE_LOC,BATCH_ID,
LJ_PROV,LJ_CITY_ORIG
from ods_lj_hse_list_pr_crawl;

 

四、挂牌详情表

4.1 创建挂牌详情表

CREATE TABLE `ods_lj_hse_detail_temp`(
`pk_id` int COMMENT '唯一主键',
`lj_province` string COMMENT '省',
`lj_city_orig` string COMMENT '市',
`lj_area_orig` string COMMENT '区',
`lj_comm_id_orig` string COMMENT '小区ID',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名',
`lj_comm_addr_orig` string COMMENT '小区地址',
`lj_dist` string COMMENT '行政区',
`lj_biz_dist` string COMMENT '所属商圈',
`lj_cmnt` string COMMENT '小区名',
`lj_title` string COMMENT '链家房源标题(大)',
`lj_hse_url` string COMMENT '链家房源URL地址',
`lj_hse_sub_title` string COMMENT '链家房源标题(小)',
`lj_hse_list_pr` string COMMENT '链家房源挂牌价',
`lj_hse_sq_list_pr` string COMMENT '链家房源挂牌单价',
`lj_hse_area` string COMMENT '链家房源面积',
`lj_hse_bld_year` string COMMENT '链家房源建成年份',
`lj_cmnt_nm` string COMMENT '小区名称',
`lj_cmnt_dtl_url` string COMMENT '小区详情链接',
`lj_cmnt_loc_area` string COMMENT '所在区域_区',
`lj_cmnt_loc_add` string COMMENT '所在区域_地点',
`lj_hse_type` string COMMENT '基本信息-基本属性-房屋户型',
`lj_hse_blg_are` string COMMENT '基本信息-基本属性-建筑面积',
`lj_hse_ubl_are` string COMMENT '基本信息-基本属性-套内面积',
`lj_hse_twd` string COMMENT '基本信息-基本属性-房屋朝向',
`lj_hse_deg_dect` string COMMENT '基本信息-基本属性-装修情况',
`lj_hse_is_elvt` string COMMENT '基本信息-基本属性-配备电梯',
`lj_hse_flr` string COMMENT '基本信息-基本属性-所在楼层',
`lj_hse_ttl_flr` string COMMENT '基本信息-基本属性-总楼层',
`lj_hse_ttl_type` string COMMENT '基本信息-基本属性-户型结构',
`lj_hse_bld_type` string COMMENT '基本信息-基本属性-建筑类型',
`lj_hse_bld_stru` string COMMENT '基本信息-基本属性-建筑结构',
`lj_elvt_hse_rto` string COMMENT '基本信息-基本属性-梯户比例',
`lj_list_pr_tm` string COMMENT '基本信息-交易属性-挂牌时间',
`lj_last_trans_tm` string COMMENT '基本信息-交易属性-上次交易',
`lj_hse_year_per` string COMMENT '基本信息-交易属性-房屋年限',
`lj_hse_mrge` string COMMENT '基本信息-交易属性-抵押信息',
`lj_hse_trans_osp` string COMMENT '基本信息-交易属性-交易属性',
`lj_hse_purp` string COMMENT '基本信息-交易属性-房屋用途',
`lj_hse_prop_blg` string COMMENT '基本信息-交易属性-产权所属',
`lj_hse_feat_tag` string COMMENT '房源特色-房源标签',
`lj_core_sell_pt` string COMMENT '房源特色-核心卖点',
`lj_cmnt_info` string COMMENT '房源特色-小区介绍',
`lj_cmnt_surd_fac` string COMMENT '房源特色-周边配套',
`lj_hse_crawl_tm` timestamp COMMENT '链家房源爬取时间',
`lj_hse_loc` string COMMENT '链家房源位置',
`batch_id` string COMMENT '批次号')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

4.2 创建挂牌详情分区表

CREATE TABLE `ods_lj_hse_detail_crawl`(
`pk_id` string COMMENT '唯一主键 ',
`lj_area_orig` string COMMENT '区',
`lj_comm_id_orig` string COMMENT '小区ID',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名',
`lj_comm_addr_orig` string COMMENT '小区地址',
`lj_dist` string COMMENT '行政区',
`lj_biz_dist` string COMMENT '所属商圈',
`lj_cmnt` string COMMENT '小区名',
`lj_title` string COMMENT '链家房源标题(大)',
`lj_hse_url` string COMMENT '链家房源URL地址',
`lj_hse_sub_title` string COMMENT '链家房源标题(小)',
`lj_hse_list_pr` string COMMENT '链家房源挂牌价',
`lj_hse_sq_list_pr` string COMMENT '链家房源挂牌单价',
`lj_hse_area` string COMMENT '链家房源面积',
`lj_hse_bld_year` string COMMENT '链家房源建成年份',
`lj_cmnt_nm` string COMMENT '小区名称',
`lj_cmnt_dtl_url` string COMMENT '小区详情链接',
`lj_cmnt_loc_area` string COMMENT '所在区域_区',
`lj_cmnt_loc_add` string COMMENT '所在区域_地点',
`lj_hse_type` string COMMENT '基本信息-基本属性-房屋户型',
`lj_hse_blg_are` string COMMENT '基本信息-基本属性-建筑面积',
`lj_hse_ubl_are` string COMMENT '基本信息-基本属性-套内面积',
`lj_hse_twd` string COMMENT '基本信息-基本属性-房屋朝向',
`lj_hse_deg_dect` string COMMENT '基本信息-基本属性-装修情况',
`lj_hse_is_elvt` string COMMENT '基本信息-基本属性-配备电梯',
`lj_hse_flr` string COMMENT '基本信息-基本属性-所在楼层',
`lj_hse_ttl_flr` string COMMENT '基本信息-基本属性-总楼层',
`lj_hse_ttl_type` string COMMENT '基本信息-基本属性-户型结构',
`lj_hse_bld_type` string COMMENT '基本信息-基本属性-建筑类型',
`lj_hse_bld_stru` string COMMENT '基本信息-基本属性-建筑结构',
`lj_elvt_hse_rto` string COMMENT '基本信息-基本属性-梯户比例',
`lj_list_pr_tm` string COMMENT '基本信息-交易属性-挂牌时间',
`lj_last_trans_tm` string COMMENT '基本信息-交易属性-上次交易',
`lj_hse_year_per` string COMMENT '基本信息-交易属性-房屋年限',
`lj_hse_mrge` string COMMENT '基本信息-交易属性-抵押信息',
`lj_hse_trans_osp` string COMMENT '基本信息-交易属性-交易属性',
`lj_hse_purp` string COMMENT '基本信息-交易属性-房屋用途',
`lj_hse_prop_blg` string COMMENT '基本信息-交易属性-产权所属',
`lj_hse_feat_tag` string COMMENT '房源特色-房源标签',
`lj_core_sell_pt` string COMMENT '房源特色-核心卖点',
`lj_cmnt_info` string COMMENT '房源特色-小区介绍',
`lj_cmnt_surd_fac` string COMMENT '房源特色-周边配套',
`lj_hse_crawl_tm` timestamp COMMENT '链家房源爬取时间',
`lj_hse_loc` string COMMENT '链家房源位置',
`batch_id` string COMMENT '批次号')
PARTITIONED BY (
`lj_province` string COMMENT '省',
`lj_city_orig` string COMMENT '市')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

4.3 插入数据

insert into ods_lj_hse_detail_crawl_temp select uuid(),LJ_AREA_ORIG,LJ_COMM_ID_ORIG,LJ_COMM_NAME_ORIG,LJ_ALIAS_NAME_ORIG,LJ_COMM_ADDR_ORIG,LJ_DIST,LJ_BIZ_DIST,LJ_CMNT,
LJ_TITLE,LJ_HSE_URL,LJ_HSE_SUB_TITLE,LJ_HSE_LIST_PR,LJ_HSE_SQ_LIST_PR,LJ_HSE_AREA,LJ_HSE_BLD_YEAR,LJ_CMNT_NM,LJ_CMNT_DTL_URL,
LJ_CMNT_LOC_AREA,LJ_CMNT_LOC_ADD,LJ_HSE_TYPE,LJ_HSE_BLG_ARE,LJ_HSE_UBL_ARE,LJ_HSE_TWD,LJ_HSE_DEG_DECT,LJ_HSE_IS_ELVT,LJ_HSE_FLR,
LJ_HSE_TTL_FLR,LJ_HSE_TTL_TYPE,LJ_HSE_BLD_TYPE,LJ_HSE_BLD_STRU,LJ_ELVT_HSE_RTO,LJ_LIST_PR_TM,LJ_LAST_TRANS_TM,LJ_HSE_YEAR_PER,
LJ_HSE_MRGE,LJ_HSE_TRANS_OSP,LJ_HSE_PURP,LJ_HSE_PROP_BLG,LJ_HSE_FEAT_TAG,LJ_CORE_SELL_PT,LJ_CMNT_INFO,LJ_CMNT_SURD_FAC,LJ_HSE_CRAWL_TM,
LJ_HSE_LOC,BATCH_ID,LJ_PROVINCE,LJ_CITY_ORIG
from ods_lj_hse_detail_crawl;

五、成交价表

5.1 创建成交表

CREATE TABLE `ods_lj_hse_tran_pr_temp`(
`pk_id` string COMMENT '唯一主键',
`lj_prov` string COMMENT '省',
`lj_city_orig` string COMMENT '市_原始',
`lj_area_orig` string COMMENT '行政区县_原始',
`lj_comm_id_orig` string COMMENT '小区ID',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名_原始',
`lj_comm_addr_orig` string COMMENT '小区地址_原始',
`get_method` string COMMENT '获取方式',
`lj_title` string COMMENT '链家房源标题',
`lj_hse_url` string COMMENT '链家房源URL地址',
`lj_hse_list_pr` int COMMENT '链家房源挂牌价',
`lj_hse_sq_list_pr` float COMMENT '链家房源挂牌单价',
`lj_hse_type` string COMMENT '链家房源户型',
`lj_hse_area` float COMMENT '链家房源面积',
`lj_hse_twd` string COMMENT '链家房源朝向',
`lj_hse_deg_dect` string COMMENT '链家房源装修程度',
`lj_hse_flr_type` string COMMENT '链家房源楼层',
`lj_hse_ttl_flr` int COMMENT '链家房源总楼层',
`lj_hse_bld_year` int COMMENT '链家房源建成年份',
`lj_hse_bld_stru` string COMMENT '链家房源建筑结构',
`lj_hse_trans_cycle` string COMMENT '链家房源成交周期',
`lj_hse_trans_pr` float COMMENT '链家房源成交价',
`lj_per_sq_trans_pr` float COMMENT '链家房源成交均价',
`lj_hse_trans_date` timestamp COMMENT '链家房源成交日期',
`lj_hse_crawl_tm` timestamp COMMENT '链家房源爬取时间',
`batch_id` string COMMENT '批次号')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

5.2 创建成交分区表

CREATE TABLE `ods_lj_hse_tran_pr_crawl`(
`pk_id` string COMMENT '唯一主键',
`lj_area_orig` string COMMENT '行政区县_原始',
`lj_comm_id_orig` string COMMENT '小区ID',
`lj_comm_name_orig` string COMMENT '小区名_原始',
`lj_alias_name_orig` string COMMENT '小区别名_原始',
`lj_comm_addr_orig` string COMMENT '小区地址_原始',
`get_method` string COMMENT '获取方式',
`lj_title` string COMMENT '链家房源标题',
`lj_hse_url` string COMMENT '链家房源URL地址',
`lj_hse_list_pr` int COMMENT '链家房源挂牌价',
`lj_hse_sq_list_pr` float COMMENT '链家房源挂牌单价',
`lj_hse_type` string COMMENT '链家房源户型',
`lj_hse_area` float COMMENT '链家房源面积',
`lj_hse_twd` string COMMENT '链家房源朝向',
`lj_hse_deg_dect` string COMMENT '链家房源装修程度',
`lj_hse_flr_type` string COMMENT '链家房源楼层',
`lj_hse_ttl_flr` int COMMENT '链家房源总楼层',
`lj_hse_bld_year` int COMMENT '链家房源建成年份',
`lj_hse_bld_stru` string COMMENT '链家房源建筑结构',
`lj_hse_trans_cycle` string COMMENT '链家房源成交周期',
`lj_hse_trans_pr` float COMMENT '链家房源成交价',
`lj_per_sq_trans_pr` float COMMENT '链家房源成交均价',
`lj_hse_trans_date` timestamp COMMENT '链家房源成交日期',
`lj_hse_crawl_tm` timestamp COMMENT '链家房源爬取时间',
`batch_id` string COMMENT '批次号')
PARTITIONED BY (
`lj_prov` string COMMENT '省',
`lj_city_orig` string COMMENT '市_原始')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

5.3 插入数据

insert into ods_lj_hse_tran_pr_crawl select uuid(), lj_area_orig, lj_comm_id_orig, lj_comm_name_orig,
lj_alias_name_orig,
lj_comm_addr_orig, get_method, lj_title, lj_hse_url, lj_hse_list_pr, lj_hse_sq_list_pr, lj_hse_type, lj_hse_area, lj_hse_twd,
lj_hse_deg_dect, lj_hse_flr_type, lj_hse_ttl_flr, lj_hse_bld_year, lj_hse_bld_stru,lj_hse_trans_cycle ,lj_hse_trans_pr ,lj_per_sq_trans_pr,
lj_hse_trans_date, lj_hse_crawl_tm,batch_id,lj_prov,lj_city_orig
from ods_lj_hse_tran_pr_temp;

六、 商品房指数

6.1 创建指数表

CREATE TABLE `nation_house_data_temp`(
`pk_id` string COMMENT '\t唯一ID',
`prov_id` int COMMENT '\t省ID',
`prov_name` string COMMENT '\t省',
`city_id` int COMMENT '\t城市ID',
`city_name` string COMMENT '\t城市',
`fixture_date` string COMMENT '\t成交日期',
`pi_year` string COMMENT '\t指数年份 ',
`pi_mon` int COMMENT '\t指数月份 ',
`value_index` float COMMENT '\t价格指数 ',
`pi_type` string COMMENT '\t指数类型 ',
`source_data` string COMMENT '\t数据来源 ',
`use_code` string COMMENT '\t用途 ',
`standard_year` int COMMENT '\t基准年份 ',
`create_time` timestamp COMMENT '\t创建时间 ',
`update_time` timestamp COMMENT '\t更新时间 ',
`creator` string COMMENT '\t创建人 ',
`modifier` string COMMENT '\t更新人 ',
`batch_id` string COMMENT '\t批次号 ')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

6.2 创建指数分区表

CREATE TABLE `ods_nation_house_data`(
`pk_id` string COMMENT '唯一ID',
`prov_id` int COMMENT '省ID',
`city_id` int COMMENT '城市ID',
`fixture_date` string COMMENT '成交日期',
`pi_year` int COMMENT '指数年份 ',
`pi_mon` int COMMENT '指数月份 ',
`value_index` float COMMENT '价格指数 ',
`pi_type` string COMMENT '指数类型 ',
`source_data` string COMMENT '数据来源 ',
`use_code` string COMMENT '用途 ',
`standard_year` int COMMENT '基准年份 ',
`create_time` timestamp COMMENT '创建时间 ',
`update_time` timestamp COMMENT '更新时间 ',
`creator` string COMMENT '创建人 ',
`modifier` string COMMENT '更新人 ',
`batch_id` string COMMENT '批次号 ')
PARTITIONED BY (
`prov_name` string COMMENT '省',
`city_name` string COMMENT '城市')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

 

 

6.3 插入数据

pass

 

7.1 城市房产网小区详情表

create table ods_ch_cmnt_detail_temp (
PK_ID string comment '',
CH_PROVINCE string comment '',
CH_CITY_ORIG string comment '',
CH_AREA_ORIG string comment '',
CH_CMNT_ID_ORIG string comment '',
CH_CMNT_NAME_ORIG string comment '',
CH_ALIAS_NAME_ORIG string comment '',
CH_CMNT_ADDR_ORIG string comment '',
GET_METHOD string comment '',
CH_DIST string comment '',
CH_BIZ_DIST string comment '',
CH_CMNT string comment '',
CH_CMNT_URL string comment '',
CH_CMNT_SCORE string comment '',
CH_ENV_SCORE string comment '',
CH_CITY_SCORE string comment '',
CH_MAN_SCORE string comment '',
CH_BLD_SCORE string comment '',
CH_CMNT_BLD_YEAR string comment '',
CH_CMNT_PER_PR string comment '',
CH_CMNT_RENT string comment '',
CH_CMNT_BLD_STRU string comment '',
CH_CMNT_BLD_TYPE string comment '',
CH_HSE_STRU string comment '',
CH_CMNT_HOA_FEE string comment '',
CH_CMNT_HOA_NM string comment '',
CH_CMNT_DEV_NM string comment '',
CH_CMNT_HSE_TTL string comment '',
CH_CMNT_USE string comment '',
CH_CMNT_HOA_ADDR string comment '',
CH_GRN_RTO string comment '',
CH_VOL_RTO string comment '',
CH_CMNT_AREA string comment '',
CH_BLD_AREA string comment '',
CH_COM_DATE string comment '',
IS_AVL string comment '',
CRT_TM string comment '',
CRT_PSN string comment '',
UPT_TM string comment '',
PRICE_LIST string comment '',
RENT_LIST string comment '',
UPT_PSN string comment '',
CH_CMNT_CRAWL_TM string comment '',
BATCH_ID string comment '') ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',', 'serialization.format'=',')STORED AS TEXTFILE;

 

7.2 城市房产网小区详情分区表

create table ods_ch_cmnt_detail (
PK_ID string comment '唯一主键',
CH_AREA_ORIG string comment '区_原始',
CH_CMNT_ID_ORIG string comment '小区ID_原始',
CH_CMNT_NAME_ORIG string comment '小区名_原始',
CH_ALIAS_NAME_ORIG string comment '小区别名_原始',
CH_CMNT_ADDR_ORIG string comment '小区地址_原始',
GET_METHOD string comment '获取方式',
CH_DIST string comment '行政区',
CH_BIZ_DIST string comment '所属商圈',
CH_CMNT string comment '小区名',
CH_CMNT_URL string comment '小区URL地址',
CH_CMNT_SCORE string comment '小区评分',
CH_ENV_SCORE string comment '景观环境',
CH_CITY_SCORE string comment '城市配套',
CH_MAN_SCORE string comment '运营管理',
CH_BLD_SCORE string comment '规划建设',
CH_CMNT_BLD_YEAR string comment '链家小区建筑年代',
CH_CMNT_PER_PR string comment '平均房价',
CH_CMNT_RENT string comment '平均租金',
CH_CMNT_BLD_STRU string comment '建筑结构',
CH_CMNT_BLD_TYPE string comment '建筑类型',
CH_HSE_STRU string comment '房屋类型',
CH_CMNT_HOA_FEE string comment '物业费用',
CH_CMNT_HOA_NM string comment '物业公司',
CH_CMNT_DEV_NM string comment '开发商',
CH_CMNT_HSE_TTL string comment '房屋总数',
CH_CMNT_USE string comment '用途',
CH_CMNT_HOA_ADDR string comment '物业地址',
CH_GRN_RTO string comment '绿化率',
CH_VOL_RTO string comment '容积率',
CH_CMNT_AREA string comment '占地面积',
CH_BLD_AREA string comment '建筑面积',
CH_COM_DATE string comment '竣工时间',
IS_AVL string comment '是否有效',
CRT_TM string comment '创建时间',
CRT_PSN string comment '创建人',
UPT_TM string comment '更新时间',
PRICE_LIST string comment '二手房价格走势信息',
RENT_LIST string comment '租金价格走势信息',
UPT_PSN string comment '更新人',
CH_CMNT_CRAWL_TM string comment '爬取时间',
BATCH_ID string comment '批次号')
PARTITIONED BY (
`CH_PROVINCE` string COMMENT '省',
`CH_CITY_ORIG` string COMMENT '市_原始')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

7.3 插入数据

 

8.1 贝壳房价走势表

create table bk_cmnt_pr(
PK_ID string comment '唯一ID',
BK_PROV string comment '省',
BK_CITY string comment '市',
BK_AREA string comment '区',
BK_CMNT_NM string comment '小区名',
BK_TM string comment '贝壳日期',
BK_PR string comment '贝壳价格',
PR_CAT string comment '价格类型',
LJ_CMNT_URL string comment '链家URL',
BK_CMNT_URL string comment '贝壳URL',
LJ_CMNT_ID string comment '链家小区ID',
UPT_TM timestamp comment '更新时间',
CRT_TM timestamp comment '创建时间',
UPT_PSN string comment '更新人',
CRT_PSN string comment '创建人',
BATCH_ID string comment '批次号'
)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',', 'serialization.format'=',')STORED AS TEXTFILE;

8.2 贝壳房价走势分区表

pass

8.3 插入分区表数据

insert into ods_bk_cmnt_pr
select uuid(),
BK_AREA,
BK_CMNT_NM,
BK_TM,
BK_PR,
PR_CAT,
LJ_CMNT_URL,
BK_CMNT_URL,
LJ_CMNT_ID,
UPT_TM,
CRT_TM,
UPT_PSN,
CRT_PSN,
BATCH_ID,
BK_PROV,
BK_CITY
from
bk_cmnt_pr;

 

9.1 创建城市市场指导价分区表:

CREATE TABLE `ODS_EST_CITY_MKT_PR`(
`pk_id` string COMMENT '唯一id',
`est_dist` string COMMENT '行政区县始',
`est_rd` string COMMENT '街道',
`est_cmnt_nm` string COMMENT '小区名',
`cmnt_pr` string COMMENT '指导价',
`batch_id` string COMMENT '批次号',
`IS_AVL` string COMMENT '是否有效',
`CRT_TM` timestamp COMMENT '创建时间',
`CRT_PSN` string COMMENT '创建人',
`UPT_TM` timestamp COMMENT '更新时间',
`UPT_PSN` string COMMENT '更新人')
PARTITIONED BY (
`est_prov` string COMMENT '省',
`est_city` string COMMENT '市_原始')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

#创建城市房产网小区详情表

CREATE TABLE `ch_cmnt_detail`(
`PK_ID` string comment '唯一主键',
`CH_PROVINCE` string comment '省',
`CH_CITY_ORIG` string comment '市_原始',
`CH_AREA_ORIG` string comment '区_原始',
`CH_CMNT_ID_ORIG` string comment '小区ID_原始',
`CH_CMNT_NAME_ORIG` string comment '小区名_原始',
`CH_ALIAS_NAME_ORIG` string comment '小区别名_原始',
`CH_CMNT_ADDR_ORIG` string comment '小区地址_原始',
`GET_METHOD` string comment '获取方式',
`CH_DIST` string comment '行政区',
`CH_BIZ_DIST` string comment '所属商圈',
`CH_CMNT` string comment '小区名',
`CH_CMNT_URL` string comment '小区URL地址',
`CH_CMNT_SCORE` string comment '小区评分',
`CH_ENV_SCORE` string comment '景观环境',
`CH_CITY_SCORE` string comment '城市配套',
`CH_MAN_SCORE` string comment '运营管理',
`CH_BLD_SCORE` string comment '规划建设',
`CH_CMNT_BLD_YEAR` string comment '链家小区建筑年代',
`CH_CMNT_PER_PR` string comment '平均房价',
`CH_CMNT_RENT` string comment '平均租金',
`CH_CMNT_BLD_STRU` string comment '建筑结构',
`CH_CMNT_BLD_TYPE` string comment '建筑类型',
`CH_CMNT_TYPE` string comment '分类',
`CH_HSE_STRU` string comment '房屋类型',
`CH_CMNT_HOA_FEE` string comment '物业费用',
`CH_CMNT_HOA_NM` string comment '物业公司',
`CH_CMNT_DEV_NM` string comment '开发商',
`CH_CMNT_HSE_TTL` string comment '房屋总数',
`CH_CMNT_USE` string comment '用途',
`CH_CMNT_HOA_ADDR` string comment '物业地址',
`CH_GRN_RTO` string comment '绿化率',
`CH_VOL_RTO` string comment '容积率',
`CH_CMNT_AREA` string comment '占地面积',
`CH_BLD_AREA` string comment '建筑面积',
`CH_COM_DATE` string comment '竣工时间',
`CH_CMNT_LOC` string comment '位置',
`CH_OPEN_DATE` string comment '开盘时间',
`IS_AVL` string comment '是否有效',
`CRT_TM` string comment '创建时间',
`CRT_PSN` string comment '创建人',
`UPT_TM` string comment '更新时间',
`PRICE_LIST` string comment '二手房价格走势信息',
`RENT_LIST` string comment '租金价格走势信息',
`UPT_PSN` string comment '更新人',
`CH_CMNT_CRAWL_TM` timestamp comment '爬取时间',
`BATCH_ID` string comment '批次号',
`CH_CMNT_INFO` string comment '小区简介'
)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

 

# 创建城市房产网小区详情分区表

CREATE TABLE `ch_cmnt_detail_fq`(
`PK_ID` string comment '唯一主键',
`CH_AREA_ORIG` string comment '区_原始',
`CH_CMNT_ID_ORIG` string comment '小区ID_原始',
`CH_CMNT_NAME_ORIG` string comment '小区名_原始',
`CH_ALIAS_NAME_ORIG` string comment '小区别名_原始',
`CH_CMNT_ADDR_ORIG` string comment '小区地址_原始',
`GET_METHOD` string comment '获取方式',
`CH_DIST` string comment '行政区',
`CH_BIZ_DIST` string comment '所属商圈',
`CH_CMNT` string comment '小区名',
`CH_CMNT_URL` string comment '小区URL地址',
`CH_CMNT_SCORE` string comment '小区评分',
`CH_ENV_SCORE` string comment '景观环境',
`CH_CITY_SCORE` string comment '城市配套',
`CH_MAN_SCORE` string comment '运营管理',
`CH_BLD_SCORE` string comment '规划建设',
`CH_CMNT_BLD_YEAR` string comment '链家小区建筑年代',
`CH_CMNT_PER_PR` string comment '平均房价',
`CH_CMNT_RENT` string comment '平均租金',
`CH_CMNT_BLD_STRU` string comment '建筑结构',
`CH_CMNT_BLD_TYPE` string comment '建筑类型',
`CH_CMNT_TYPE` string comment '分类',
`CH_HSE_STRU` string comment '房屋类型',
`CH_CMNT_HOA_FEE` string comment '物业费用',
`CH_CMNT_HOA_NM` string comment '物业公司',
`CH_CMNT_DEV_NM` string comment '开发商',
`CH_CMNT_HSE_TTL` string comment '房屋总数',
`CH_CMNT_USE` string comment '用途',
`CH_CMNT_HOA_ADDR` string comment '物业地址',
`CH_GRN_RTO` string comment '绿化率',
`CH_VOL_RTO` string comment '容积率',
`CH_CMNT_AREA` string comment '占地面积',
`CH_BLD_AREA` string comment '建筑面积',
`CH_COM_DATE` string comment '竣工时间',
`CH_CMNT_LOC` string comment '位置',
`CH_OPEN_DATE` string comment '开盘时间',
`IS_AVL` string comment '是否有效',
`CRT_TM` string comment '创建时间',
`CRT_PSN` string comment '创建人',
`UPT_TM` string comment '更新时间',
`PRICE_LIST` string comment '二手房价格走势信息',
`RENT_LIST` string comment '租金价格走势信息',
`UPT_PSN` string comment '更新人',
`CH_CMNT_CRAWL_TM` timestamp comment '爬取时间',
`BATCH_ID` string comment '批次号',
`CH_CMNT_INFO` string comment '小区简介'
)
PARTITIONED BY (
`CH_PROVINCE` string COMMENT '省',
`CH_CITY_ORIG` string COMMENT '市_原始')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

 

# 插入分区表
insert into ch_cmnt_detail_fq select uuid(),
CH_AREA_ORIG,
CH_CMNT_ID_ORIG,
CH_CMNT_NAME_ORIG,
CH_ALIAS_NAME_ORIG,
CH_CMNT_ADDR_ORIG,
GET_METHOD,
CH_DIST,
CH_BIZ_DIST,
CH_CMNT,
CH_CMNT_URL,
CH_CMNT_SCORE,
CH_ENV_SCORE,
CH_CITY_SCORE,
CH_MAN_SCORE,
CH_BLD_SCORE,
CH_CMNT_BLD_YEAR,
CH_CMNT_PER_PR,
CH_CMNT_RENT,
CH_CMNT_BLD_STRU,
CH_CMNT_BLD_TYPE,
CH_CMNT_TYPE,
CH_HSE_STRU,
CH_CMNT_HOA_FEE,
CH_CMNT_HOA_NM,
CH_CMNT_DEV_NM,
CH_CMNT_HSE_TTL,
CH_CMNT_USE,
CH_CMNT_HOA_ADDR,
CH_GRN_RTO,
CH_VOL_RTO,
CH_CMNT_AREA,
CH_BLD_AREA,
CH_COM_DATE,
CH_CMNT_LOC,
CH_OPEN_DATE,
IS_AVL,
CRT_TM,
CRT_PSN,
UPT_TM,
PRICE_LIST,
RENT_LIST,
UPT_PSN,
CH_CMNT_CRAWL_TM,
BATCH_ID,
CH_CMNT_INFO,
CH_PROVINCE,
CH_CITY_ORIG
from ch_cmnt_detail where batch_id='202110201000';

 # 创建城市房产网租房详情表

CREATE TABLE `ch_rent_detail`(
`PK_ID` string comment '唯一主键',
`CH_PROVINCE` string comment '省',
`CH_CITY_ORIG` string comment '市_原始',
`CH_AREA_ORIG` string comment '区_原始',
`CH_CMNT_ID_ORIG` string comment '小区ID_原始',
`CH_CMNT_NAME_ORIG` string comment '小区名_原始',
`CH_ALIAS_NAME_ORIG` string comment '小区别名_原始',
`CH_CMNT_ADDR_ORIG` string comment '小区地址_原始',
`GET_METHOD` string comment '获取方式',
`CH_DIST` string comment '行政区',
`CH_BIZ_DIST` string comment '所属商圈',
`CH_CMNT` string comment '小区名',
`CH_CMNT_URL` string comment '小区URL',
`CH_CMNT_SCORE` string comment '小区评分',
`CH_CMNT_YEAR` string comment '小区建筑年代',
`CH_RENT_PER_PR` string comment '租房平均单价',
`CH_RENT_PER_PR_INS` string comment '较上个月涨幅',
`CH_HSE_RENT_URL` string comment '租房url',
`CH_RENT_PRICE` string comment '整租价格',
`CH_BLD_TYPE` string comment '建筑类型',
`CH_CMNT_BLD_YEAR` string comment '建筑年代',
`CH_CMNT_AREA` string comment '占地面积',
`CH_VOL_RTO` string comment '容积率',
`CH_GRN_RTO` string comment '绿化率',
`CH_CMNT_DEV_NM` string comment '开发商',
`CH_CMNT_HOA_NM` string comment '物业公司',
`CH_BLD_AREA` string comment '建筑面积',
`CH_TITLE` string comment '标题',
`CH_HSE_USE` string comment '用途',
`CH_HSE_AREA` string comment '面积',
`CH_HSE_TWD` string comment '用途',
`CH_HSE_TYPE` string comment '户型',
`CH_HSE_DEG_DECT` string comment '装修程度',
`CH_HSE_FLR` string comment '所在楼层',
`CH_HSE_TTL_FLR` string comment '总楼层',
`CH_RENT_TYPE` string comment '租赁方式',
`CH_PAY_METHOD` string comment '付款方式',
`CH_RELEASE_TM` string comment '发布时间',
`CH_HSE_PROP_BLG` string comment '权属',
`CH_RENT_INFO` string comment '出租简介',
`IS_AVL` string comment '是否有效',
`CRT_TM` timestamp comment '创建时间',
`CRT_PSN` string comment '创建人',
`UPT_TM` timestamp comment '更新时间',
`UPT_PSN` string comment '更新人',
`CH_RENT_CRAWL_TM` timestamp comment '爬取时间',
`BATCH_ID` string comment '批次号'
)
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',', 'serialization.format'=',')STORED AS TEXTFILE;

 

 

# 创建城市房产网租房详情分区表

CREATE TABLE `ch_rent_detail_fq`(
`PK_ID` string comment '唯一主键',
`CH_AREA_ORIG` string comment '区_原始',
`CH_CMNT_ID_ORIG` string comment '小区ID_原始',
`CH_CMNT_NAME_ORIG` string comment '小区名_原始',
`CH_ALIAS_NAME_ORIG` string comment '小区别名_原始',
`CH_CMNT_ADDR_ORIG` string comment '小区地址_原始',
`GET_METHOD` string comment '获取方式',
`CH_DIST` string comment '行政区',
`CH_BIZ_DIST` string comment '所属商圈',
`CH_CMNT` string comment '小区名',
`CH_CMNT_URL` string comment '小区URL',
`CH_CMNT_SCORE` string comment '小区评分',
`CH_CMNT_YEAR` string comment '小区建筑年代',
`CH_RENT_PER_PR` string comment '租房平均单价',
`CH_RENT_PER_PR_INS` string comment '较上个月涨幅',
`CH_HSE_RENT_URL` string comment '租房url',
`CH_RENT_PRICE` string comment '整租价格',
`CH_BLD_TYPE` string comment '建筑类型',
`CH_CMNT_BLD_YEAR` string comment '建筑年代',
`CH_CMNT_AREA` string comment '占地面积',
`CH_VOL_RTO` string comment '容积率',
`CH_GRN_RTO` string comment '绿化率',
`CH_CMNT_DEV_NM` string comment '开发商',
`CH_CMNT_HOA_NM` string comment '物业公司',
`CH_BLD_AREA` string comment '建筑面积',
`CH_TITLE` string comment '标题',
`CH_HSE_USE` string comment '用途',
`CH_HSE_AREA` string comment '面积',
`CH_HSE_TWD` string comment '用途',
`CH_HSE_TYPE` string comment '户型',
`CH_HSE_DEG_DECT` string comment '装修程度',
`CH_HSE_FLR` string comment '所在楼层',
`CH_HSE_TTL_FLR` string comment '总楼层',
`CH_RENT_TYPE` string comment '租赁方式',
`CH_PAY_METHOD` string comment '付款方式',
`CH_RELEASE_TM` string comment '发布时间',
`CH_HSE_PROP_BLG` string comment '权属',
`CH_RENT_INFO` string comment '出租简介',
`IS_AVL` string comment '是否有效',
`CRT_TM` timestamp comment '创建时间',
`CRT_PSN` string comment '创建人',
`UPT_TM` timestamp comment '更新时间',
`UPT_PSN` string comment '更新人',
`CH_RENT_CRAWL_TM` timestamp comment '爬取时间',
`BATCH_ID` string comment '批次号'
)
PARTITIONED BY (
`CH_PROVINCE` string comment '省',
`CH_CITY_ORIG` string comment '市_原始')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

# 插入数据

insert into ch_rent_detail_fq select uuid(),
CH_AREA_ORIG,
CH_CMNT_ID_ORIG,
CH_CMNT_NAME_ORIG,
CH_ALIAS_NAME_ORIG,
CH_CMNT_ADDR_ORIG,
GET_METHOD,
CH_DIST,
CH_BIZ_DIST,
CH_CMNT,
CH_CMNT_URL,
CH_CMNT_SCORE,
CH_CMNT_YEAR,
CH_RENT_PER_PR,
CH_RENT_PER_PR_INS,
CH_HSE_RENT_URL,
CH_RENT_PRICE,
CH_BLD_TYPE,
CH_CMNT_BLD_YEAR,
CH_CMNT_AREA,
CH_VOL_RTO,
CH_GRN_RTO,
CH_CMNT_DEV_NM,
CH_CMNT_HOA_NM,
CH_BLD_AREA,
CH_TITLE,
CH_HSE_USE,
CH_HSE_AREA,
CH_HSE_TWD,
CH_HSE_TYPE,
CH_HSE_DEG_DECT,
CH_HSE_FLR,
CH_HSE_TTL_FLR,
CH_RENT_TYPE,
CH_PAY_METHOD,
CH_RELEASE_TM,
CH_HSE_PROP_BLG,
CH_RENT_INFO,
IS_AVL,
CRT_TM,
CRT_PSN,
UPT_TM,
UPT_PSN,
CH_RENT_CRAWL_TM,
BATCH_ID,
CH_PROVINCE,
CH_CITY_ORIG
from ch_rent_detail where batch_id='202110201000';

 

10.1 创建70大城市价格指数详情表:
CREATE TABLE ypc_price_detail(
pd_id string comment '价格指数详情ID',
pi_id string comment '价格指数ID',
fixture_date string comment '成交日期',
value_index double comment '价格指数',
create_time timestamp comment '创建时间',
update_time timestamp comment '更新时间',
creator string comment '创建人',
modifier string comment '更新人',
batch_id string COMMENT '批次号')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

11.1 创建70大城市价格指数配置表:
CREATE TABLE ypc_price_index(
pi_id string comment '价格指数ID',
pi_pid string comment '价格指数父级ID',
prov_id string comment '省id',
prov_name string comment '省名称',
city_id string comment '市id',
city_name string comment '市名称',
pi_type string comment '价格指数类型(0-新建商品住宅销售价格指数(定基)|1-新建商品住宅销售价格指数(环比)|2-二手住宅销售价格指数(定基)|3-二手住宅销售价格指数(环比)|4-新建商品住宅销售价格指数(同比)|5-二手住宅销售价格指数(同比))',
use_code string comment '用途',
is_standard string comment '是否基准年份(0-否|1-是)',
pi_year string comment '指数年份',
standard_year string comment '基准年份',
stan_coefficient string comment '基准转换系数',
create_time timestamp comment '创建时间',
update_time timestamp comment '更新时间',
creator string comment '创建人',
modifier string comment '更新人',
batch_id string COMMENT '批次号')
ROW FORMAT SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')STORED AS TEXTFILE;

七、其他操作

①从csv导入数据

load data inpath '/user/Linjj/test11.csv' into table source_city_list_pr_date_creator;

②查询

select * from ods_lj_tran_pr_crawl;

③清空表

truncate table source_city_list_pr_date_creator;

④更改字段数据类型

Alter table source_city_list_pr_date_creator change column batch_id batch_id string;

⑤删除表
drop table source_city_trans_pr_date_creator_temp;

⑥复制表结构并插入数据

create table if not exists ods_data_collection.ods_lj_tran_pr_crawl like test_spider.source_city_trans_pr_date_creator_temp;
insert into ods_data_collection.ods_lj_tran_pr_crawl select * from test_spider.source_city_trans_pr_date_creator_temp;

⑦ 修改数据

insert into table test SELECT * FROM source_city_list_pr_date_creator_temp WHERE lj_hse_ttl_flr is not NULL

⑧修改表名

alter table ods_lj_hse_tran_pr_crawl_2 rename to ods_lj_hse_tran_pr_crawl

 

⑨row format delimited fields terminated by "," STORED AS TEXTFILE;

 

posted @ 2020-11-06 17:30  Big_river  阅读(1560)  评论(0编辑  收藏  举报