In 
https://ci.apache.org/projects/flink/flink-docs-release-1.8/dev/table/common.html#convert-a-table-into-a-datastream-or-dataset
 
<https://ci.apache.org/projects/flink/flink-docs-release-1.8/dev/table/common.html#convert-a-table-into-a-datastream-or-dataset>,
POJO data type is available to convert to DataStream.

I would like to use POJO data type class with private fields. I wonder it is 
possible or not officially. 
Any currently it does not work.

Codes:
—————
CsvTableSource as = CsvTableSource.builder()
        .path("aa.csv")
        .field("name", STRING)
        .field("value", INT)
        .build();
Table aa = tEnv.fromTableSource(as);
tEnv.toAppendStream(aa, P.class);
—————
public class P implements Serializable {
    private String name;
    private Integer value;
}
—————

Above codes, I got below error message:
==========
Exception in thread "main" org.apache.flink.table.api.TableException: Arity [2] 
of result [ArrayBuffer(String, Integer)] does not match the number[1] of 
requested type [GenericType<aa.P>].
        at 
org.apache.flink.table.api.TableEnvironment.generateRowConverterFunction(TableEnvironment.scala:1165)
        at 
org.apache.flink.table.api.StreamTableEnvironment.getConversionMapper(StreamTableEnvironment.scala:423)
        at 
org.apache.flink.table.api.StreamTableEnvironment.translate(StreamTableEnvironment.scala:936)
        at 
org.apache.flink.table.api.StreamTableEnvironment.translate(StreamTableEnvironment.scala:866)
        at 
org.apache.flink.table.api.java.StreamTableEnvironment.toAppendStream(StreamTableEnvironment.scala:202)
        at 
org.apache.flink.table.api.java.StreamTableEnvironment.toAppendStream(StreamTableEnvironment.scala:156)
        at ...
==========

When fields of class P are changed to “public”, it works well.
—————
public class P implements Serializable {
    public String name;
    public Integer value;
}
—————

Thanks,
skonmeme



Reply via email to