Skip to content

Commit 7cc16e9

Browse files
committed
Add __repr__ where missing
1 parent 3535a99 commit 7cc16e9

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

python/datafusion/catalog.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ def __init__(self, catalog: df_internal.Catalog) -> None:
3434
"""This constructor is not typically called by the end user."""
3535
self.catalog = catalog
3636

37+
def __repr__(self) -> str:
38+
"""Print a string representation of the catalog."""
39+
self.catalog.__repr__()
40+
3741
def names(self) -> list[str]:
3842
"""Returns the list of databases in this catalog."""
3943
return self.catalog.names()
@@ -50,6 +54,10 @@ def __init__(self, db: df_internal.Database) -> None:
5054
"""This constructor is not typically called by the end user."""
5155
self.db = db
5256

57+
def __repr__(self) -> str:
58+
"""Print a string representation of the database."""
59+
self.db.__repr__()
60+
5361
def names(self) -> set[str]:
5462
"""Returns the list of all tables in this database."""
5563
return self.db.names()
@@ -66,6 +74,10 @@ def __init__(self, table: df_internal.Table) -> None:
6674
"""This constructor is not typically called by the end user."""
6775
self.table = table
6876

77+
def __repr__(self) -> str:
78+
"""Print a string representation of the table."""
79+
self.table.__repr__()
80+
6981
@property
7082
def schema(self) -> pa.Schema:
7183
"""Returns the schema associated with this table."""

python/datafusion/context.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,10 @@ def __init__(
496496

497497
self.ctx = SessionContextInternal(config, runtime)
498498

499+
def __repr__(self) -> str:
500+
"""Print a string representation of the Session Context."""
501+
self.ctx.__repr__()
502+
499503
@classmethod
500504
def global_ctx(cls) -> SessionContext:
501505
"""Retrieve the global context as a `SessionContext` wrapper.

python/datafusion/expr.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,10 @@ def __init__(
11721172
end_bound = end_bound.cast(pa.uint64())
11731173
self.window_frame = expr_internal.WindowFrame(units, start_bound, end_bound)
11741174

1175+
def __repr__(self) -> str:
1176+
"""Print a string representation of the window frame."""
1177+
self.window_frame.__repr__()
1178+
11751179
def get_frame_units(self) -> str:
11761180
"""Returns the window frame units for the bounds."""
11771181
return self.window_frame.get_frame_units()

python/datafusion/user_defined.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ def __init__(
102102
name, func, input_types, return_type, str(volatility)
103103
)
104104

105+
def __repr__(self) -> str:
106+
"""Print a string representation of the Scalar UDF."""
107+
self._udf.__repr__()
108+
105109
def __call__(self, *args: Expr) -> Expr:
106110
"""Execute the UDF.
107111
@@ -268,6 +272,10 @@ def __init__(
268272
str(volatility),
269273
)
270274

275+
def __repr__(self) -> str:
276+
"""Print a string representation of the Aggregate UDF."""
277+
self._udaf.__repr__()
278+
271279
def __call__(self, *args: Expr) -> Expr:
272280
"""Execute the UDAF.
273281
@@ -604,6 +612,10 @@ def __init__(
604612
name, func, input_types, return_type, str(volatility)
605613
)
606614

615+
def __repr__(self) -> str:
616+
"""Print a string representation of the Window UDF."""
617+
self._udwf.__repr__()
618+
607619
def __call__(self, *args: Expr) -> Expr:
608620
"""Execute the UDWF.
609621

0 commit comments

Comments
 (0)