Class StringType


@Evolving public class StringType extends BasePrimitiveType
The data type representing string type values.
Since:
3.0.0
  • Field Details

  • Constructor Details

    • StringType

      public StringType(CollationIdentifier collationIdentifier)
      Parameters:
      collationIdentifier - An identifier representing the collation to be used for string comparison and sorting. This determines how strings will be ordered and compared in query operations.
    • StringType

      public StringType(String collationName)
      Parameters:
      collationName - name of collation in which this StringType will be observed. In form of PROVIDER.COLLATION_NAME[.VERSION]
  • Method Details

    • getCollationIdentifier

      public CollationIdentifier getCollationIdentifier()
      Returns:
      StringType's collation identifier
    • equivalent

      public boolean equivalent(DataType dataType)
      Are the data types same? The metadata, collations or column names could be different.
      Overrides:
      equivalent in class DataType
      Parameters:
      dataType -
      Returns:
    • isWriteCompatible

      public boolean isWriteCompatible(DataType dataType)
      Checks whether the given dataType is compatible with this type when writing data. Collation differences are ignored.

      This method is intended to be used during the write path to validate that an input type matches the expected schema before data is written.

      It should not be used in other cases, such as the read path.

      Overrides:
      isWriteCompatible in class DataType
      Parameters:
      dataType - the input data type being written
      Returns:
      true if the input type is compatible with this type.
    • isUTF8BinaryCollated

      public boolean isUTF8BinaryCollated()
      Returns:
      true if this StringType uses the default Spark UTF8_BINARY collation.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class BasePrimitiveType
    • toString

      public String toString()
      Override is needed because toString() may be used for schema serialization and similar contexts, so collation information must be included.
      Overrides:
      toString in class BasePrimitiveType
      Returns:
      string representation of the StringType.