azkabin实现每天向hive分区表中加载数据——每天自动生成一个分区

第一步:创建分区表
create database hive_autoload;

create table hive_autoload.student2(
uid string,
gender string,
fuid string
)
partitioned by (dt string)
row format delimited fields terminated by "\t";

第二步创建脚本文件

1.在shell脚本的开头往往有一句话来定义使用哪种sh解释器来解释脚本。
目前研发送测的shell脚本中主要有以下两种方式:
(1) #!/bin/sh
(2) #!/bin/bash

区别:
#!/bin/sh-------------------程序执行错误就不会向下运行
#!/bin/bash-----------------程序运行错误略过错误继续向下执行

loadstudent.sh文件
#!/bin/bash
#定义昨天的日期时间
yesterday=`date -d '0 days ago' +%Y%m%d`
#定义local数据目录
hive_load='/datas/student1.txt'
#定义hive路径
hive_home=/opt/app/hive-1.2.2
#向表中添加分区
hive_sql="load data local inpath '"${hive_load}"' into table hive_autoload.student2 partition(dt="${yesterday}")"
echo "$hive_sql"
hive -e "$hive_sql"

2.创建job文件
type=command
command=bash loadstudent.sh

上传执行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值