From 55645a8f0ee1baa3c41b21f0f7a77110c761d49e Mon Sep 17 00:00:00 2001 From: Ian Cook Date: Tue, 21 May 2024 13:12:25 -0400 Subject: [PATCH] Try restore typing test --- python/pyspark/sql/tests/typing/test_session.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/python/pyspark/sql/tests/typing/test_session.yml b/python/pyspark/sql/tests/typing/test_session.yml index d6eee82a7678e..e481a5b3cbbbf 100644 --- a/python/pyspark/sql/tests/typing/test_session.yml +++ b/python/pyspark/sql/tests/typing/test_session.yml @@ -51,6 +51,21 @@ spark.createDataFrame(["foo", "bar"], "string") +- case: createDataFrameScalarsInvalid + main: | + from pyspark.sql import SparkSession + from pyspark.sql.types import StructType, StructField, StringType, IntegerType + spark = SparkSession.builder.getOrCreate() + schema = StructType([ + StructField("name", StringType(), True), + StructField("age", IntegerType(), True) + ]) + # Invalid - scalars require schema + spark.createDataFrame(["foo", "bar"]) # E: Value of type variable "RowLike" of "createDataFrame" of "SparkSession" cannot be "str" [type-var] + # Invalid - data has to match schema (either product -> struct or scalar -> atomic) + spark.createDataFrame([1, 2, 3], schema) # E: Value of type variable "RowLike" of "createDataFrame" of "SparkSession" cannot be "int" [type-var] + + - case: createDataFrameStructsInvalid main: | from pyspark.sql import SparkSession