File tree 3 files changed +31
-2
lines changed
3 files changed +31
-2
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
@@ -195,12 +196,20 @@ def to_variant(self) -> Any:
195
196
"""Convert this expression into a python object if possible."""
196
197
return self .expr .to_variant ()
197
198
199
+ @deprecated ("display_name() is deprecated. Use :py:meth:`~Expr.schema_name` instead" )
198
200
def display_name (self ) -> str :
199
201
"""Returns the name of this expression as it should appear in a schema.
200
202
201
203
This name will not include any CAST expressions.
202
204
"""
203
- return self .expr .display_name ()
205
+ return self .schema_name ()
206
+
207
+ def schema_name (self ) -> str :
208
+ """Returns the name of this expression as it should appear in a schema.
209
+
210
+ This name will not include any CAST expressions.
211
+ """
212
+ return self .expr .schema_name ()
204
213
205
214
def canonical_name (self ) -> str :
206
215
"""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 @@ -189,7 +189,7 @@ impl PyExpr {
189
189
190
190
/// Returns the name of this expression as it should appear in a schema. This name
191
191
/// will not include any CAST expressions.
192
- fn display_name ( & self ) -> PyResult < String > {
192
+ fn schema_name ( & self ) -> PyResult < String > {
193
193
Ok ( format ! ( "{}" , self . expr. schema_name( ) ) )
194
194
}
195
195
You can’t perform that action at this time.
0 commit comments