Skip to content

Commit

Permalink
Merge pull request ibis-project#20 from maxmzkr/QP-882
Browse files Browse the repository at this point in the history
Don't set database and don't ensure database
  • Loading branch information
maxmzkr authored Jun 28, 2017
2 parents 292e23d + c98e98a commit 2d3652d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ibis/impala/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ def _get_cursor(self):

def _new_cursor(self):
params = self.params.copy()
con = impyla.connect(database=self.database, **params)
database = None
if self.database != 'default':
database = self.database
con = impyla.connect(database=database, **params)

self._connections[id(con)] = con

Expand Down Expand Up @@ -486,7 +489,7 @@ def __init__(self, con, hdfs_client=None, **params):

self._temp_objects = weakref.WeakValueDictionary()

self._ensure_temp_db_exists()
self._ensured = False

def _build_ast(self, expr):
return build_ast(expr)
Expand Down Expand Up @@ -1017,6 +1020,7 @@ def parquet_file(self, hdfs_dir, schema=None, name=None, database=None,
return self._wrap_new_table(name, database, persist)

def _get_concrete_table_path(self, name, database, persist=False):
self._ensure_temp_db_exists()
if not persist:
if name is None:
name = '__ibis_tmp_{0}'.format(util.guid())
Expand All @@ -1032,13 +1036,16 @@ def _get_concrete_table_path(self, name, database, persist=False):

def _ensure_temp_db_exists(self):
# TODO: session memoize to avoid unnecessary `SHOW DATABASES` calls
if self._ensured:
return
name, path = options.impala.temp_db, options.impala.temp_hdfs_path
if not self.exists_database(name):
if self._hdfs is None:
print('Without an HDFS connection, certain functionality'
' may be disabled')
else:
self.create_database(name, path=path, force=True)
self._ensured = True

def _wrap_new_table(self, name, database, persist):
qualified_name = self._fully_qualified_name(name, database)
Expand Down

0 comments on commit 2d3652d

Please sign in to comment.