Class Literal

Object
io.delta.kernel.expressions.Literal
All Implemented Interfaces:
Expression

@Evolving public final class Literal extends Object implements Expression
A literal value.

Definition:

Since:
3.0.0
  • Method Details

    • ofBoolean

      public static Literal ofBoolean(boolean value)
      Create a boolean type literal expression.
      Parameters:
      value - literal value
      Returns:
      a Literal of type BooleanType
    • ofByte

      public static Literal ofByte(byte value)
      Create a byte type literal expression.
      Parameters:
      value - literal value
      Returns:
      a Literal of type ByteType
    • ofShort

      public static Literal ofShort(short value)
      Create a short type literal expression.
      Parameters:
      value - literal value
      Returns:
      a Literal of type ShortType
    • ofInt

      public static Literal ofInt(int value)
      Create a integer type literal expression.
      Parameters:
      value - literal value
      Returns:
      a Literal of type IntegerType
    • ofLong

      public static Literal ofLong(long value)
      Create a long type literal expression.
      Parameters:
      value - literal value
      Returns:
      a Literal of type LongType
    • ofFloat

      public static Literal ofFloat(float value)
      Create a float type literal expression.
      Parameters:
      value - literal value
      Returns:
      a Literal of type FloatType
    • ofDouble

      public static Literal ofDouble(double value)
      Create a double type literal expression.
      Parameters:
      value - literal value
      Returns:
      a Literal of type DoubleType
    • ofString

      public static Literal ofString(String value)
      Create a string type literal expression.
      Parameters:
      value - literal value
      Returns:
      a Literal of type StringType
    • ofBinary

      public static Literal ofBinary(byte[] value)
      Create a binary type literal expression.
      Parameters:
      value - binary literal value as an array of bytes
      Returns:
      a Literal of type BinaryType
    • ofDate

      public static Literal ofDate(int daysSinceEpochUTC)
      Create a date type literal expression.
      Parameters:
      daysSinceEpochUTC - number of days since the epoch in UTC timezone.
      Returns:
      a Literal of type DateType
    • ofTimestamp

      public static Literal ofTimestamp(long microsSinceEpochUTC)
      Create a timestamp type literal expression.
      Parameters:
      microsSinceEpochUTC - microseconds since epoch time in UTC timezone.
      Returns:
      a Literal with data type TimestampType
    • ofTimestampNtz

      public static Literal ofTimestampNtz(long microSecondsEpoch)
      Create a timestamp_ntz type literal expression.
      Parameters:
      microSecondsEpoch - Microseconds since epoch with no timezone.
      Returns:
      a Literal with data type TimestampNTZType
    • ofDecimal

      public static Literal ofDecimal(BigDecimal value, int precision, int scale)
      Create a decimal type literal expression.
      Parameters:
      value - decimal literal value
      precision - precision of the decimal literal
      scale - scale of the decimal literal
      Returns:
      a Literal with data type DecimalType with given precision and scale.
    • ofNull

      public static Literal ofNull(DataType dataType)
      Create null value literal.
      Parameters:
      dataType - DataType of the null literal.
      Returns:
      a null Literal with the given data type
    • getValue

      public Object getValue()
      Get the literal value. If the value is null a null is returned. For non-null literal the returned value is one of the following types based on the literal data type.
      Returns:
      Literal value.
    • getDataType

      public DataType getDataType()
      Get the datatype of the literal object. Datatype lets the caller interpret the value of the literal object returned by getValue()
      Returns:
      Datatype of the literal object.
    • toString

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

      public List<Expression> getChildren()
      Specified by:
      getChildren in interface Expression
      Returns:
      a list of expressions that are input to this expression.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object