xuyang created FLINK-36284:
--
Summary: StreamTableEnvironment#toDataStream(Table table, Class
targetClass) is not suitable for setting targetClass as a class generated by
Avro.
Key: FLINK-36284
URL: https://issues.apache.org/jira/browse/FLINK-36284
Project: Flink
Issue Type: Improvement
Components: Formats (JSON, Avro, Parquet, ORC, SequenceFile), Table
SQL / API
Reporter: xuyang
Fix For: 2.0-preview
Attachments: image-2024-09-14-17-39-16-698.png
This issue can be fired by updating the {{testAvroToAvro}} method in the
{{org.apache.flink.table.runtime.batch.AvroTypesITCase}} class.
{code:java}
@Test
public void testAvroToAvro() {
StreamExecutionEnvironment env =
StreamExecutionEnvironment.getExecutionEnvironment();
StreamTableEnvironment tEnv = StreamTableEnvironment.create(env);
DataStream 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 results =
//CollectionUtil.iteratorToList(
//DataStreamUtils.collect(tEnv.toAppendStream(result,
User.class)));
// after: using recommended new method
List results =
CollectionUtil.iteratorToList(
DataStreamUtils.collect(tEnv.toDataStream(result, User.class)));
List expected = Arrays.asList(USER_1, USER_2, USER_3);
assertThat(results).isEqualTo(expected);
} {code}
An exception will be thrown:
!image-2024-09-14-17-39-16-698.png|width=1049,height=594!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)