Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
Description
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:
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());
throws exception:
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)
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?
Attachments
Issue Links
- links to