Skip to content

Commit 0ef9c4b

Browse files
committed
fix: update TableLike type alias to use Union for compatibility with Python 3.9
1 parent a4b94f9 commit 0ef9c4b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

python/datafusion/context.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from __future__ import annotations
2121

2222
import warnings
23-
from typing import TYPE_CHECKING, Any, Protocol
23+
from typing import TYPE_CHECKING, Any, Protocol, Union
2424

2525
try:
2626
from warnings import deprecated # Python 3.13+
@@ -83,7 +83,10 @@ def __datafusion_table_provider__(self) -> object: ... # noqa: D105
8383

8484

8585
# Type alias for objects accepted by read_table
86-
TableLike = Table | TableProviderExportable
86+
# Use typing.Union here (instead of PEP 604 `|`) because this alias is
87+
# evaluated at import time and must work on Python 3.9 where PEP 604
88+
# syntax is not supported for runtime expressions.
89+
TableLike = Union[Table, TableProviderExportable]
8790

8891

8992
class CatalogProviderExportable(Protocol):

0 commit comments

Comments
 (0)