nxcals.api.common.utils.array_utils.ArrayType.fromDDL
- classmethod ArrayType.fromDDL(ddl: str) DataType
Creates
DataTypefor a given DDL-formatted string.Added in version 4.0.0.
- Parameters:
ddl (str) – DDL-formatted string representation of types, e.g.
pyspark.sql.types.DataType.simpleString, except that top level struct type can omit thestruct<>for the compatibility reason withspark.createDataFrameand Python UDFs.- Return type:
Examples
Create a StructType by the corresponding DDL formatted string.
>>> from pyspark.sql.types import DataType >>> DataType.fromDDL("b string, a int") StructType([StructField('b', StringType(), True), StructField('a', IntegerType(), True)])
Create a single DataType by the corresponding DDL formatted string.
>>> DataType.fromDDL("decimal(10,10)") DecimalType(10,10)
Create a StructType by the legacy string format.
>>> DataType.fromDDL("b: string, a: int") StructType([StructField('b', StringType(), True), StructField('a', IntegerType(), True)])