Vamsi-klu commented on code in PR #58191:
URL: https://github.com/apache/spark/pull/58191#discussion_r3828875707


##########
python/pyspark/sql/datasource_internal.py:
##########
@@ -162,11 +162,11 @@ def getCache(self, start: dict, end: dict) -> 
Optional[Iterator[Tuple]]:
         it = chain(*entries)
         return it
 
-    def read(
-        self,
-        input_partition: SimpleInputPartition,  # type: ignore[override]
-    ) -> Iterator[Tuple]:
-        return self.simple_reader.readBetweenOffsets(input_partition.start, 
input_partition.end)
+    def read(self, partition: InputPartition) -> Iterator[Tuple]:
+        assert isinstance(partition, SimpleInputPartition), (
+            "simple stream reader wrapper only accepts SimpleInputPartition"
+        )

Review Comment:
   Agreed. The runtime assert was a poor stand-in for the old 
`SimpleInputPartition` parameter.
   
   mypy treats method parameters as contravariant, so the override has to 
accept `InputPartition`. `partitions()` only yields `SimpleInputPartition`, so 
this now uses `cast` and leaves runtime behavior unchanged.
   
   cc @gaogaotiantian 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to