You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/10/09 06:13:27 UTC

[GitHub] [flink] wuchong commented on a change in pull request #13543: [FLINK-19509][Format-json] Fix ClassCastException of JsonRowDataDeserializationSchema and JsonRowDataSerializationSchema when type is multiset

wuchong commented on a change in pull request #13543:
URL: https://github.com/apache/flink/pull/13543#discussion_r502208764



##########
File path: flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/RowDataToJsonConverters.java
##########
@@ -218,14 +220,23 @@ private RowDataToJsonConverter createArrayConverter(ArrayType type) {
 		};
 	}
 
-	private RowDataToJsonConverter createMapConverter(MapType type) {
-		LogicalType keyType = type.getKeyType();
+	private RowDataToJsonConverter createMapConverter(LogicalType type) {

Review comment:
       The same to above. 

##########
File path: flink-formats/flink-json/src/main/java/org/apache/flink/formats/json/JsonToRowDataConverters.java
##########
@@ -298,15 +300,25 @@ private JsonToRowDataConverter createArrayConverter(ArrayType arrayType) {
 		};
 	}
 
-	private JsonToRowDataConverter createMapConverter(MapType mapType) {
-		LogicalType keyType = mapType.getKeyType();
+	private JsonToRowDataConverter createMapConverter(LogicalType type) {
+		LogicalType keyType;
+		LogicalType valueType;
+		if (type instanceof MapType) {
+			MapType mapType = (MapType) type;
+			keyType = mapType.getKeyType();
+			valueType = mapType.getValueType();
+		} else {
+			MultisetType multisetType = (MultisetType) type;
+			keyType = multisetType.getElementType();
+			valueType = new IntType();
+		}

Review comment:
       I would suggest to change the method parameters to `createMapConverter(String typeSummary, LogicalType keyType, LogicalType valueType)` and move the above code out of the method (i.e. move to the switch case block). This can make the method `createMapConverter` more generic. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org