Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用pyspark中包含MapType的复杂架构创建数据帧_Python_Apache Spark_Pyspark - Fatal编程技术网

Python 使用pyspark中包含MapType的复杂架构创建数据帧

Python 使用pyspark中包含MapType的复杂架构创建数据帧,python,apache-spark,pyspark,Python,Apache Spark,Pyspark,我正在尝试使用以下架构创建数据帧: |-- data: struct (nullable = true) | |-- id: long (nullable = true) | |-- keyNote: struct (nullable = true) | | |-- key: string (nullable = true) | | |-- note: string (nullable = true) | |-- details: map (n

我正在尝试使用以下架构创建数据帧:

|-- 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)
这是我能做到的最好的事情:

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])
但我有个例外:

AssertionError:keyType应为数据类型


似乎您应该为MapType编写正确的语法:

MapType(StringType(), StringType(), True)

您编写的StringType没有括号,而不是StringType()

详细信息
中的
字符串类型
之后缺少
()
?始终共享整个错误消息。