nxcals.api.common.utils.array_utils.ArrayType.toNullable

ArrayType.toNullable() → ArrayType

Returns the same data type but set all nullability fields are true (StructField.nullable, ArrayType.containsNull, and MapType.valueContainsNull).

Added in version 4.0.0.

Return type:

ArrayType

Examples

Example 1: Simple nullability conversion

>>> ArrayType(IntegerType(), containsNull=False).toNullable()
ArrayType(IntegerType(), True)

Example 2: Nested nullability conversion

>>> ArrayType(
...     StructType([
...         StructField("b", IntegerType(), nullable=False),
...         StructField("c", ArrayType(IntegerType(), containsNull=False))
...     ]),
...     containsNull=False
... ).toNullable()
ArrayType(StructType([StructField('b', IntegerType(), True),
StructField('c', ArrayType(IntegerType(), True), True)]), True)