hive transform shell脚本运行
来源:互联网 发布:java调用父类方法 编辑:程序博客网 时间:2024/05/21 09:48
hive transform shell脚本运行
hive transform是将脚本嵌入到hive的sql搜索当中。由于在hive中,sql相当于mapreduce,因此相当于在mapreduce的过程中再加入一个处理。
实例分析
- 需求:在hive中搜索数据,搜索过程中看是否数据在某个集合中。
- 描述:在hive的sql搜索过程中,对搜索成功的每一条数据,输入到脚本中,然后再输出。
- 过程:
- 将需要的文件添加进去
- 执行sql
- 执行脚本,脚本中先读取文件,获取集合。然后对标准输入的数据进行处理,如果在集合中就输出
- 扩展:可以多层嵌套(sql+脚本),直到满足需求
- 坑:add文件和sql语句必须在一起
- 代码
HIVE_BIN='your path'${HIVE_BIN} -e "add file transform.py ;add file temp; select transform(p.a) using 'python transform.py' as (b) from (select a from table1 ) as p" > $DATE;
#coding:utf-8import sysreload(sys)sys.setdefaultencoding('utf-8')if __name__=="__main__": a_list = [] with open('tmp','r')as r: a_lines = r.readlines() for a_line in a_lines: a_list.append(a_line.strip().split('\t')[0]) #print da_list for line in sys.stdin: try: a = line.strip() if a in a_list: print a except : continue
阅读全文
0 0
- hive transform shell脚本运行
- hive transform脚本书写问题
- Shell脚本执行Hive语句
- hive脚本+shell执行方式
- HIVE的shell脚本模板
- Java运行shell脚本
- 运行shell脚本
- Shell脚本的运行
- shell脚本后台运行
- shell 脚本运行权限
- 远程运行shell脚本
- Linux 运行shell脚本
- shell 脚本后台运行
- ubuntu运行shell脚本
- 2.运行 shell 脚本
- Shell脚本运行~01
- 如何通过程序kill掉后台运行shell脚本中的mapreduce和hive任务
- 使用shell脚本执行hive、sqoop命令
- Lambda OrderByDescending OrderBy 记录
- MySQL数据类型选择原则
- 一个简单、漂亮、功能强大的Android日志程序:logger
- Java Reference
- Message.obtain() 和Handler.obtainMessage()的区别
- hive transform shell脚本运行
- #Poj1769#Minimizing maximizer(Dp+线段树优化)
- 2017-6-8
- How to Set Up an IKEv2 VPN Server with StrongSwan on Ubuntu 16.04
- 基于jQuery实现标签页切换的小功能
- 使用OllyDbg破解EasyCrackMe
- 微软OCR两层优化提升自然场景下的文字识别精度
- 最小权覆盖问题
- jQuery获取动态id的办法