Class AdaptedCallContext

java.lang.Object
org.apache.flink.table.types.inference.utils.AdaptedCallContext
All Implemented Interfaces:
CallContext

@Internal public final class AdaptedCallContext extends Object implements CallContext
Helper context that deals with adapted arguments.

For example, if an argument needs to be casted to a target type, an expression that was a literal before is not a literal anymore in this call context.

  • Constructor Details

    • AdaptedCallContext

      public AdaptedCallContext(CallContext originalContext, @Nullable DataType outputDataType)
  • Method Details

    • setExpectedArguments

      public void setExpectedArguments(List<DataType> expectedArguments)
    • getDataTypeFactory

      public DataTypeFactory getDataTypeFactory()
      Description copied from interface: CallContext
      Enables to lookup types in a catalog and resolve RAW types.
      Specified by:
      getDataTypeFactory in interface CallContext
    • getFunctionDefinition

      public FunctionDefinition getFunctionDefinition()
      Description copied from interface: CallContext
      Returns the function definition that defines the function currently being called.
      Specified by:
      getFunctionDefinition in interface CallContext
    • isArgumentLiteral

      public boolean isArgumentLiteral(int pos)
      Description copied from interface: CallContext
      Returns whether the argument at the given position is a value literal.
      Specified by:
      isArgumentLiteral in interface CallContext
    • isArgumentNull

      public boolean isArgumentNull(int pos)
      Description copied from interface: CallContext
      Returns true if the argument at the given position is a literal and null, false otherwise. If the argument is declared as optional and has no value, true is returned.

      Use CallContext.isArgumentLiteral(int) before to check if the argument is actually a literal.

      Specified by:
      isArgumentNull in interface CallContext
    • getArgumentValue

      public <T> Optional<T> getArgumentValue(int pos, Class<T> clazz)
      Description copied from interface: CallContext
      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.

      It supports conversions to default conversion classes of LogicalTypes. This method should not be called with other classes.

      Use CallContext.isArgumentLiteral(int) before to check if the argument is actually a literal.

      Specified by:
      getArgumentValue in interface CallContext
    • getTableSemantics

      public Optional<TableSemantics> getTableSemantics(int pos)
      Description copied from interface: CallContext
      Returns information about the table that has been passed to a table argument.

      Semantics are only available for table arguments (i.e. arguments of a ProcessTableFunction that are annotated with @ArgumentHint(TABLE_AS_SET) or @ArgumentHint(TABLE_AS_ROW)).

      Specified by:
      getTableSemantics in interface CallContext
    • getName

      public String getName()
      Description copied from interface: CallContext
      Returns the function's name usually referencing the function in a catalog.

      Note: The name is meant for debugging purposes only.

      Specified by:
      getName in interface CallContext
    • getArgumentDataTypes

      public List<DataType> getArgumentDataTypes()
      Description copied from interface: CallContext
      Returns a resolved list of the call's argument types. It also includes a type for every argument in a vararg function call.
      Specified by:
      getArgumentDataTypes in interface CallContext
    • getOutputDataType

      public Optional<DataType> getOutputDataType()
      Description copied from interface: CallContext
      Returns the inferred output data type of the function call.

      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.

      Specified by:
      getOutputDataType in interface CallContext
    • isGroupedAggregation

      public boolean isGroupedAggregation()
      Description copied from interface: CallContext
      Returns whether the function call happens as part of an aggregation that defines grouping columns.

      E.g. SELECT COUNT(*) FROM t is not a grouped aggregation but SELECT COUNT(*) FROM t GROUP BY k is.

      Specified by:
      isGroupedAggregation in interface CallContext