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

StreamTableEnvironment#toDataStream(Table table, Class<T> targetClass) is not suitable for setting targetClass as a class generated by Avro.

    XMLWordPrintableJSON

Details

    Description

      This issue can be fired by updating the testAvroToAvro method in the org.apache.flink.table.runtime.batch.AvroTypesITCase class.

       

      @Test
      public void testAvroToAvro() {
          StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
          StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
      
          DataStream<User> ds = testData(env);
          // before: using deprecated method
          // Table t = tEnv.fromDataStream(ds, selectFields(ds));
          // after: using recommended new method
          Table t = tEnv.fromDataStream(ds);
          Table result = t.select($("*"));
      
          // before: using deprecated method
          // List<User> results =
          //        CollectionUtil.iteratorToList(
          //                DataStreamUtils.collect(tEnv.toAppendStream(result, User.class)));
          // after: using recommended new method
          List<User> results =
              CollectionUtil.iteratorToList(
                      DataStreamUtils.collect(tEnv.toDataStream(result, User.class)));
          List<User> expected = Arrays.asList(USER_1, USER_2, USER_3);
          assertThat(results).isEqualTo(expected);
      } 

      An exception will be thrown:

       

       

       

       

      Attachments

        Issue Links

          Activity

            People

              xuyangzhong xuyang
              xuyangzhong xuyang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: