Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only install PyHive for default HiveServer2Client driver #65

Merged
merged 2 commits into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion omniduct/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

'hiveserver2': [
'pyhive[hive]>=0.4', # Primary client
'impyla>=0.14.0', # Primary client
'thrift>=0.10.0', # Thrift dependency which seems not to be installed with upstream deps
],

Expand Down
18 changes: 16 additions & 2 deletions omniduct/databases/hiveserver2.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,14 @@ def _init(self, schema=None, driver='pyhive', auth_mechanism='NOSASL',
def _connect(self):
from sqlalchemy import create_engine, MetaData
if self.driver == 'pyhive':
import pyhive.hive
try:
import pyhive.hive
except ImportError:
raise ImportError("""
Omniduct is attempting to use the 'pyhive' driver, but it
is not installed. Please either install the pyhive package,
or reconfigure this Duct to use the 'impyla' driver.
""")
self.__hive = pyhive.hive.connect(host=self.host,
port=self.port,
auth=self.auth_mechanism,
Expand All @@ -97,7 +104,14 @@ def _connect(self):
self._sqlalchemy_engine = create_engine('hive://{}:{}/{}'.format(self.host, self.port, self.schema))
self._sqlalchemy_metadata = MetaData(self._sqlalchemy_engine)
elif self.driver == 'impyla':
import impala.dbapi
try:
import impala.dbapi
except ImportError:
raise ImportError("""
Omniduct is attempting to use the 'impyla' driver, but it
is not installed. Please either install the impyla package,
or reconfigure this Duct to use the 'pyhive' driver.
""")
self.__hive = impala.dbapi.connect(host=self.host,
port=self.port,
auth_mechanism=self.auth_mechanism,
Expand Down