Skip to content

Commit 72afd1c

Browse files
committed
refactor: simplify table registration logic by normalizing table provider
1 parent 2d4387c commit 72afd1c

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

python/datafusion/context.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
import pyarrow as pa
2626

27-
from datafusion import EXPECTED_PROVIDER_MSG
28-
2927
try:
3028
from warnings import deprecated # Python 3.13+
3129
except ImportError:
@@ -769,13 +767,8 @@ def register_table(
769767
implementing ``__datafusion_table_provider__`` to add to the session
770768
context.
771769
"""
772-
if isinstance(table, DataFrame):
773-
raise TypeError(EXPECTED_PROVIDER_MSG)
774-
775-
if isinstance(table, Table):
776-
self.ctx.register_table(name, table.table)
777-
else:
778-
self.ctx.register_table(name, table)
770+
provider = _normalize_table_provider(table)
771+
self.ctx.register_table(name, provider)
779772

780773
def deregister_table(self, name: str) -> None:
781774
"""Remove a table from the session."""

0 commit comments

Comments
 (0)