Class ProcessTableFunctionTestHarness.Builder<OUT>
java.lang.Object
org.apache.flink.table.runtime.functions.ProcessTableFunctionTestHarness.Builder<OUT>
- Type Parameters:
OUT- The output type of the ProcessTableFunction
- Enclosing class:
- ProcessTableFunctionTestHarness<OUT>
Builder for
ProcessTableFunctionTestHarness.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds the test harness.withInitialStateForKey(String stateName, Row partitionKey, Object state) Sets initial state for a state parameter.withOnTimeColumn(String columnName) Configures the on-time column name for the function.withPartitionBy(String argumentName, String... columnNames) Specifies partition columns for a set semantic table.withScalarArgument(String argumentName, Object value) Configures a scalar (non-table) argument for the PTF's eval() method.withTableArgument(String argumentName) Configures a table argument without an explicit schema.withTableArgument(String argumentName, AbstractDataType<?> dataType) Configures a table argument with its schema (named argument).
-
Method Details
-
withTableArgument
public ProcessTableFunctionTestHarness.Builder<OUT> withTableArgument(String argumentName, AbstractDataType<?> dataType) Configures a table argument with its schema (named argument).Use this for dynamic tables that receive elements during the test. Elements are provided via
ProcessTableFunctionTestHarness.processElement(Row)orProcessTableFunctionTestHarness.processElementForTable(String, Row).- Parameters:
argumentName- The table argument namedataType- The schema/structure of the table
-
withTableArgument
Configures a table argument without an explicit schema.Use this for structured type arguments where the type can be inferred from the PTF's eval() signature. For Row arguments, use
withTableArgument(String, AbstractDataType)with an explicit schema.- Parameters:
argumentName- The table argument name
-
withScalarArgument
public ProcessTableFunctionTestHarness.Builder<OUT> withScalarArgument(String argumentName, Object value) Configures a scalar (non-table) argument for the PTF's eval() method.Scalar arguments are constant values passed to every eval() invocation, such as thresholds, multipliers, or configuration parameters.
- Parameters:
argumentName- Must match the parameter name in eval() or the @ArgumentHint namevalue- The value to pass for this argument in all eval() calls
-
withInitialStateForKey
public ProcessTableFunctionTestHarness.Builder<OUT> withInitialStateForKey(String stateName, Row partitionKey, Object state) Sets initial state for a state parameter. -
withPartitionBy
public ProcessTableFunctionTestHarness.Builder<OUT> withPartitionBy(String argumentName, String... columnNames) Specifies partition columns for a set semantic table.- Parameters:
argumentName- The table argument namecolumnNames- The partition column names- Returns:
- This builder
-
withOnTimeColumn
Configures the on-time column name for the function.- Parameters:
columnName- The column that carries event time
-
build
Builds the test harness.This instantiates the PTF, validates configuration via type inference, creates the FunctionContext, and opens the function.
- Returns:
- The configured test harness
- Throws:
Exception- If instantiation or opening fails
-