@PublicEvolving public interface CallContext
TypeInference
.Modifier and Type | Method and Description |
---|---|
default <T> Optional<T> |
fail(boolean throwOnFailure,
String message,
Object... args)
Helper method for handling failures during the type inference process while considering the
throwOnFailure flag. |
List<DataType> |
getArgumentDataTypes()
Returns a resolved list of the call's argument types.
|
<T> Optional<T> |
getArgumentValue(int pos,
Class<T> clazz)
Returns the literal value of the argument at the given position, given that the argument is a
literal, is not null, and can be expressed as an instance of the provided class.
|
DataTypeFactory |
getDataTypeFactory()
Enables to lookup types in a catalog and resolve RAW types.
|
FunctionDefinition |
getFunctionDefinition()
Returns the function definition that defines the function currently being called.
|
String |
getName()
Returns the function's name usually referencing the function in a catalog.
|
Optional<DataType> |
getOutputDataType()
Returns the inferred output data type of the function call.
|
boolean |
isArgumentLiteral(int pos)
Returns whether the argument at the given position is a value literal.
|
boolean |
isArgumentNull(int pos)
Returns
true if the argument at the given position is a literal and null ,
false otherwise. |
boolean |
isGroupedAggregation()
Returns whether the function call happens as part of an aggregation that defines grouping
columns.
|
default ValidationException |
newValidationError(String message,
Object... args)
Creates a validation exception for exiting the type inference process with a meaningful
exception.
|
DataTypeFactory getDataTypeFactory()
FunctionDefinition getFunctionDefinition()
boolean isArgumentLiteral(int pos)
boolean isArgumentNull(int pos)
true
if the argument at the given position is a literal and null
,
false
otherwise.
Use isArgumentLiteral(int)
before to check if the argument is actually a literal.
<T> Optional<T> getArgumentValue(int pos, Class<T> clazz)
It supports conversions to default conversion classes of LogicalTypes
.
This method should not be called with other classes.
Use isArgumentLiteral(int)
before to check if the argument is actually a literal.
String getName()
Note: The name is meant for debugging purposes only.
List<DataType> getArgumentDataTypes()
Optional<DataType> getOutputDataType()
It does this by inferring the input argument data type using ArgumentTypeStrategy.inferArgumentType(CallContext, int, boolean)
of a wrapping call (if
available) where this function call is an argument. For example, takes_string(this_function(NULL))
would lead to a DataTypes.STRING()
because the
wrapping call expects a string argument.
default ValidationException newValidationError(String message, Object... args)
default <T> Optional<T> fail(boolean throwOnFailure, String message, Object... args)
throwOnFailure
flag.
Shorthand for if (throwOnFailure) throw ValidationException(...) else return
Optional.empty()
.
boolean isGroupedAggregation()
E.g. SELECT COUNT(*) FROM t
is not a grouped aggregation but SELECT
COUNT(*) FROM t GROUP BY k
is.
Copyright © 2014–2024 The Apache Software Foundation. All rights reserved.