Search in sources :

Example 1 with FlattenMTableStreamOp

use of com.alibaba.alink.operator.stream.dataproc.FlattenMTableStreamOp in project Alink by alibaba.

the class FlattenMTableTest method test3.

@Test
public void test3() throws Exception {
    List<Row> rows = new ArrayList<>();
    rows.add(Row.of("a1", "{\"data\":{\"f0\":[\"11L\",\"12L\"],\"f1\":[2.0,2.0]},\"schema\":\"f0 VARCHAR,f1 " + "DOUBLE\"}"));
    rows.add(Row.of("a3", "{\"data\":{\"f0\":[\"13L\",\"14L\"],\"f1\":[2.0,2.0]},\"schema\":\"f0 VARCHAR,f1 " + "DOUBLE\"}"));
    StreamOperator<?> input = new MemSourceStreamOp(rows, "id string, mt string");
    FlattenMTableStreamOp flatten = new FlattenMTableStreamOp().setReservedCols("id").setSelectedCol("mt").setSchemaStr("f0 string, f1 int");
    CollectSinkStreamOp sop = flatten.linkFrom(input).link(new CollectSinkStreamOp());
    StreamOperator.execute();
    List<Row> res = sop.getAndRemoveValues();
    for (Row row : res) {
        Assert.assertEquals(2, row.getField(2));
    }
}
Also used : MemSourceStreamOp(com.alibaba.alink.operator.stream.source.MemSourceStreamOp) FlattenMTableStreamOp(com.alibaba.alink.operator.stream.dataproc.FlattenMTableStreamOp) CollectSinkStreamOp(com.alibaba.alink.operator.stream.sink.CollectSinkStreamOp) ArrayList(java.util.ArrayList) Row(org.apache.flink.types.Row) Test(org.junit.Test)

Aggregations

FlattenMTableStreamOp (com.alibaba.alink.operator.stream.dataproc.FlattenMTableStreamOp)1 CollectSinkStreamOp (com.alibaba.alink.operator.stream.sink.CollectSinkStreamOp)1 MemSourceStreamOp (com.alibaba.alink.operator.stream.source.MemSourceStreamOp)1 ArrayList (java.util.ArrayList)1 Row (org.apache.flink.types.Row)1 Test (org.junit.Test)1