我有一个我试图在模式中解析的 DF。但是,如果对象中的任何值为 null,则用于创建模式的类将跳过。
例子:
case class Parent(
Version: Int,
Info: InfoInstance
)
嵌套类如下:
case class InfoInstance(
FName: String ,
SName: String,
ID: Double,
ErrorCode: Int
)
因此,如果在 InfoInstance 中有任何机会,Fname 作为值是 null,它完全跳过键,并返回为
{ Sname: "abc", ID: 23123123, ErrorCode: 123 }
如果它为null,我希望它返回null。
{ FName: null, Sname: "abc", ID: 23123123, ErrorCode: 123 }
我在 spark 2.2 上,所以我不能使用 ignoreNullFields。我也尝试过使用 JSONInclude.Always,但即使这样也没有用。