Skip to content

Commit f21ee01

Browse files
committed
added impala_tables_list.py
1 parent e26f222 commit f21ee01

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

impala_tables_list.py

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/usr/bin/env python
2+
# vim:ts=4:sts=4:sw=4:et
3+
#
4+
# Author: Hari Sekhon
5+
# Date: 2019-11-26 10:08:52 +0000 (Tue, 26 Nov 2019)
6+
#
7+
# https://github.com/harisekhon/devops-python-tools
8+
#
9+
# License: see accompanying Hari Sekhon LICENSE file
10+
#
11+
# If you're using my code you're welcome to connect with me on LinkedIn
12+
# and optionally send me feedback to help steer this or other code I publish
13+
#
14+
# https://www.linkedin.com/in/harisekhon
15+
#
16+
17+
"""
18+
19+
Connect to an Impala daemon and list all databases and tables
20+
21+
TSV Output format:
22+
23+
<database> <table>
24+
25+
26+
Tested on Impala 2.7.0 on CDH 5.10 with Kerberos
27+
28+
Due to a thrift / impyla bug this needs exactly thrift==0.9.3, see
29+
30+
https://github.com/cloudera/impyla/issues/286
31+
32+
If you get an error like this:
33+
34+
ERROR:impala.hiveserver2:Failed to open transport (tries_left=1)
35+
...
36+
TTransportException: TSocket read 0 bytes
37+
38+
then check your --kerberos and --ssl settings match the cluster's settings
39+
(Thrift and Kerberos have the worst error messages ever)
40+
41+
"""
42+
43+
from __future__ import absolute_import
44+
from __future__ import division
45+
from __future__ import print_function
46+
from __future__ import unicode_literals
47+
48+
import os
49+
import sys
50+
srcdir = os.path.abspath(os.path.dirname(__file__))
51+
pylib = os.path.join(srcdir, 'pylib')
52+
sys.path.append(pylib)
53+
try:
54+
# pylint: disable=wrong-import-position
55+
from hive_tables_list import HiveTablesList
56+
except ImportError as _:
57+
print('module import failed: %s' % _, file=sys.stderr)
58+
print("Did you remember to build the project by running 'make'?", file=sys.stderr)
59+
print("Alternatively perhaps you tried to copy this program out without it's adjacent libraries?", file=sys.stderr)
60+
sys.exit(4)
61+
62+
__author__ = 'Hari Sekhon'
63+
__version__ = '0.1.0'
64+
65+
66+
class ImpalaTablesList(HiveTablesList):
67+
68+
def __init__(self):
69+
# Python 2.x
70+
super(ImpalaTablesList, self).__init__()
71+
# Python 3.x
72+
# super().__init__()
73+
74+
# these are auto-set checking sys.argv[0] in HiveImpalaCLI class
75+
self.name = 'Impala'
76+
#self.default_port = 21050
77+
#self.default_service_name = 'impala'
78+
79+
80+
if __name__ == '__main__':
81+
ImpalaTablesList().main()

0 commit comments

Comments
 (0)