因此,對於這樣的事情:即使在指定了所有值的情況下,Spark SQL爲什麼在字符串列上可以爲空?
case class RandomClass(stringOne: String, stringTwo: String, numericOne: Int)
val ds = Seq(
RandomClass("a", null, 1),
RandomClass("a", "x", 3),
RandomClass("a", "y", 4),
RandomClass("a", null, 5)
).toDS()
ds.printSchema()
結果
root
|-- stringOne: string (nullable = true)
|-- stringTwo: string (nullable = true)
|-- numericOne: integer (nullable = false)
爲什麼會stringOne
是nullable?
奇怪的是,numericOne
正確的推斷。我假設我只是缺少關於數據集和DataFrame API之間關係的東西?