[
https://issues.apache.org/jira/browse/FLINK-14409?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
ASF GitHub Bot updated FLINK-14409:
-----------------------------------
Labels: pull-request-available (was: )
> MapType doesn't accept any subclass of java.util.Map
> ----------------------------------------------------
>
> Key: FLINK-14409
> URL: https://issues.apache.org/jira/browse/FLINK-14409
> Project: Flink
> Issue Type: Bug
> Components: Table SQL / API
> Reporter: Jark Wu
> Priority: Major
> Labels: pull-request-available
>
> Currently the conversion class of MapType is {{java.util.Map}}, but
> {{java.util.Map}} is an interface not a concrete class. So when verifying an
> instance of {{HashMap}} for MapType, it fails.
> For example:
> {code:java}
> Map<String, Integer> map = new HashMap<>();
> map.put("key1", 1);
> map.put("key2", 2);
> map.put("key3", 3);
> assertEquals(
> "{key1=1, key2=2, key3=3}",
> new ValueLiteralExpression(
> map,
> DataTypes.MAP(DataTypes.STRING(),
> DataTypes.INT()))
> .toString());
> {code}
> throws exception:
> {code}
> org.apache.flink.table.api.ValidationException: Data type 'MAP<STRING, INT>'
> does not support a conversion from class 'java.util.HashMap'.
> at
> org.apache.flink.table.expressions.ValueLiteralExpression.validateValueDataType(ValueLiteralExpression.java:236)
> at
> org.apache.flink.table.expressions.ValueLiteralExpression.<init>(ValueLiteralExpression.java:66)
> {code}
> It's easy to fix this by considering whether it's a subclass of Map. But I'm
> wondering what the default conversion class should be?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)