Search in sources :

Example 1 with JsonValue

use of com.alibaba.alink.pipeline.dataproc.JsonValue in project Alink by alibaba.

the class JsonValueBatchOpTest method test3.

@Test
public void test3() throws Exception {
    Row[] testArray = new Row[] { Row.of("{\"ak\":1,\"dd\":1}") };
    String[] colnames = new String[] { "jsoncol" };
    MemSourceBatchOp inOp = new MemSourceBatchOp(Arrays.asList(testArray), colnames);
    List<Row> result = (new Pipeline().add(new JsonValue().setSkipFailed(true).setOutputColTypes(new String[] { "string", "string" }).setSelectedCol("jsoncol").setOutputCols(new String[] { "jsonval", "jv" }).setJsonPath("$.ak", "$.ck"))).fit(inOp).transform(inOp).collect();
    Assert.assertNull(result.get(0).getField(2));
}
Also used : MemSourceBatchOp(com.alibaba.alink.operator.batch.source.MemSourceBatchOp) JsonValue(com.alibaba.alink.pipeline.dataproc.JsonValue) Row(org.apache.flink.types.Row) Pipeline(com.alibaba.alink.pipeline.Pipeline) Test(org.junit.Test)

Aggregations

MemSourceBatchOp (com.alibaba.alink.operator.batch.source.MemSourceBatchOp)1 Pipeline (com.alibaba.alink.pipeline.Pipeline)1 JsonValue (com.alibaba.alink.pipeline.dataproc.JsonValue)1 Row (org.apache.flink.types.Row)1 Test (org.junit.Test)1