I'm trying to create a dataframe with the following schema:
|-- data: struct (nullable = true) | |-- id: long (nullable = true) | |-- keyNote: struct (nullable = true) | | |-- key: string (nullable = true) | | |-- note: string (nullable = true) | |-- details: map (nullable = true) | | |-- key: string | | |-- value: string (valueContainsNull = true) This is the best I managed to do:
schema = StructType([ StructField("id",LongType(), True), StructField("keyNote",StructType([ StructField("key",StringType(),True), StructField("note",StringType(),True) ])), StructField("details",MapType(StringType, StringType, True)) ]) df = spark\ .createDataFrame([("idd",("keyy","notee"),("keyy","valuee")),schema]) But I'm getting an exception:
AssertionError: keyType should be DataType
()afterStringTypeindetails?