python查找hive表是否缺少日期分区脚本
#-*-coding:utf-8 -*-
import os
import sys
import datetime
import subprocess
reload(sys)
#获取hive表对应的文件存储目录
def get_hdfs(tb):
my_cmd = """hive -S -e "desc formatted """ + tb + """;" |grep Location"""
print(my_cmd)
res = subprocess.Popen(my_cmd, shell = True, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
get_results = []
while True:
line = res.stdout.readline().decode('utf8').strip()
if line == '' and res.poll() is not None:
break