进入hive
beeline
!connect jdbc:hive2://s101:10000/lx;auth=noSasl;
建库并进入:
create database umeng;
use umeng;
建立原始数据表并加载数据:
use umeng; create external table if not exists raw_logs(servertimems float, servertimestr string, clientip string, clienttimems bigint, status int, json string) partitioned by(ym string,day string) row format delimited fields terminated by '#' lines terminated by ' '; load data inpath '/user/centos/umeng/raw-logs/201810/29/2027' into table raw_logs partition(ym=201810,day=29);
hive -f hive_create_table.sql
创建日志子表
-- 创建日志子表 use umeng ; create table if not exists appstartuplogs ( appchannel string , appid string , appplatform string , appversion string , brand string , carrier string , country string , createdatms bigint , deviceid string , devicestyle string , ipaddress string , network string , ostype string , province string , screensize string , tenantid string) PARTITIONED BY (ym string, day string) stored as parquet ; create table if not exists appeventlogs ( appchannel string , appid string , appplatform string , appversion string , brand string , createdatms bigint , deviceid string , devicestyle string , eventdurationsecs string , eventid string , ostype string , paramkeyvaluemap string , tenantid string) PARTITIONED BY (ym string, day string) stored as parquet ; create table if not exists apperrorlogs ( appchannel string , appid string , appplatform string , appversion string , brand string , createdatms bigint , deviceid string , devicestyle string , errorbrief string , errordetail string , ostype string , tenantid string) PARTITIONED BY (ym string, day string) stored as parquet ; create table if not exists appusagelogs ( appchannel string , appid string , appplatform string , appversion string , brand string , createdatms bigint , deviceid string , devicestyle string , ostype string , singledownloadtraffic string , singleuploadtraffic string , singleusedurationsecs string , tenantid string) PARTITIONED BY (ym string, day string) stored as parquet ; create table if not exists apppagelogs ( appchannel string , appid string , appplatform string , appversion string , brand string , createdatms bigint , deviceid string , devicestyle string , nextpage string , ostype string , pageid string , pageviewcntinsession string , staydurationsecs string , tenantid string , visitindex string) PARTITIONED BY (ym string, day string) stored as parquet ;