df = df.withColumnRenamed('mail', 'EmailAddress')
更改我声明为架构一部分的nulltype(声明为false)。有没有办法不让这种事情发生?
pyspark文档中什么都没有提及。
schema = StructType([StructField("mail", StringType(), False)])
df = spark.read.json(inputPath, schema = schema)
df = df.withColumnRenamed('mail', 'EmailAddress')
df.printSchema()
此输出:
|-- EmailAddress: string (nullable = true)