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 TypeMethodDescriptionGet the datatype of the literal object.getValue()Get the literal value.static LiteralofBinary(byte[] value) Create abinarytype literal expression.static LiteralofBoolean(boolean value) Create abooleantype literal expression.static LiteralofByte(byte value) Create abytetype literal expression.static LiteralofDate(int daysSinceEpochUTC) Create adatetype literal expression.static LiteralofDecimal(BigDecimal value, int precision, int scale) Create adecimaltype literal expression.static LiteralofDouble(double value) Create adoubletype literal expression.static LiteralofFloat(float value) Create afloattype literal expression.static LiteralofInt(int value) Create aintegertype literal expression.static LiteralofLong(long value) Create alongtype literal expression.static LiteralCreatenullvalue literal.static LiteralofShort(short value) Create ashorttype literal expression.static LiteralCreate astringtype literal expression.static LiteralofTimestamp(long microsSinceEpochUTC) Create atimestamptype literal expression.static LiteralofTimestampNtz(long microSecondsEpoch) Create atimestamp_ntztype literal expression.toString()
-
Method Details
-
ofBoolean
Create abooleantype literal expression.- Parameters:
value- literal value- Returns:
- a
Literalof typeBooleanType
-
ofByte
Create abytetype literal expression. -
ofShort
Create ashorttype literal expression. -
ofInt
Create aintegertype literal expression.- Parameters:
value- literal value- Returns:
- a
Literalof typeIntegerType
-
ofLong
Create alongtype literal expression. -
ofFloat
Create afloattype literal expression. -
ofDouble
Create adoubletype literal expression.- Parameters:
value- literal value- Returns:
- a
Literalof typeDoubleType
-
ofString
Create astringtype literal expression.- Parameters:
value- literal value- Returns:
- a
Literalof typeStringType
-
ofBinary
Create abinarytype literal expression.- Parameters:
value- binary literal value as an array of bytes- Returns:
- a
Literalof typeBinaryType
-
ofDate
Create adatetype literal expression. -
ofTimestamp
Create atimestamptype literal expression.- Parameters:
microsSinceEpochUTC- microseconds since epoch time in UTC timezone.- Returns:
- a
Literalwith data typeTimestampType
-
ofTimestampNtz
Create atimestamp_ntztype literal expression.- Parameters:
microSecondsEpoch- Microseconds since epoch with no timezone.- Returns:
- a
Literalwith data typeTimestampNTZType
-
ofDecimal
Create adecimaltype literal expression.- Parameters:
value- decimal literal valueprecision- precision of the decimal literalscale- scale of the decimal literal- Returns:
- a
Literalwith data typeDecimalTypewith givenprecisionandscale.
-
ofNull
Createnullvalue literal. -
getValue
Get the literal value. If the value is null anullis 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:
Integerrepresents the number of days since epoch in UTC - TIMESTAMP:
Longrepresents the microseconds since epoch in UTC - TIMESTAMP_NTZ:
Longrepresents 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:
getChildrenin interfaceExpression- Returns:
- a list of expressions that are input to this expression.
-