[
https://issues.apache.org/jira/browse/FLINK-12175?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Dawid Wysakowicz closed FLINK-12175.
------------------------------------
Fix Version/s: 1.12.0
Resolution: Fixed
Fixed in a8847061c40bf8ca17e22e6e412a378f53b8b82d
> TypeExtractor.getMapReturnTypes produces different TypeInformation than
> createTypeInformation for classes with parameterized ancestors
> --------------------------------------------------------------------------------------------------------------------------------------
>
> Key: FLINK-12175
> URL: https://issues.apache.org/jira/browse/FLINK-12175
> Project: Flink
> Issue Type: Bug
> Components: API / Type Serialization System
> Affects Versions: 1.7.2, 1.9.0
> Reporter: Daniel Adams
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.12.0
>
> Time Spent: 10m
> Remaining Estimate: 0h
>
> I expect that the {{TypeMapper}} {{createTypeInformation}} and
> {{getMapReturnTypes}} would produce equivalent type information for the same
> type. But when there is a parameterized superclass, this does not appear to
> be the case.
> Here's a test case that could be added to {{PojoTypeExtractorTest.java}} that
> demonstrates the issue:
> {code}
> public static class Pojo implements Serializable {
> public int digits;
> public String letters;
> }
> public static class ParameterizedParent<T extends Serializable> implements
> Serializable {
> public T pojoField;
> }
> public static class ConcreteImpl extends ParameterizedParent<Pojo> {
> public double precise;
> }
> public static class ConcreteMapFunction implements MapFunction<ConcreteImpl,
> ConcreteImpl> {
> @Override
> public ConcreteImpl map(ConcreteImpl value) throws Exception {
> return null;
> }
> }
> @Test
> public void testMapReturnType() {
> final TypeInformation<ConcreteImpl> directTypeInfo =
> TypeExtractor.createTypeInfo(ConcreteImpl.class);
> Assert.assertTrue(directTypeInfo instanceof PojoTypeInfo);
> TypeInformation<?> directPojoFieldTypeInfo = ((PojoTypeInfo)
> directTypeInfo).getPojoFieldAt(0).getTypeInformation();
> Assert.assertTrue(directPojoFieldTypeInfo instanceof PojoTypeInfo);
> final TypeInformation<ConcreteImpl> mapReturnTypeInfo
> = TypeExtractor.getMapReturnTypes(new ConcreteMapFunction(),
> directTypeInfo);
> Assert.assertTrue(mapReturnTypeInfo instanceof PojoTypeInfo);
> TypeInformation<?> mapReturnPojoFieldTypeInfo = ((PojoTypeInfo)
> mapReturnTypeInfo).getPojoFieldAt(0).getTypeInformation();
> Assert.assertTrue(mapReturnPojoFieldTypeInfo instanceof PojoTypeInfo);
> Assert.assertEquals(directTypeInfo, mapReturnTypeInfo);
> }
> {code}
> This test case will fail on the last two asserts because
> {{getMapReturnTypes}} produces a {{TypeInformation}} for {{ConcreteImpl}}
> with a {{GenericTypeInfo}} for the {{pojoField}}, whereas
> {{createTypeInformation}} correctly produces a {{PojoTypeInfo}}.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)