Package io.delta.kernel.expressions
Class Literal
Object
io.delta.kernel.expressions.Literal
- All Implemented Interfaces:
Expression
A literal value.
Definition:
- Represents literal of primitive types as defined in the protocol Delta Transaction Log Protocol: Primitive Types
- Use
getValue()
to fetch the literal value. Returned value type depends on the type of the literal data type. See thegetValue()
for further details.
- Since:
- 3.0.0
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Get the datatype of the literal object.getValue()
Get the literal value.static Literal
ofBinary
(byte[] value) Create abinary
type literal expression.static Literal
ofBoolean
(boolean value) Create aboolean
type literal expression.static Literal
ofByte
(byte value) Create abyte
type literal expression.static Literal
ofDate
(int daysSinceEpochUTC) Create adate
type literal expression.static Literal
ofDecimal
(BigDecimal value, int precision, int scale) Create adecimal
type literal expression.static Literal
ofDouble
(double value) Create adouble
type literal expression.static Literal
ofFloat
(float value) Create afloat
type literal expression.static Literal
ofInt
(int value) Create ainteger
type literal expression.static Literal
ofLong
(long value) Create along
type literal expression.static Literal
Createnull
value literal.static Literal
ofShort
(short value) Create ashort
type literal expression.static Literal
Create astring
type literal expression.static Literal
ofTimestamp
(long microsSinceEpochUTC) Create atimestamp
type literal expression.static Literal
ofTimestampNtz
(long microSecondsEpoch) Create atimestamp_ntz
type literal expression.toString()
-
Method Details
-
ofBoolean
Create aboolean
type literal expression.- Parameters:
value
- literal value- Returns:
- a
Literal
of typeBooleanType
-
ofByte
Create abyte
type literal expression. -
ofShort
Create ashort
type literal expression. -
ofInt
Create ainteger
type literal expression.- Parameters:
value
- literal value- Returns:
- a
Literal
of typeIntegerType
-
ofLong
Create along
type literal expression. -
ofFloat
Create afloat
type literal expression. -
ofDouble
Create adouble
type literal expression.- Parameters:
value
- literal value- Returns:
- a
Literal
of typeDoubleType
-
ofString
Create astring
type literal expression.- Parameters:
value
- literal value- Returns:
- a
Literal
of typeStringType
-
ofBinary
Create abinary
type literal expression.- Parameters:
value
- binary literal value as an array of bytes- Returns:
- a
Literal
of typeBinaryType
-
ofDate
Create adate
type literal expression. -
ofTimestamp
Create atimestamp
type literal expression.- Parameters:
microsSinceEpochUTC
- microseconds since epoch time in UTC timezone.- Returns:
- a
Literal
with data typeTimestampType
-
ofTimestampNtz
Create atimestamp_ntz
type literal expression.- Parameters:
microSecondsEpoch
- Microseconds since epoch with no timezone.- Returns:
- a
Literal
with data typeTimestampNTZType
-
ofDecimal
Create adecimal
type literal expression.- Parameters:
value
- decimal literal valueprecision
- precision of the decimal literalscale
- scale of the decimal literal- Returns:
- a
Literal
with data typeDecimalType
with givenprecision
andscale
.
-
ofNull
Createnull
value literal. -
getValue
Get the literal value. If the value is null anull
is returned. For non-null literal the returned value is one of the following types based on the literal data type.- BOOLEAN:
Boolean
- BYTE:
Byte
- SHORT:
Short
- INTEGER:
Integer
- LONG:
Long
- FLOAT:
Float
- DOUBLE:
Double
- DATE:
Integer
represents the number of days since epoch in UTC - TIMESTAMP:
Long
represents the microseconds since epoch in UTC - TIMESTAMP_NTZ:
Long
represents the microseconds since epoch with no timezone - DECIMAL:
BigDecimal
.UsegetDataType()
to find the precision and scale
- Returns:
- Literal value.
- BOOLEAN:
-
getDataType
Get the datatype of the literal object. Datatype lets the caller interpret the value of the literal object returned bygetValue()
- Returns:
- Datatype of the literal object.
-
toString
-
getChildren
- Specified by:
getChildren
in interfaceExpression
- Returns:
- a list of expressions that are input to this expression.
-
equals
-