Skip to content

Commit a8d3007

Browse files
committed
refactor(ir/backends): remove various deprecated functions and methods
BREAKING CHANGE: removed the following symbols: - `ibis.backends.duckdb.parse_type()` function - `ibis.backends.impala.Backend.set_database()` method - `ibis.backends.pyspark.Backend.set_database()` method - `ibis.backends.impala.ImpalaConnection.ping()` method - `ibis.expr.operations.DatabaseTable.change_name()` method - `ibis.expr.operations.ParseURL` class - `ibis.expr.operations.Value.to_projection()` method - `ibis.expr.types.Table.get_column()` method - `ibis.expr.types.Table.get_columns()` method - `ibis.expr.types.StringValue.parse_url()` method
1 parent 8912b24 commit a8d3007

File tree

17 files changed

+7
-210
lines changed

17 files changed

+7
-210
lines changed

docs/backends/Impala.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ backend.
2929
options:
3030
heading_level: 3
3131
members:
32-
- set_database
3332
- create_database
3433
- drop_database
3534
- list_databases

ibis/backends/base/sql/compiler/translator.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -375,24 +375,3 @@ def _rewrite_cast(op):
375375
@rewrites(ops.StringContains)
376376
def _rewrite_string_contains(op):
377377
return ops.GreaterEqual(ops.StringFind(op.haystack, op.needle), 0)
378-
379-
380-
NEW_EXTRACT_URL_OPERATION = {
381-
"PROTOCOL": ops.ExtractProtocol,
382-
"AUTHORITY": ops.ExtractAuthority,
383-
"USERINFO": ops.ExtractUserInfo,
384-
"HOST": ops.ExtractHost,
385-
"FILE": ops.ExtractFile,
386-
"PATH": ops.ExtractPath,
387-
"REF": ops.ExtractFragment,
388-
}
389-
390-
391-
@rewrites(ops.ParseURL)
392-
def _rewrite_string_contains(op):
393-
extract = op.extract
394-
if extract == 'QUERY':
395-
return ops.ExtractQuery(op.arg, op.key)
396-
if (new_op := NEW_EXTRACT_URL_OPERATION.get(extract)) is not None:
397-
return new_op(op.arg)
398-
raise ValueError(f"{extract!r} is not supported")

ibis/backends/conftest.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ def current_data_db(ddl_con) -> str:
666666

667667

