Search in sources :

Example 1 with NamespaceAggsHandleFunction

use of org.apache.flink.table.runtime.generated.NamespaceAggsHandleFunction in project flink by apache.

the class WindowOperatorContractTest method createWindowOperator.

// ------------------------------------------------------------------------------------------
@SuppressWarnings("unchecked")
private <W extends Window> KeyedOneInputStreamOperatorTestHarness<RowData, RowData, RowData> createWindowOperator(WindowAssigner<W> assigner, Trigger<W> trigger, NamespaceAggsHandleFunctionBase<W> aggregationsFunction, long allowedLateness) throws Exception {
    LogicalType[] inputTypes = new LogicalType[] { VarCharType.STRING_TYPE, new IntType() };
    RowDataKeySelector keySelector = HandwrittenSelectorUtil.getRowDataSelector(new int[] { 0 }, inputTypes);
    TypeInformation<RowData> keyType = keySelector.getProducedType();
    LogicalType[] accTypes = new LogicalType[] { new BigIntType(), new BigIntType() };
    LogicalType[] windowTypes = new LogicalType[] { new BigIntType(), new BigIntType() };
    LogicalType[] outputTypeWithoutKeys = new LogicalType[] { new BigIntType(), new BigIntType(), new BigIntType(), new BigIntType() };
    boolean sendRetraction = allowedLateness > 0;
    if (aggregationsFunction instanceof NamespaceAggsHandleFunction) {
        AggregateWindowOperator operator = new AggregateWindowOperator((NamespaceAggsHandleFunction) aggregationsFunction, mock(RecordEqualiser.class), assigner, trigger, assigner.getWindowSerializer(new ExecutionConfig()), inputTypes, outputTypeWithoutKeys, accTypes, windowTypes, 2, sendRetraction, allowedLateness, UTC_ZONE_ID, -1);
        return new KeyedOneInputStreamOperatorTestHarness<RowData, RowData, RowData>(operator, keySelector, keyType);
    } else {
        TableAggregateWindowOperator operator = new TableAggregateWindowOperator((NamespaceTableAggsHandleFunction) aggregationsFunction, assigner, trigger, assigner.getWindowSerializer(new ExecutionConfig()), inputTypes, outputTypeWithoutKeys, accTypes, windowTypes, 2, sendRetraction, allowedLateness, UTC_ZONE_ID, -1);
        return new KeyedOneInputStreamOperatorTestHarness<RowData, RowData, RowData>(operator, keySelector, keyType);
    }
}
Also used : RecordEqualiser(org.apache.flink.table.runtime.generated.RecordEqualiser) LogicalType(org.apache.flink.table.types.logical.LogicalType) BigIntType(org.apache.flink.table.types.logical.BigIntType) ExecutionConfig(org.apache.flink.api.common.ExecutionConfig) NamespaceAggsHandleFunction(org.apache.flink.table.runtime.generated.NamespaceAggsHandleFunction) KeyedOneInputStreamOperatorTestHarness(org.apache.flink.streaming.util.KeyedOneInputStreamOperatorTestHarness) IntType(org.apache.flink.table.types.logical.IntType) BigIntType(org.apache.flink.table.types.logical.BigIntType) GenericRowData(org.apache.flink.table.data.GenericRowData) RowData(org.apache.flink.table.data.RowData) RowDataKeySelector(org.apache.flink.table.runtime.keyselector.RowDataKeySelector)

Aggregations

ExecutionConfig (org.apache.flink.api.common.ExecutionConfig)1 KeyedOneInputStreamOperatorTestHarness (org.apache.flink.streaming.util.KeyedOneInputStreamOperatorTestHarness)1 GenericRowData (org.apache.flink.table.data.GenericRowData)1 RowData (org.apache.flink.table.data.RowData)1 NamespaceAggsHandleFunction (org.apache.flink.table.runtime.generated.NamespaceAggsHandleFunction)1 RecordEqualiser (org.apache.flink.table.runtime.generated.RecordEqualiser)1 RowDataKeySelector (org.apache.flink.table.runtime.keyselector.RowDataKeySelector)1 BigIntType (org.apache.flink.table.types.logical.BigIntType)1 IntType (org.apache.flink.table.types.logical.IntType)1 LogicalType (org.apache.flink.table.types.logical.LogicalType)1