Spark DataFrame Schema Nullable Fields

后端 未结 1 1676
星月不相逢
星月不相逢 2020-11-28 15:56

I wrote the following code in both Scala & Python, however the DataFrame that is returned doesn\'t appear to apply the non-nullable fields in my schema that I am applyin

相关标签:
1条回答
  • 2020-11-28 16:14

    In general Spark Datasets either inherit nullable property from its parents, or infer based on the external data types.

    You can argue if it is a good approach or not but ultimately it is sensible. If semantics of a data source doesn't support nullability constraints, then application of a schema cannot either. At the end of the day it is always better to assume that things can be null, than fail on the runtime if this the opposite assumption turns out to be incorrect.

    0 讨论(0)
提交回复
热议问题