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

Fix typo made in #1964 #2106

Merged
merged 8 commits into from
Jun 2, 2020
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
2 changes: 1 addition & 1 deletion ibis/omniscidb/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1178,7 +1178,7 @@ def database(self, name=None):
protocol=self.protocol,
session_id=self.session_id,
ipc=self.ipc,
device=self.device,
gpu_device=self.gpu_device,
)
return self.database_class(name, new_client)

Expand Down
36 changes: 36 additions & 0 deletions ibis/tests/all/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,3 +414,39 @@ def temp_view(con) -> str:
finally:
if hasattr(con, 'drop_view'):
con.drop_view(name, force=True)


@pytest.fixture(scope='session')
def current_data_db(con, backend) -> str:
"""Return current database name."""
if not hasattr(con, 'current_database'):
pytest.skip(
f'{backend.name} backend doesn\'t have current_database method.'
)
return con.current_database


@pytest.fixture
def alternate_current_database(con, backend, current_data_db: str) -> str:
"""Create a temporary database and yield its name.
Drops the created database upon completion.

Parameters
----------
con : ibis.client.Client
current_data_db : str
Yields
-------
str
"""
name = _random_identifier('database')
if not hasattr(con, 'create_database'):
pytest.skip(
f'{backend.name} backend doesn\'t have create_database method.'
)
con.create_database(name)
try:
yield name
finally:
con.set_database(current_data_db)
con.drop_database(name, force=True)
23 changes: 22 additions & 1 deletion ibis/tests/all/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

import ibis
import ibis.expr.datatypes as dt
from ibis.tests.backends import BigQuery, Impala, PySpark, Spark
from ibis.tests.backends import (
BigQuery,
Clickhouse,
Impala,
OmniSciDB,
PySpark,
Spark,
)


@pytest.fixture
Expand Down Expand Up @@ -187,3 +194,17 @@ def test_create_drop_view(con, backend, temp_view):
v_expr = con.table(temp_view)
# check if the view and the table has the same fields
assert set(t_expr.schema().names) == set(v_expr.schema().names)


@pytest.mark.only_on_backends(
[BigQuery, Clickhouse, Impala, OmniSciDB, Spark, BigQuery],
reason="run only if backend is sql-based",
)
def test_separate_database(con, alternate_current_database, current_data_db):
# using alternate_current_database switches "con" current
# database to a temporary one until a test is over
tmp_db = con.database(alternate_current_database)
# verifying we can open another db which isn't equal to current
db = con.database(current_data_db)
assert db.name == current_data_db
assert tmp_db.name == alternate_current_database