File tree Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Expand file tree Collapse file tree 3 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 2929)
3030from datafusion .common import NullTreatment , RexType , DataTypeMap
3131from typing import Any , Optional , Type
32+ from typing_extensions import deprecated
3233import pyarrow as pa
3334
3435# The following are imported from the internal representation. We may choose to
@@ -195,12 +196,20 @@ def to_variant(self) -> Any:
195196 """Convert this expression into a python object if possible."""
196197 return self .expr .to_variant ()
197198
199+ @deprecated ("display_name() is deprecated. Use :py:meth:`~Expr.schema_name` instead" )
198200 def display_name (self ) -> str :
199201 """Returns the name of this expression as it should appear in a schema.
200202
201203 This name will not include any CAST expressions.
202204 """
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 ()
204213
205214 def canonical_name (self ) -> str :
206215 """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:
192192
193193 assert names == ["Alice" , "Bob" , "Charlie" , None ]
194194 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 {
189189
190190 /// Returns the name of this expression as it should appear in a schema. This name
191191 /// will not include any CAST expressions.
192- fn display_name ( & self ) -> PyResult < String > {
192+ fn schema_name ( & self ) -> PyResult < String > {
193193 Ok ( format ! ( "{}" , self . expr. schema_name( ) ) )
194194 }
195195
You can’t perform that action at this time.
0 commit comments