File tree 3 files changed +32
-3
lines changed
3 files changed +32
-3
lines changed Original file line number Diff line number Diff line change 29
29
)
30
30
from datafusion .common import NullTreatment , RexType , DataTypeMap
31
31
from typing import Any , Optional , Type
32
+ from typing_extensions import deprecated
32
33
import pyarrow as pa
33
34
34
35
# The following are imported from the internal representation. We may choose to
@@ -174,12 +175,20 @@ def to_variant(self) -> Any:
174
175
"""Convert this expression into a python object if possible."""
175
176
return self .expr .to_variant ()
176
177
178
+ @deprecated (since = "41.0.0" , message = "Use :py:meth:`~Expr.schema_name` instead" )
177
179
def display_name (self ) -> str :
178
180
"""Returns the name of this expression as it should appear in a schema.
179
181
180
182
This name will not include any CAST expressions.
181
183
"""
182
- return self .expr .display_name ()
184
+ return self .schema_name ()
185
+
186
+ def schema_name (self ) -> str :
187
+ """Returns the name of this expression as it should appear in a schema.
188
+
189
+ This name will not include any CAST expressions.
190
+ """
191
+ return self .expr .schema_name ()
183
192
184
193
def canonical_name (self ) -> str :
185
194
"""Returns a complete string representation of this expression."""
Original file line number Diff line number Diff line change @@ -192,3 +192,23 @@ def test_expr_getitem() -> None:
192
192
193
193
assert names == ["Alice" , "Bob" , "Charlie" , None ]
194
194
assert array_values == [2 , 5 , None , None ]
195
+
196
+
197
+ def test_display_name_deprecation ():
198
+ import warnings
199
+ expr = col ("foo" )
200
+ with warnings .catch_warnings (record = True ) as w :
201
+ # Cause all warnings to always be triggered
202
+ warnings .simplefilter ("always" )
203
+
204
+ # should trigger warning
205
+ name = expr .display_name ()
206
+
207
+ # Verify some things
208
+ assert len (w ) == 1
209
+ assert issubclass (w [- 1 ].category , DeprecationWarning )
210
+ assert "deprecated" in str (w [- 1 ].message )
211
+
212
+ # returns appropriate result
213
+ assert name == expr .schema_name ()
214
+ assert name == "foo"
Original file line number Diff line number Diff line change @@ -188,8 +188,8 @@ impl PyExpr {
188
188
189
189
/// Returns the name of this expression as it should appear in a schema. This name
190
190
/// will not include any CAST expressions.
191
- fn display_name ( & self ) -> PyResult < String > {
192
- Ok ( self . expr . display_name ( ) ? )
191
+ fn schema_name ( & self ) -> PyResult < String > {
192
+ Ok ( format ! ( "{}" , self . expr. schema_name ( ) ) )
193
193
}
194
194
195
195
/// Returns a full and complete string representation of this expression.
You can’t perform that action at this time.
0 commit comments