Skip to content

Commit

Permalink
Try restore typing test
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmcook committed May 21, 2024
1 parent a8fc0e8 commit 55645a8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions python/pyspark/sql/tests/typing/test_session.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 55645a8

Please sign in to comment.