668668
@pytest.fixture
669-
def alternate_current_database(ddl_con, ddl_backend, current_data_db: str) -> str:
669+
def alternate_current_database(ddl_con, ddl_backend) -> str:
670670
"""Create a temporary database and yield its name. Drops the created
671671
database upon completion.
672672
@@ -686,7 +686,6 @@ def alternate_current_database(ddl_con, ddl_backend, current_data_db: str) -> st
686686
try:
687687
yield name
688688
finally:
689-
ddl_con.set_database(current_data_db)
690689
ddl_con.drop_database(name, force=True)
691690

692691

ibis/backends/duckdb/datatypes.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from sqlalchemy.dialects import postgresql
88

99
import ibis.expr.datatypes as dt
10-
from ibis import util
1110
from ibis.backends.base.sql.alchemy import to_sqla_type
1211
from ibis.common.parsing import (
1312
COMMA,
@@ -139,13 +138,6 @@ def struct():
139138
return ty.parse(text)
140139

141140

142-
@util.deprecated(
143-
instead=f"use {parse.__module__}.{parse.__name__}", as_of="4.0", removed_in="5.0"
144-
)
145-
def parse_type(*args, **kwargs):
146-
return parse(*args, **kwargs)
147-
148-
149141
@to_sqla_type.register(DuckDBDialect, dt.UUID)
150142
def sa_duckdb_uuid(_, itype):
151143
return postgresql.UUID

ibis/backends/duckdb/tests/test_datatypes.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,3 @@
7878
def test_parser(typ, expected):
7979
ty = parse(typ)
8080
assert ty == expected
81-
82-
83-
def test_parse_type_warns():
84-
from ibis.backends.duckdb.datatypes import parse_type
85-
86-
with pytest.warns(FutureWarning):
87-
parse_type("BIGINT")

ibis/backends/impala/__init__.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,6 @@ def _get_list(self, cur):
380380
tuples = cur.fetchall()
381381
return list(map(operator.itemgetter(0), tuples))
382382

383-
@util.deprecated(
384-
as_of="2.0", removed_in="5.0", instead="use a new connection to the database"
385-
)
386-
def set_database(self, name):
387-
# XXX The parent `Client` has a generic method that calls this same
388-
# method in the backend. But for whatever reason calling this code from
389-
# that method doesn't seem to work. Maybe `con` is a copy?
390-
self.con.set_database(name)
391-
392383
@property
393384
def current_database(self):
394385
# XXX The parent `Client` has a generic method that calls this same

ibis/backends/impala/client.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ def close(self):
7373
"""Close all idle Impyla connections."""
7474
self.pool.dispose()
7575

76-
def set_database(self, name):
77-
self.database = name
78-
7976
def disable_codegen(self, disabled=True):
8077
self.options["DISABLE_CODEGEN"] = str(int(disabled))
8178

@@ -115,10 +112,6 @@ def _new_cursor(self):
115112
wrapper.set_options()
116113
return wrapper
117114

118-
@util.deprecated(instead="", as_of="4.0", removed_in="5.0")
119-
def ping(self): # pragma: no cover
120-
self.pool.connect()._cursor.ping()
121-
122115
def release(self, cur): # pragma: no cover
123116
pass
124117

ibis/backends/impala/tests/conftest.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@ def tmp_db(env, con, test_data_db):
313313
try:
314314
yield tmp_db
315315
finally:
316-
con.set_database(test_data_db)
317316
with contextlib.suppress(impala.error.HiveServer2Error):
318317
# The database can be dropped by another process during tear down
319318
# in the middle of dropping this one if tests are running in
@@ -353,7 +352,6 @@ def temp_database(con, test_data_db):
353352
try:
354353
yield name
355354
finally:
356-
con.set_database(test_data_db)
357355
con.drop_database(name, force=True)
358356

359357

ibis/backends/impala/tests/test_client.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -302,23 +302,3 @@ def test_list_databases(con):
302302
def test_list_tables(con, test_data_db):
303303
assert con.list_tables(database=test_data_db)
304304
assert con.list_tables(like='*nat*', database=test_data_db)
305-
306-
307-
def test_set_database(con_no_db, test_data_db):
308-
# create new connection with no default db set
309-
# TODO: set test_data_db to None
310-
with pytest.raises(Exception):
311-
con_no_db.table('functional_alltypes')
312-
con_no_db.set_database(test_data_db)
313-
assert con_no_db.table('functional_alltypes') is not None
314-
315-
316-
def test_tables_robust_to_set_database(con, test_data_db, temp_database):
317-
table = con.table('functional_alltypes', database=test_data_db)
318-
con.set_database(temp_database)
319-
assert con.current_database == temp_database
320-
321-
# it still works!
322-
n = 10
323-
df = table.limit(n).execute()
324-
assert len(df) == n

ibis/backends/pyspark/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import ibis.expr.operations as ops
1414
import ibis.expr.schema as sch
1515
import ibis.expr.types as ir
16-
from ibis import util
1716
from ibis.backends.base.sql import BaseSQLBackend
1817
from ibis.backends.base.sql.compiler import Compiler, TableSetFormatter
1918
from ibis.backends.base.sql.ddl import (
@@ -158,12 +157,6 @@ def do_connect(self, session: SparkSession) -> None:
158157
def version(self):
159158
return pyspark.__version__
160159

161-
@util.deprecated(
162-
as_of="2.0", removed_in="5.0", instead="use a new connection to the database"
163-
)
164-
def set_database(self, name):
165-
self._catalog.setCurrentDatabase(name)
166-
167160
@property
168161
def current_database(self):
169162
return self._catalog.currentDatabase()

ibis/backends/pyspark/tests/conftest.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ def get_pyspark_testing_client(data_directory):
212212
return get_common_spark_testing_client(data_directory, ibis.pyspark.connect)
213213

214214

215+
def set_pyspark_database(client, database):
216+
client._session.catalog.setCurrentDatabase(database)
217+
218+
215219
class TestConf(BackendTest, RoundAwayFromZero):
216220
supported_to_timestamp_units = {'s'}
217221

@@ -303,7 +307,7 @@ def test_data_db(client):
303307
name = os.environ.get('IBIS_TEST_DATA_DB', 'ibis_testing')
304308
client.create_database(name)
305309
try:
306-
client.set_database(name)
310+
set_pyspark_database(client, name)
307311
yield name
308312
finally:
309313
client.drop_database(name, force=True)
@@ -316,7 +320,7 @@ def temp_database(client, test_data_db):
316320
try:
317321
yield name
318322
finally:
319-
client.set_database(test_data_db)
323+
set_pyspark_database(client, test_data_db)
320324
client.drop_database(name, force=True)
321325

322326

ibis/expr/operations/relations.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ class DatabaseTable(PhysicalTable):
5959
schema = rlz.instance_of(sch.Schema)
6060
source = rlz.client
6161

62-
@util.deprecated(instead=".copy(name=new_name)", as_of="4.1", removed_in="5.0")
63-
def change_name(self, new_name):
64-
return self.copy(name=new_name)
65-
6662

6763
@public
6864
class SQLQueryResult(TableNode):

ibis/expr/operations/strings.py

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import ibis.expr.datatypes as dt
66
import ibis.expr.rules as rlz
7-
from ibis import util
87
from ibis.common.annotations import attribute
98
from ibis.expr.operations.core import Unary, Value
109

@@ -225,33 +224,6 @@ class StringConcat(Value):
225224
output_dtype = rlz.dtype_like('arg')
226225

227226

228-
@public
229-
class ParseURL(Value):
230-
arg = rlz.string
231-
extract = rlz.isin(
232-
{
233-
'PROTOCOL',
234-
'AUTHORITY',
235-
'USERINFO',
236-
'HOST',
237-
'FILE',
238-
'PATH',
239-
'QUERY',
240-
'REF',
241-
}
242-
)
243-
key = rlz.optional(rlz.string)
244-
245-
output_shape = rlz.shape_like("arg")
246-
output_dtype = dt.string
247-
248-
@util.deprecated(
249-
as_of="4.0", removed_in="5.0", instead="use ExtractURLField and its subclasses"
250-
)
251-
def __init__(self, *args, **kwargs):
252-
super().__init__(*args, **kwargs)
253-
254-
255227
@public
256228
class ExtractURLField(Value):
257229
arg = rlz.string

ibis/expr/types/generic.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,6 @@ def desc(self) -> ir.Value:
481481
"""Sort an expression descending."""
482482
return ops.SortKey(self, ascending=False).to_expr()
483483

484-
@util.deprecated(as_of="4.1", removed_in="5.0", instead="use `.as_table()`")
485-
def to_projection(self) -> ir.Table: # noqa: D102
486-
return self.as_table()
487-
488484
def as_table(self) -> ir.Table:
489485
"""Promote the expression to a table.
490486

