Class StructField

Object
org.apache.spark.sql.types.StructField
All Implemented Interfaces:
Serializable, scala.Equals, scala.Product, scala.Serializable

public class StructField extends Object implements scala.Product, scala.Serializable
A field inside a StructType. param: name The name of this field. param: dataType The data type of this field. param: nullable Indicates if values of this field can be null values. param: metadata The metadata of this field. The metadata should be preserved during transformation if the content of the column is not modified, e.g, in selection.

Since:
1.3.0
See Also:
  • Constructor Details

  • Method Details

    • apply

      public abstract static R apply(T1 v1, T2 v2, T3 v3, T4 v4)
    • name

      public String name()
    • dataType

      public DataType dataType()
    • nullable

      public boolean nullable()
    • metadata

      public Metadata metadata()
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • withComment

      public StructField withComment(String comment)
      Updates the StructField with a new comment value.
      Parameters:
      comment - (undocumented)
      Returns:
      (undocumented)
    • getComment

      public scala.Option<String> getComment()
      Return the comment of this StructField.
      Returns:
      (undocumented)
    • withCurrentDefaultValue

      public StructField withCurrentDefaultValue(String value)
      Updates the StructField with a new current default value.
      Parameters:
      value - (undocumented)
      Returns:
      (undocumented)
    • clearCurrentDefaultValue

      public StructField clearCurrentDefaultValue()
      Clears the StructField of its current default value, if any.
      Returns:
      (undocumented)
    • getCurrentDefaultValue

      public scala.Option<String> getCurrentDefaultValue()
      Return the current default value of this StructField.
      Returns:
      (undocumented)
    • withExistenceDefaultValue

      public StructField withExistenceDefaultValue(String value)
      Updates the StructField with a new existence default value.
      Parameters:
      value - (undocumented)
      Returns:
      (undocumented)
    • toDDL

      public String toDDL()
      Returns a string containing a schema in DDL format. For example, the following value: StructField("eventId", IntegerType, false) will be converted to eventId INT NOT NULL. StructField("eventId", IntegerType, true) will be converted to eventId INT.
      Returns:
      (undocumented)
      Since:
      2.4.0