Search in sources :

Example 91 with RowData

use of org.apache.flink.table.data.RowData in project flink by apache.

the class PythonStreamGroupTableAggregateOperatorTest method testFlushDataOnClose.

@Test
public void testFlushDataOnClose() throws Exception {
    OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(new Configuration());
    long initialTime = 0L;
    ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
    testHarness.open();
    testHarness.processElement(new StreamRecord<>(newRow(true, "c1", 0L), initialTime + 1));
    testHarness.processElement(new StreamRecord<>(newRow(false, "c2", 1L), initialTime + 2));
    testHarness.close();
    expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
    expectedOutput.add(new StreamRecord<>(newRow(false, "c2", 1L)));
    expectedOutput.add(new StreamRecord<>(newRow(false, "c2", 1L)));
    assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
Also used : RowData(org.apache.flink.table.data.RowData) GenericRowData(org.apache.flink.table.data.GenericRowData) Configuration(org.apache.flink.configuration.Configuration) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Test(org.junit.Test)

Example 92 with RowData

use of org.apache.flink.table.data.RowData in project flink by apache.

the class PythonStreamGroupTableAggregateOperatorTest method testFinishBundleTriggeredByTime.

@Test
public void testFinishBundleTriggeredByTime() throws Exception {
    Configuration conf = new Configuration();
    conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
    conf.setLong(PythonOptions.MAX_BUNDLE_TIME_MILLS, 1000L);
    OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(conf);
    long initialTime = 0L;
    ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
    testHarness.open();
    testHarness.processElement(new StreamRecord<>(newRow(true, "c1", 0L), initialTime + 1));
    testHarness.processElement(new StreamRecord<>(newRow(true, "c2", 1L), initialTime + 2));
    testHarness.processElement(new StreamRecord<>(newRow(true, "c3", 2L), initialTime + 3));
    assertOutputEquals("FinishBundle should not be triggered.", expectedOutput, testHarness.getOutput());
    testHarness.setProcessingTime(1000L);
    expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 1L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 1L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c3", 2L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c3", 2L)));
    assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
    testHarness.close();
}
Also used : RowData(org.apache.flink.table.data.RowData) GenericRowData(org.apache.flink.table.data.GenericRowData) Configuration(org.apache.flink.configuration.Configuration) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Test(org.junit.Test)

Example 93 with RowData

use of org.apache.flink.table.data.RowData in project flink by apache.

the class PythonStreamGroupTableAggregateOperatorTest method testFinishBundleTriggeredByCount.

@Test
public void testFinishBundleTriggeredByCount() throws Exception {
    Configuration conf = new Configuration();
    conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 3);
    OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(conf);
    long initialTime = 0L;
    ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
    testHarness.open();
    testHarness.processElement(new StreamRecord<>(newRow(true, "c1", 0L), initialTime + 1));
    testHarness.processElement(new StreamRecord<>(newRow(true, "c2", 1L), initialTime + 2));
    assertOutputEquals("FinishBundle should not be triggered.", expectedOutput, testHarness.getOutput());
    testHarness.processElement(new StreamRecord<>(newRow(true, "c3", 2L), initialTime + 2));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 1L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 1L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c3", 2L)));
    expectedOutput.add(new StreamRecord<>(newRow(true, "c3", 2L)));
    assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
    testHarness.close();
}
Also used : RowData(org.apache.flink.table.data.RowData) GenericRowData(org.apache.flink.table.data.GenericRowData) Configuration(org.apache.flink.configuration.Configuration) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Test(org.junit.Test)

Example 94 with RowData

use of org.apache.flink.table.data.RowData in project flink by apache.

the class ArrowPythonAggregateFunctionOperatorTestBase method newBinaryRow.

protected RowData newBinaryRow(boolean accumulateMsg, Object... fields) {
    if (accumulateMsg) {
        return binaryrow(fields);
    } else {
        RowData row = binaryrow(fields);
        row.setRowKind(RowKind.DELETE);
        return row;
    }
}
Also used : RowData(org.apache.flink.table.data.RowData)

Example 95 with RowData

use of org.apache.flink.table.data.RowData in project flink by apache.

the class BatchArrowPythonGroupAggregateFunctionOperatorTest method testFinishBundleTriggeredByTime.

@Test
public void testFinishBundleTriggeredByTime() throws Exception {
    Configuration conf = new Configuration();
    conf.setInteger(PythonOptions.MAX_BUNDLE_SIZE, 10);
    conf.setLong(PythonOptions.MAX_BUNDLE_TIME_MILLS, 1000L);
    OneInputStreamOperatorTestHarness<RowData, RowData> testHarness = getTestHarness(conf);
    long initialTime = 0L;
    ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>();
    testHarness.open();
    testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 0L), initialTime + 1));
    testHarness.processElement(new StreamRecord<>(newRow(true, "c1", "c2", 1L), initialTime + 2));
    testHarness.processElement(new StreamRecord<>(newRow(true, "c2", "c6", 2L), initialTime + 2));
    assertOutputEquals("FinishBundle should not be triggered.", expectedOutput, testHarness.getOutput());
    testHarness.setProcessingTime(1000L);
    expectedOutput.add(new StreamRecord<>(newRow(true, "c1", 0L)));
    assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
    testHarness.close();
    expectedOutput.add(new StreamRecord<>(newRow(true, "c2", 2L)));
    assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput());
}
Also used : RowData(org.apache.flink.table.data.RowData) Configuration(org.apache.flink.configuration.Configuration) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) Test(org.junit.Test)

Aggregations

RowData (org.apache.flink.table.data.RowData)602 Test (org.junit.Test)201 GenericRowData (org.apache.flink.table.data.GenericRowData)178 ArrayList (java.util.ArrayList)109 RowType (org.apache.flink.table.types.logical.RowType)105 JoinedRowData (org.apache.flink.table.data.utils.JoinedRowData)90 Watermark (org.apache.flink.streaming.api.watermark.Watermark)84 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)72 Transformation (org.apache.flink.api.dag.Transformation)70 Configuration (org.apache.flink.configuration.Configuration)68 BinaryRowData (org.apache.flink.table.data.binary.BinaryRowData)67 List (java.util.List)65 ExecEdge (org.apache.flink.table.planner.plan.nodes.exec.ExecEdge)54 DataType (org.apache.flink.table.types.DataType)52 Map (java.util.Map)42 LogicalType (org.apache.flink.table.types.logical.LogicalType)41 TableException (org.apache.flink.table.api.TableException)34 OneInputTransformation (org.apache.flink.streaming.api.transformations.OneInputTransformation)33 RowDataKeySelector (org.apache.flink.table.runtime.keyselector.RowDataKeySelector)32 OperatorSubtaskState (org.apache.flink.runtime.checkpoint.OperatorSubtaskState)31