執行語句前:
先配置以下條件
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 SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')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 SERDE
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe'
WITH SERDEPROPERTIES (
'field.delim'=',',
'serialization.format'=',')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';
三、掛牌均價表
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;
