xinrong-databricks commented on a change in pull request #34101: URL: https://github.com/apache/spark/pull/34101#discussion_r717822966
########## File path: python/pyspark/sql/pandas/conversion.py ########## @@ -301,27 +314,50 @@ class SparkConversionMixin(object): Min-in for the conversion from pandas to Spark. Currently, only :class:`SparkSession` can use this class. """ - def createDataFrame(self, data, schema=None, samplingRatio=None, verifySchema=True): + + @overload + def createDataFrame( + self, data: "PandasDataFrameLike", samplingRatio: Optional[float] = ... + ) -> "DataFrame": + ... + + @overload + def createDataFrame( + self, + data: "PandasDataFrameLike", + schema: Union[StructType, str], + verifySchema: bool = ..., + ) -> "DataFrame": + ... + + def createDataFrame( # type: ignore[misc] Review comment: Since we have `@overload`s, do we have to annotate the original function, here `createDataFrame`? ########## File path: python/pyspark/sql/pandas/conversion.py ########## @@ -301,27 +314,50 @@ class SparkConversionMixin(object): Min-in for the conversion from pandas to Spark. Currently, only :class:`SparkSession` can use this class. """ - def createDataFrame(self, data, schema=None, samplingRatio=None, verifySchema=True): + + @overload + def createDataFrame( + self, data: "PandasDataFrameLike", samplingRatio: Optional[float] = ... + ) -> "DataFrame": + ... + + @overload + def createDataFrame( + self, + data: "PandasDataFrameLike", + schema: Union[StructType, str], + verifySchema: bool = ..., + ) -> "DataFrame": + ... + + def createDataFrame( # type: ignore[misc] Review comment: Since we have `@overload`s, do we have to annotate the original function here for `createDataFrame`? Can we simply ignore the `[no-untyped-def]` here? ########## File path: python/pyspark/sql/pandas/conversion.py ########## @@ -301,27 +314,50 @@ class SparkConversionMixin(object): Min-in for the conversion from pandas to Spark. Currently, only :class:`SparkSession` can use this class. """ - def createDataFrame(self, data, schema=None, samplingRatio=None, verifySchema=True): + + @overload + def createDataFrame( + self, data: "PandasDataFrameLike", samplingRatio: Optional[float] = ... + ) -> "DataFrame": + ... + + @overload + def createDataFrame( + self, + data: "PandasDataFrameLike", + schema: Union[StructType, str], + verifySchema: bool = ..., + ) -> "DataFrame": + ... + + def createDataFrame( # type: ignore[misc] Review comment: Since we have `@overload`s, do we have to annotate the original function here for `createDataFrame`? Can we simply ignore the `[no-untyped-def]` here? -- 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: reviews-unsubscr...@spark.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org