No-arg constructor for kryo.
Creates a new StructType by adding a new field and specifying metadata where the dataType is specified as a String.
Creates a new StructType by adding a new field and specifying metadata where the dataType is specified as a String.
val struct = (new StructType) .add("a", "int", true, "comment1") .add("b", "long", false, "comment2") .add("c", "string", true, "comment3")
Creates a new StructType by adding a new field and specifying metadata where the dataType is specified as a String.
Creates a new StructType by adding a new field and specifying metadata where the dataType is specified as a String.
val struct = (new StructType) .add("a", "int", true, Metadata.empty) .add("b", "long", false, Metadata.empty) .add("c", "string", true, Metadata.empty)
Creates a new StructType by adding a new field with no metadata where the dataType is specified as a String.
Creates a new StructType by adding a new field with no metadata where the dataType is specified as a String.
val struct = (new StructType) .add("a", "int", true) .add("b", "long", false) .add("c", "string", true)
Creates a new StructType by adding a new nullable field with no metadata where the dataType is specified as a String.
Creates a new StructType by adding a new nullable field with no metadata where the dataType is specified as a String.
val struct = (new StructType) .add("a", "int") .add("b", "long") .add("c", "string")
Creates a new StructType by adding a new field and specifying metadata.
Creates a new StructType by adding a new field and specifying metadata.
val struct = (new StructType) .add("a", IntegerType, true, "comment1") .add("b", LongType, false, "comment2") .add("c", StringType, true, "comment3")
Creates a new StructType by adding a new field and specifying metadata.
Creates a new StructType by adding a new field and specifying metadata.
val struct = (new StructType) .add("a", IntegerType, true, Metadata.empty) .add("b", LongType, false, Metadata.empty) .add("c", StringType, true, Metadata.empty)
Creates a new StructType by adding a new field with no metadata.
Creates a new StructType by adding a new field with no metadata.
val struct = (new StructType) .add("a", IntegerType, true) .add("b", LongType, false) .add("c", StringType, true)
Creates a new StructType by adding a new nullable field with no metadata.
Creates a new StructType by adding a new nullable field with no metadata.
val struct = (new StructType) .add("a", IntegerType) .add("b", LongType) .add("c", StringType)
Creates a new StructType by adding a new field.
Creates a new StructType by adding a new field.
val struct = (new StructType) .add(StructField("a", IntegerType, true)) .add(StructField("b", LongType, false)) .add(StructField("c", StringType, true))
Returns a StructType containing StructFields of the given names, preserving the original order of fields.
Returns a StructType containing StructFields of the given names, preserving the original order of fields.
IllegalArgumentException
if a field cannot be found for any of the given names
Extracts the StructField with the given name.
Extracts the StructField with the given name.
IllegalArgumentException
if a field with the given name does not exist
String representation for the type saved in external catalogs.
String representation for the type saved in external catalogs.
The default size of a value of the StructType is the total default sizes of all field types.
The default size of a value of the StructType is the total default sizes of all field types.
Returns the index of a given field.
Returns the index of a given field.
IllegalArgumentException
if a field with the given name does not exist
Returns all field names in an array.
The compact JSON representation of this data type.
The compact JSON representation of this data type.
Returns all field names in an array.
Returns all field names in an array. This is an alias of fieldNames
.
2.4.0
The pretty (i.e.
The pretty (i.e. indented) JSON representation of this data type.
(Changed in version 2.9.0) The behavior of scanRight
has changed. The previous behavior can be reproduced with scanRight.reverse.
Readable string representation for the type.
Readable string representation for the type.
Returns a string containing a schema in DDL format.
Returns a string containing a schema in DDL format. For example, the following value:
StructType(Seq(StructField("eventId", IntegerType), StructField("s", StringType)))
will be converted to eventId
INT, s
STRING.
The returned DDL schema can be used in a table creation.
2.4.0
(Changed in version 2.9.0) transpose
throws an IllegalArgumentException
if collections are not uniformly sized.
Name of the type used in JSON serialization.
Name of the type used in JSON serialization.
A StructType object can be constructed by
StructType(fields: Seq[StructField])
For a StructType object, one or multiple StructFields can be extracted by names. If multiple StructFields are extracted, a StructType object will be returned. If a provided name does not have a matching field, it will be ignored. For the case of extracting a single StructField, a
null
will be returned.Scala Example:
A org.apache.spark.sql.Row object is used as a value of the StructType.
Scala Example:
1.3.0