ibis/expr/types/relations.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -230,48 +230,6 @@ def _ensure_expr(self, expr):
230230
else:
231231
return expr
232232

233-
@util.deprecated(
234-
as_of="4.1",
235-
removed_in="5.0",
236-
instead="use a list comprehension and attribute/getitem syntax",
237-
)
238-
def get_columns(self, iterable: Iterable[str]) -> list[Column]:
239-
"""Get multiple columns from the table.
240-
241-
Parameters
242-
----------
243-
iterable
244-
An iterable of column names
245-
246-
Examples
247-
--------
248-
>>> import ibis
249-
>>> table = ibis.table(dict(a='int64', b='string', c='timestamp', d='float'))
250-
>>> a, b, c = table.get_columns(['a', 'b', 'c'])
251-
252-
Returns
253-
-------
254-
list[ir.Column]
255-
List of column expressions
256-
"""
257-
return list(map(self.get_column, iterable))
258-
259-
@util.deprecated(as_of="4.1", removed_in="5.0", instead="use t.<name> or t[name]")
260-
def get_column(self, name: str) -> Column:
261-
"""Get a reference to a single column from the table.
262-
263-
Parameters
264-
----------
265-
name
266-
A column name
267-
268-
Returns
269-
-------
270-
Column
271-
A column named `name`.
272-
"""
273-
return ops.TableColumn(self, name).to_expr()
274-
275233
@property
276234
def columns(self):
277235
"""The list of columns in this table."""

ibis/expr/types/strings.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -635,51 +635,6 @@ def to_timestamp(self, format_str: str) -> ir.TimestampValue:
635635
"""
636636
return ops.StringToTimestamp(self, format_str).to_expr()
637637

638-
@util.deprecated(
639-
as_of='4.0',
640-
removed_in='5.0',
641-
instead=(
642-
'use .protocol(), .authroity(), .userinfo(), .host(), .file(), .path(), .query(), or .fragment().'
643-
),
644-
)
645-
def parse_url(
646-
self,
647-
extract: Literal[
648-
"PROTOCOL",
649-
"AUTHORITY",
650-
"USERINFO",
651-
"HOST",
652-
"FILE",
653-
"PATH",
654-
"QUERY",
655-
"REF",
656-
],
657-
key: str | None = None,
658-
) -> StringValue:
659-
"""Parse a URL and extract its components.
660-
661-
`key` can be used to extract query values when `extract == 'QUERY'`
662-
663-
Parameters
664-
----------
665-
extract
666-
Component of URL to extract
667-
key
668-
Query component to extract
669-
670-
Examples
671-
--------
672-
>>> import ibis
673-
>>> url = ibis.literal("https://www.youtube.com/watch?v=kEuEcWfewf8&t=10")
674-
>>> result = url.parse_url('QUERY', 'v') # kEuEcWfewf
675-
676-
Returns
677-
-------
678-
StringValue
679-
Extracted string value
680-
"""
681-
return ops.ParseURL(self, extract, key).to_expr()
682-
683638
def protocol(self):
684639
"""Parse a URL and extract protocol.
685640

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,6 @@ filterwarnings = [
270270
# ibis
271271
"ignore:`BaseBackend.database` is deprecated:FutureWarning",
272272
"ignore:`Backend.database` is deprecated:FutureWarning",
273-
"ignore:`Backend.set_database` is deprecated:FutureWarning",
274273
# ibis on postgres + windows
275274
"ignore:locale specific date formats:UserWarning",
276275
# shapely

0 commit comments

Comments
 (0)