[
https://issues.apache.org/jira/browse/FLINK-36284?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17901943#comment-17901943
]
Timo Walther commented on FLINK-36284:
--------------------------------------
[~xuyangzhong] [~lincoln.86xy] I don't think that the implementation is good
for supporting Avro going forward. Switching to TypeInformation just to convert
to DataType will loose precision. Was this change only made for the affected
test? Or other requirements?
> StreamTableEnvironment#toDataStream(Table table, Class<T> 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
> Assignee: xuyang
> Priority: Blocker
> Labels: pull-request-available
> 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<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);
> } {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)