Class ValueLiteralExpression
- java.lang.Object
-
- org.apache.flink.table.expressions.ValueLiteralExpression
-
- All Implemented Interfaces:
Expression
,ResolvedExpression
@PublicEvolving public final class ValueLiteralExpression extends Object implements ResolvedExpression
Expression for constant literal values.By design, this class can take any value described by a
DataType
. However, it is recommended to use instances with default conversion (seeDataType.getConversionClass()
.Equals/hashCode support of this expression depends on the equals/hashCode support of the value.
The data type can be extracted automatically from non-null values using value-based extraction (see
ValueDataTypeConverter
).Symbols (enums extending from
TableSymbol
) are considered as literal values.
-
-
Constructor Summary
Constructors Constructor Description ValueLiteralExpression(Object value)
ValueLiteralExpression(Object value, DataType dataType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <R> R
accept(ExpressionVisitor<R> visitor)
String
asSerializableString()
Returns a string that fully serializes this instance.String
asSummaryString()
Returns a string that summarizes this expression for printing to a console.boolean
equals(Object o)
List<Expression>
getChildren()
DataType
getOutputDataType()
Returns the data type of the computation result.List<ResolvedExpression>
getResolvedChildren()
<T> Optional<T>
getValueAs(Class<T> clazz)
Returns the value (excluding null) as an instance of the given class.int
hashCode()
boolean
isNull()
String
toString()
-
-
-
Method Detail
-
isNull
public boolean isNull()
-
getValueAs
public <T> Optional<T> getValueAs(Class<T> clazz)
Returns the value (excluding null) as an instance of the given class.It supports conversions to default conversion classes of
LogicalTypes
and additionally toBigDecimal
for all types ofLogicalTypeFamily.NUMERIC
. This method should not be called with other classes.Note to implementers: Whenever we add a new class here, make sure to also update the planner for supporting the class via
CallContext.getArgumentValue(int, Class)
.
-
getOutputDataType
public DataType getOutputDataType()
Description copied from interface:ResolvedExpression
Returns the data type of the computation result.- Specified by:
getOutputDataType
in interfaceResolvedExpression
-
getResolvedChildren
public List<ResolvedExpression> getResolvedChildren()
- Specified by:
getResolvedChildren
in interfaceResolvedExpression
-
asSummaryString
public String asSummaryString()
Description copied from interface:Expression
Returns a string that summarizes this expression for printing to a console. An implementation might skip very specific properties.- Specified by:
asSummaryString
in interfaceExpression
- Returns:
- summary string of this expression for debugging purposes
-
asSerializableString
public String asSerializableString()
Description copied from interface:ResolvedExpression
Returns a string that fully serializes this instance. The serialized string can be used for storing the query in, for example, aCatalog
as a view.- Specified by:
asSerializableString
in interfaceResolvedExpression
- Returns:
- detailed string for persisting in a catalog
-
getChildren
public List<Expression> getChildren()
- Specified by:
getChildren
in interfaceExpression
-
accept
public <R> R accept(ExpressionVisitor<R> visitor)
- Specified by:
accept
in interfaceExpression
-
-