File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,10 +118,6 @@ impl PyCreateExternalTable {
118118 Ok ( self . create . name . to_string ( ) )
119119 }
120120
121- pub fn location ( & self ) -> String {
122- self . create . locations . first ( ) . cloned ( ) . unwrap_or_default ( )
123- }
124-
125121 pub fn locations ( & self ) -> Vec < String > {
126122 self . create . locations . clone ( )
127123 }
Original file line number Diff line number Diff line change 4949from collections .abc import Callable , Iterable , Sequence
5050from typing import TYPE_CHECKING , Any , ClassVar
5151
52+ try :
53+ from warnings import deprecated # Python 3.13+
54+ except ImportError :
55+ from typing_extensions import deprecated # Python 3.12
56+
5257import pyarrow as pa
5358
5459from ._internal import expr as expr_internal
9095CreateCatalog = expr_internal .CreateCatalog
9196CreateCatalogSchema = expr_internal .CreateCatalogSchema
9297CreateExternalTable = expr_internal .CreateExternalTable
98+
99+
100+ @deprecated ("CreateExternalTable.location() is deprecated; use locations() instead." )
101+ def _create_external_table_location (self : Any ) -> str :
102+ """Return the first external table location.
103+
104+ Examples:
105+ >>> class Command:
106+ ... def locations(self) -> list[str]:
107+ ... return ["data.csv"]
108+ >>> _create_external_table_location(Command())
109+ 'data.csv'
110+ """
111+ locations = self .locations ()
112+ return locations [0 ] if locations else ""
113+
114+
115+ CreateExternalTable .location = _create_external_table_location
116+
93117CreateFunction = expr_internal .CreateFunction
94118CreateFunctionBody = expr_internal .CreateFunctionBody
95119CreateIndex = expr_internal .CreateIndex
Original file line number Diff line number Diff line change 1919from concurrent .futures import ThreadPoolExecutor
2020from datetime import date , datetime , time , timezone
2121from decimal import Decimal
22+ from unittest .mock import MagicMock
2223
2324import arro3 .core
2425import nanoarrow
3940 BinaryExpr ,
4041 Column ,
4142 CopyTo ,
43+ CreateExternalTable ,
4244 CreateIndex ,
4345 DescribeTable ,
4446 DmlStatement ,
@@ -68,6 +70,17 @@ def test_ctx():
6870 return ctx
6971
7072
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+
7184def test_projection (test_ctx ):
7285 df = test_ctx .sql ("select c1, 123, c1 < 123 from test" )
7386 plan = df .logical_plan ()
You can’t perform that action at this time.
0 commit comments