diff --git a/ibis/impala/client.py b/ibis/impala/client.py index fcd46eb6e9a8..20b4ed3a835a 100644 --- a/ibis/impala/client.py +++ b/ibis/impala/client.py @@ -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 @@ -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) @@ -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()) @@ -1032,6 +1036,8 @@ 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: @@ -1039,6 +1045,7 @@ def _ensure_temp_db_exists(self): ' 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)