You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flink.apache.org by "Gyula Fora (Jira)" <ji...@apache.org> on 2020/04/29 15:31:00 UTC

[jira] [Created] (FLINK-17466) toRetractStream doesn't work correctly with Pojo conversion class

Gyula Fora created FLINK-17466:
----------------------------------

             Summary: toRetractStream doesn't work correctly with Pojo conversion class
                 Key: FLINK-17466
                 URL: https://issues.apache.org/jira/browse/FLINK-17466
             Project: Flink
          Issue Type: Bug
          Components: Table SQL / Planner
    Affects Versions: 1.10.0
            Reporter: Gyula Fora


The toRetractStream(table, Pojo.class) does not map the query columns properly to the pojo fields.

This either leads to exceptions due to type incompatibility or simply incorrect results.

It can be simple reproduced by the following test code:
{code:java}
@Test
public void testRetract() throws Exception {
 EnvironmentSettings settings = EnvironmentSettings
 .newInstance()
 .useBlinkPlanner()
 .inStreamingMode()
 .build();

 StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
 StreamTableEnvironment tableEnv = StreamTableEnvironment
 .create(StreamExecutionEnvironment.getExecutionEnvironment(), settings);

 tableEnv.createTemporaryView("person", env.fromElements(new Person()));
 tableEnv.toRetractStream(tableEnv.sqlQuery("select name, age from person"), Person.class).print();
 tableEnv.execute("Test");

}

public static class Person {
 public String name = "bob";
 public int age = 1;
}{code}
Runtime Error:
{noformat}
java.lang.ClassCastException: org.apache.flink.table.dataformat.BinaryString cannot be cast to java.lang.Integer{noformat}
Changing the query to "select age,name from person" in this case would resolve the problem but it also highlights the possible underlying issue.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)