(1)获取参数:从shell文件传来参数,调用:$1,$2,$3

load_date=$1

clearn_date=`date -d"$2 day ago $load_date" +%Y-%m-%d`

local_path=$3

(2)执行HIVE:

hive -e 后面是直接用双引号拼接hivesql语句,然后就可以执行命令

hive -e "ALTER TABLE dm_kg.dwd_intopieces DROP IF EXISTS PARTITION(etl_date='$clearn_date')"

hive -f 后面指定的是一个文件,然后文件里面直接写sql,就可以运行hive的sql

hive  -f $local_path/hive.hsql

(3)shell定义变量

hive -hiveconf day=20151115          -f test.sql

(4) sql文件调用变量

select * from ods.tracklog where day='${hiveconf:day}'

shell_hive的更多相关文章

随机推荐

  1. 【HANA系列】SAP HANA SQL条件判断是NULL的写法

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[HANA系列]SAP HANA SQL条件判断 ...

  2. bash: ./vmware-install.pl: /user/bin/perl: 坏的解释器:没有那个文件或目录

    ----------------安装VMwere Tools------------------------bash: ./vmware-install.pl: /usr/bin/perl: bad ...

  3. Shell脚本中的shebang到底是什么

    使用类Unix系统的同学可能都对"#!"这个符号并不陌生,但是你真的了解它吗? 这个符号的名称,叫做"Shebang"或者"Sha-bang" ...

  4. Win7主题存放路径详解

    WIN7用户主题--- 自定义主题  首先当然是用户自定义的主题文件夹,这个文件夹一般是存放在下面这个路径(注意那个用户名改成你自己的登陆名喔,比如 administrator) C:\Users\用 ...

  5. 2.更新YUM源

    查看本地源 先删除本地所有源 下载源仓库文件,xxx.repo curl -o /etc/yum.repos.d/ali.repo http://mirrors.aliyun.com/repo/Cen ...

  6. 【Linux-驱动】在sysfs下创建对应的class节点---class_create

    在编写简单字符设备驱动的时候,可以使用宏class_create在sysfs下创建对应的class节点,便于用户管理设备: #define class_create(owner, name) \ ({ ...

  7. PTA(Advanced Level)1042.Shuffling Machine

    Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techn ...

  8. [转帖]linux下使用 du查看某个文件或目录占用磁盘空间的大小

    linux下使用 du查看某个文件或目录占用磁盘空间的大小 du -ah --max-depth= 去年用过一次 后来忘记了.. 命令这个东西 熟能生巧.. https://www.cnblogs.c ...

  9. plpython 中文分词Windows 版

    windows 下安装版本匹配python-3.4.3.amd64.msipostgresql-10.1-2-windows-x64.exe create language plpython3u;se ...

  10. Oracle集群检测命令

    select inst_id, count(inst_id) from gv$session group by inst_id order by inst_id; srvctl stop databa ...