Skip to content

Commit 41254de

Browse files
HyukjinKwonasl3
authored andcommitted
Revert "[SPARK-52698][PYTHON] Improve type hints for datasource module"
This reverts commit a9b8e37.
1 parent cec674a commit 41254de

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

python/pyspark/sql/datasource.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
from dataclasses import dataclass
2020
from typing import (
2121
Any,
22+
Dict,
2223
Iterable,
2324
Iterator,
2425
List,
2526
Optional,
2627
Sequence,
28+
Tuple,
2729
Type,
30+
Union,
2831
TYPE_CHECKING,
2932
)
3033

@@ -46,6 +49,7 @@
4649
"DataSourceStreamWriter",
4750
"DataSourceRegistration",
4851
"InputPartition",
52+
"SimpleDataSourceStreamReader",
4953
"WriterCommitMessage",
5054
"Filter",
5155
"EqualTo",
@@ -80,7 +84,7 @@ class DataSource(ABC):
8084
.. versionadded: 4.0.0
8185
"""
8286

83-
def __init__(self, options: dict[str, str]) -> None:
87+
def __init__(self, options: Dict[str, str]) -> None:
8488
"""
8589
Initializes the data source with user-provided options.
8690
@@ -110,7 +114,7 @@ def name(cls) -> str:
110114
"""
111115
return cls.__name__
112116

113-
def schema(self) -> StructType | str:
117+
def schema(self) -> Union[StructType, str]:
114118
"""
115119
Returns the schema of the data source.
116120
@@ -257,7 +261,7 @@ def streamReader(self, schema: StructType) -> "DataSourceStreamReader":
257261
)
258262

259263

260-
ColumnPath = tuple[str, ...]
264+
ColumnPath = Tuple[str, ...]
261265
"""
262266
A tuple of strings representing a column reference.
263267
@@ -403,7 +407,7 @@ class In(Filter):
403407
"""
404408

405409
attribute: ColumnPath
406-
value: tuple[Any, ...]
410+
value: Tuple[Any, ...]
407411

408412

409413
@dataclass(frozen=True)
@@ -627,7 +631,7 @@ def partitions(self) -> Sequence[InputPartition]:
627631
)
628632

629633
@abstractmethod
630-
def read(self, partition: InputPartition) -> Iterator[tuple] | Iterator["RecordBatch"]:
634+
def read(self, partition: InputPartition) -> Union[Iterator[Tuple], Iterator["RecordBatch"]]:
631635
"""
632636
Generates data for a given partition and returns an iterator of tuples or rows.
633637
@@ -756,7 +760,7 @@ def partitions(self, start: dict, end: dict) -> Sequence[InputPartition]:
756760
)
757761

758762
@abstractmethod
759-
def read(self, partition: InputPartition) -> Iterator[tuple] | Iterator["RecordBatch"]:
763+
def read(self, partition: InputPartition) -> Union[Iterator[Tuple], Iterator["RecordBatch"]]:
760764
"""
761765
Generates data for a given partition and returns an iterator of tuples or rows.
762766
@@ -848,7 +852,7 @@ def initialOffset(self) -> dict:
848852
messageParameters={"feature": "initialOffset"},
849853
)
850854

851-
def read(self, start: dict) -> tuple[Iterator[tuple], dict]:
855+
def read(self, start: dict) -> Tuple[Iterator[Tuple], dict]:
852856
"""
853857
Read all available data from start offset and return the offset that next read attempt
854858
starts from.
@@ -860,7 +864,7 @@ def read(self, start: dict) -> tuple[Iterator[tuple], dict]:
860864
861865
Returns
862866
-------
863-
A :class:`tuple` of an iterator of :class:`tuple` and a dict\\s
867+
A :class:`Tuple` of an iterator of :class:`Tuple` and a dict\\s
864868
The iterator contains all the available records after start offset.
865869
The dict is the end offset of this read attempt and the start of next read attempt.
866870
"""
@@ -869,7 +873,7 @@ def read(self, start: dict) -> tuple[Iterator[tuple], dict]:
869873
messageParameters={"feature": "read"},
870874
)
871875

872-
def readBetweenOffsets(self, start: dict, end: dict) -> Iterator[tuple]:
876+
def readBetweenOffsets(self, start: dict, end: dict) -> Iterator[Tuple]:
873877
"""
874878
Read all available data from specific start offset and end offset.
875879
This is invoked during failure recovery to re-read a batch deterministically.
@@ -884,7 +888,7 @@ def readBetweenOffsets(self, start: dict, end: dict) -> Iterator[tuple]:
884888
885889
Returns
886890
-------
887-
iterator of :class:`tuple`\\s
891+
iterator of :class:`Tuple`\\s
888892
All the records between start offset and end offset.
889893
"""
890894
raise PySparkNotImplementedError(

0 commit comments

Comments
 (0)