java hive建表_hive 建表, shell的例子

CREATE TABLE reqstat_gif_result(

plat string,

version  string,

net   string,

productid  string,

gbcode   string,

objtype    string,

count    BIGINT,

average   int

)

PARTITIONED BY( time_type string ,time_value string,query_type string)

ROW FORMAT DELIMITED

FIELDS TERMINATED BY '\t'

COLLECTION ITEMS TERMINATED BY ':'

LINES TERMINATED BY '\n'

STORED AS RCFILE;

#!/bin/bash

. ~/.bash_profile

if [ $# -eq 0 ]

then

time_type=hour

time_value=`date -d "-1 hour" +%Y%m%d%H`

elif [ $# -eq 1 ]

then

time_type=hour

time_value=$1

elif [ $# -eq 2 ]

then

time_type=$1

time_value=$2

else

echo "args is error."

exit 1

fi

echo "timetype:${time_type}, timevalue:${time_value}"

array="dns connect request response download"

for query_type in $array;

do

echo "querytype : ${query_type}"

$HIVE_HOME/bin/hive -e "\

set hive.exec.dynamic.partition=true;

set mapred.reduce.tasks=8;

set mapred.job.name=reqstat_gif_result_${time_type}_${time_value};

insert overwrite table mid.reqstat_gif_result partition(time_type='${time_type}',time_value='${time_value}',query_type='${query_type}') select p,v,net,u,gbcode,objtype, count(*),round(avg(get_json_object(a.req_para,'$.${query_type}')))  from  event.reqstat_gif  a where p_hour='${time_value}'  group by p,v,gbcode,net,u,objtype;

"

done;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值