Apache spark Spark DataFrame-应用模式显示nullable always true
我正在尝试为我的一个json文件应用模式。无论我是否在模式中为这个特定的字段Apache spark Spark DataFrame-应用模式显示nullable always true,apache-spark,databricks,Apache Spark,Databricks,我正在尝试为我的一个json文件应用模式。无论我是否在模式中为这个特定的字段true或false提供了null,当我在我的文件上应用该模式时,该字段仅为null 模式 val schema = StructType( List( StructField("SMS", StringType, false) ) ) 输出 schema: org.apache.spark.sql.types.StructType = StructType(StructField(S
true
或false
提供了null,当我在我的文件上应用该模式时,该字段仅为null
模式
val schema = StructType(
List(
StructField("SMS", StringType, false)
)
)
输出
schema: org.apache.spark.sql.types.StructType = StructType(StructField(SMS,StringType,false))
root
|-- SMS: string (nullable = true)
在文件上应用架构
val SMSDF=spark.read.schema(schema.json)(“/mnt/aaa/log*”)
SMSDF.printSchema()
输出
schema: org.apache.spark.sql.types.StructType = StructType(StructField(SMS,StringType,false))
root
|-- SMS: string (nullable = true)
我正在使用Spark 2.4.3、Scala 2.11