-
Notifications
You must be signed in to change notification settings - Fork 6
/
execute_hive_query
executable file
·42 lines (36 loc) · 2.03 KB
/
execute_hive_query
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python
# pluo, Apr 1, 2013
# PATH=$PATH:/home/dataproc/bi/lib/python # add python lib to path
# execute_hive_query --hive_query='desc opportunity'
# execute_hive_query --hive_query='select count(*) from opportunity'
# execute_hive_query --hive_query='drop table if exists tmp_fpv'
import legoo
import sys
from optparse import OptionParser
def main():
parser = OptionParser()
parser.add_option("--hive_node", dest="hive_node",
help="hive node. default: [namenode2s]", default='namenode2s')
parser.add_option("--hive_port", dest="hive_port",
help="hive port number. default: [10000]", default='10000')
parser.add_option("--hive_db", dest="hive_db",
help="hive db. default: [staging]", default='staging')
parser.add_option("--hive_query", dest="hive_query", help="hive query")
parser.add_option("--mapred_job_priority", dest="mapred_job_priority",
help="OPTIONAL: map reduce job priority [VERY_HIGH, HIGH, NORMAL, LOW, VERY_LOW]. default: [NORMAL]", default='NORMAL')
parser.add_option("-q", "--quiet", "--silent", dest="quiet",
help="OPTIONAL: suppress messages to stdout. default: [N]", default='N')
parser.add_option("-d", "--debug", dest="debug", help="OPTIONAL: debug flag [Y|N], default: [N]", default='N')
(options, args) = parser.parse_args()
rs = legoo.execute_remote_hive_query( hive_node = options.hive_node, \
hive_port = options.hive_port, \
hive_db = options.hive_db, \
hive_query = options.hive_query, \
mapred_job_priority = options.mapred_job_priority, \
quiet = options.quiet, \
debug = options.debug
)
for i in rs:
print i
if __name__ == '__main__':
main()