Skip to content

Commit e88ba9a

Browse files
committed
test: cover external table locations binding
AI Disclosure: This code was written in part by an AI agent.:
1 parent 17bb6cb commit e88ba9a

3 files changed

Lines changed: 9 additions & 15 deletions

File tree

python/datafusion/expr.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,14 @@
101101
def _create_external_table_location(self: Any) -> str:
102102
"""Return the first external table location.
103103
104+
Use :meth:`CreateExternalTable.locations` instead.
105+
104106
Examples:
105107
>>> class Command:
106108
... def locations(self) -> list[str]:
107109
... return ["data.csv"]
108-
>>> _create_external_table_location(Command())
109-
'data.csv'
110+
>>> Command().locations()
111+
['data.csv']
110112
"""
111113
locations = self.locations()
112114
return locations[0] if locations else ""

python/tests/test_catalog.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ def register_catalog(
123123
class CustomTableProviderFactory(dfn.catalog.TableProviderFactory):
124124
def create(self, cmd: dfn.expr.CreateExternalTable):
125125
assert cmd.name() == "test_table_factory"
126+
assert cmd.locations() == ["foo"]
127+
128+
with pytest.warns(DeprecationWarning, match=r"location\(\).+deprecated"):
129+
assert cmd.location() == "foo"
130+
126131
return create_dataset()
127132

128133

python/tests/test_expr.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from concurrent.futures import ThreadPoolExecutor
2020
from datetime import date, datetime, time, timezone
2121
from decimal import Decimal
22-
from unittest.mock import MagicMock
2322

2423
import arro3.core
2524
import nanoarrow
@@ -40,7 +39,6 @@
4039
BinaryExpr,
4140
Column,
4241
CopyTo,
43-
CreateExternalTable,
4442
CreateIndex,
4543
DescribeTable,
4644
DmlStatement,
@@ -70,17 +68,6 @@ def test_ctx():
7068
return ctx
7169

7270

73-
def test_create_external_table_location_is_deprecated():
74-
"""The singular location accessor delegates to locations()."""
75-
command = MagicMock()
76-
command.locations.return_value = ["first.csv", "second.csv"]
77-
78-
with pytest.warns(DeprecationWarning, match=r"location\(\).+deprecated"):
79-
location = CreateExternalTable.location(command)
80-
81-
assert location == "first.csv"
82-
83-
8471
def test_projection(test_ctx):
8572
df = test_ctx.sql("select c1, 123, c1 < 123 from test")
8673
plan = df.logical_plan()

0 commit comments

Comments
 (0)