Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-17466

toRetractStream doesn't work correctly with Pojo conversion class

    XMLWordPrintableJSON

    Details

      Description

      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:

      @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;
      }

      Runtime Error:

      java.lang.ClassCastException: org.apache.flink.table.dataformat.BinaryString cannot be cast to java.lang.Integer

      Changing the query to "select age,name from person" in this case would resolve the problem but it also highlights the possible underlying issue.

        Attachments

        1. retract-issue.patch
          0.9 kB
          Gyula Fora

          Issue Links

            Activity

              People

              • Assignee:
                jark Jark Wu
                Reporter:
                gyfora Gyula Fora
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: