Benchao Li的那个方法是对的,avro的一个bug:

private static AvroToRowDataConverter createMapConverter(LogicalType type) {
   final AvroToRowDataConverter keyConverter = 
createConverter(DataTypes.STRING().getLogicalType());
   final AvroToRowDataConverter valueConverter = 
createConverter(extractValueTypeToAvroMap(type));

   return avroObject -> {
      final Map<?, ?> map = (Map<?, ?>) avroObject;
      Map<Object, Object> result = new HashMap<>();
      for (Map.Entry<?, ?> entry : map.entrySet()) {
         Object key = keyConverter.convert(entry.getKey());
         Object value = valueConverter.convert(entry.getValue());
         result.put(key, value);
      }
      return new GenericMapData(result);
   };
}

 应该是 createNullableConverter

final AvroToRowDataConverter valueConverter = 
createNullableConverter(extractValueTypeToAvroMap(type));

________________________________
发件人: 史 正超 <[email protected]>
发送时间: 2020年10月14日 5:22
收件人: [email protected] <[email protected]>
主题: 回复: 回复: flink-SQL1.11版本对map类型中value的空指针异常

确定吗?我这边测试还是有问题,这应该是avro 的一个bug。
________________________________
发件人: 奔跑的小飞袁 <[email protected]>
发送时间: 2020年10月14日 3:29
收件人: [email protected] <[email protected]>
主题: Re: 回复: flink-SQL1.11版本对map类型中value的空指针异常

我尝试使用MAP<STRING, STRING NULL>来定义我的类型,问题已经解决,谢谢



--
Sent from: http://apache-flink.147419.n8.nabble.com/

回复