Skip to content

Commit

Permalink
test(bigquery): fix failing non-warning tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcloud committed Nov 16, 2023
1 parent 350fed4 commit 2f8bc62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 41 deletions.
12 changes: 4 additions & 8 deletions ibis/backends/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import ibis.common.exceptions as com
import ibis.expr.operations as ops
import ibis.expr.types as ir
from ibis import util
from ibis.backends.base import CanCreateSchema, Database
from ibis.backends.base.sql import BaseSQLBackend
from ibis.backends.bigquery.client import (
Expand Down Expand Up @@ -494,14 +495,9 @@ def table(
self, name: str, database: str | None = None, schema: str | None = None
) -> ir.TableExpr:
if database is not None and schema is None:
util.warn_deprecated(
"database",
instead=(
f"The {self.name} backend cannot return a table expression using only a `database` specifier. "
"Include a `schema` argument."
),
as_of="7.1",
removed_in="8.0",
raise com.IbisInputError(
f"The {self.name} backend cannot return a table expression using only a "
"`database` specifier. Include a `schema` argument."
)

table = sg.parse_one(name, into=sg.exp.Table, read=self.name)
Expand Down
43 changes: 10 additions & 33 deletions ibis/backends/bigquery/tests/system/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,8 @@ def test_list_tables(con):
assert set(tables) == {"functional_alltypes", "functional_alltypes_parted"}


def test_current_database(con, dataset_id):
with pytest.warns(FutureWarning, match="data project"):
db = con.current_database
assert db == dataset_id
assert db == con.dataset_id
assert con.list_tables(schema=db, like="alltypes") == con.list_tables(
like="alltypes"
)
def test_current_database(con):
assert con.current_database == con.billing_project


def test_array_collect(struct_table):
Expand Down Expand Up @@ -244,37 +238,20 @@ def test_exists_table_different_project(con):


def test_multiple_project_queries(con, snapshot):
with pytest.warns(FutureWarning, match="`database` is deprecated as of v7.1"):
so = con.table("posts_questions", database="bigquery-public-data.stackoverflow")
with pytest.warns(FutureWarning, match="`database` is deprecated as of v7.1"):
trips = con.table("trips", database="nyc-tlc.yellow")
so = con.table(
"posts_questions", database="bigquery-public-data", schema="stackoverflow"
)
trips = con.table("trips", database="nyc-tlc", schema="yellow")
join = so.join(trips, so.tags == trips.rate_code)[[so.title]]
result = join.compile()
snapshot.assert_match(result, "out.sql")


def test_multiple_project_queries_database_api(con, snapshot):
stackoverflow = con.database("bigquery-public-data.stackoverflow")
with pytest.warns(FutureWarning, match="`database` is deprecated as of v7.1"):
posts_questions = stackoverflow.posts_questions
yellow = con.database("nyc-tlc.yellow")
with pytest.warns(FutureWarning, match="`database` is deprecated as of v7.1"):
trips = yellow.trips
predicate = posts_questions.tags == trips.rate_code
join = posts_questions.join(trips, predicate)[[posts_questions.title]]
result = join.compile()
snapshot.assert_match(result, "out.sql")


def test_multiple_project_queries_execute(con):
stackoverflow = con.database("bigquery-public-data.stackoverflow")
with pytest.warns(FutureWarning, match="`database` is deprecated as of v7.1"):
posts_questions = stackoverflow.posts_questions
posts_questions = posts_questions.limit(5)
yellow = con.database("nyc-tlc.yellow")
with pytest.warns(FutureWarning, match="`database` is deprecated as of v7.1"):
trips = yellow.trips
trips = trips.limit(5)
posts_questions = con.table(
"posts_questions", database="bigquery-public-data", schema="stackoverflow"
)
trips = con.table("trips", database="nyc-taxi", schema="yellow").limit(5)
predicate = posts_questions.tags == trips.rate_code
cols = [posts_questions.title]
join = posts_questions.left_join(trips, predicate)[cols]
Expand Down

0 comments on commit 2f8bc62

Please sign in to comment.