You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/10/17 00:51:59 UTC

[GitHub] [spark] zero323 commented on a change in pull request #34146: [SPARK-36894][PYTHON] Synchronize RDD.toDF annotations with SparkSession.createDataFrame variants.

zero323 commented on a change in pull request #34146:
URL: https://github.com/apache/spark/pull/34146#discussion_r730054319



##########
File path: python/pyspark/sql/session.py
##########
@@ -646,23 +647,14 @@ def createDataFrame(
     def createDataFrame(
         self,
         data: Union[
-            "RDD[Union[DateTimeLiteral, LiteralType, DecimalLiteral]]",
-            Iterable[Union["DateTimeLiteral", "LiteralType", "DecimalLiteral"]],
+            "RDD[AtomicValue]",
+            Iterable[AtomicValue],
         ],
         schema: Union[AtomicType, str],
         verifySchema: bool = ...,
     ) -> DataFrame:
         ...
 
-    @overload
-    def createDataFrame(
-        self,
-        data: Union["RDD[RowLike]", Iterable["RowLike"]],
-        schema: Union[StructType, str],
-        verifySchema: bool = ...,
-    ) -> DataFrame:
-        ...

Review comment:
       This is not an applicable variant ‒ if schema is `Union[StructType, str]` schema is inferred and only the names are used. 

##########
File path: python/pyspark/sql/_typing.pyi
##########
@@ -42,6 +42,8 @@ AtomicDataTypeOrString = Union[pyspark.sql.types.AtomicType, str]
 DataTypeOrString = Union[pyspark.sql.types.DataType, str]
 OptionalPrimitiveType = Optional[PrimitiveType]
 
+AtomicValue = TypeVar("AtomicValue", datetime.datetime, datetime.date, decimal.Decimal, bool, str, int, float)

Review comment:
       Should it be covariant?




-- 
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-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org