Hive 合流kafka-java.io.IOException:org.apache.avro.AvroTypeException:。。。缺少必填字段

Hive 合流kafka-java.io.IOException:org.apache.avro.AvroTypeException:。。。缺少必填字段,hive,avro,Hive,Avro,我正在使用confluent-3.0.1,并希望尝试Avro模式的演变,但在尝试与hive的向后兼容性时,似乎存在一些问题 首先,我声明了这个模式,查询了配置单元并获得了数据 public static final String USER_SCHEMA = "{" + " \"namespace\": \"example.avro\",\n" + " \"type\": \"record\",\n" + " \"name\": \"user\",\

我正在使用confluent-3.0.1,并希望尝试Avro模式的演变,但在尝试与hive的向后兼容性时,似乎存在一些问题

首先,我声明了这个模式,查询了配置单元并获得了数据

public static final String USER_SCHEMA = "{" +
        " \"namespace\": \"example.avro\",\n" +
        " \"type\": \"record\",\n" +
        " \"name\": \"user\",\n" +
        " \"fields\": [\n" +
        "     {\"name\": \"name\", \"type\": \"string\"},\n" +
        "     {\"name\": \"now\", \"type\": \"long\"},\n" +
        "     {\"name\": \"favorite_number\",  \"type\": \"int\"}" +
        " ]\n" +
        "}";
然后我在模式中添加了新的可选字段“a”

但当我查询hive时,我得到了一个例外:

失败,出现异常java.io.IOException:org.apache.avro.AvroTypeException:Found example.avro.user,应为example.avro.user,缺少必填字段a

我认为这是由于第一行没有新字段造成的。 (在hadoop中,所有组件看起来都很好)

似乎只有空值才有问题,因为如果我将此字段添加到模式中,我会设法查询 添加新字段后的配置单元

public static final String USER_SCHEMA = "{" +
        " \"namespace\": \"example.avro\",\n" +
        " \"type\": \"record\",\n" +
        " \"name\": \"user\",\n" +
        " \"fields\": [\n" +
        "     {\"name\": \"name\", \"type\": \"string\"},\n" +
        "     {\"name\": \"now\", \"type\": \"long\"},\n" +
        "     {\"name\": \"favorite_number\",  \"type\": \"int\"}" +
        "     ,\n{\"name\": \"favorite_color\", \"type\": \"string\", \"default\": \"green\"}" +
        " ]\n" +
        "}";
你知道有什么问题吗


谢谢

你使用的是什么版本的avro和hive?avro 1.8.1(在我的制作人中)avro 1.7.6和hive 1.1.1(在claudera docker上,我在hadoop和hive中使用它)这是claudera docker)谢谢!
public static final String USER_SCHEMA = "{" +
        " \"namespace\": \"example.avro\",\n" +
        " \"type\": \"record\",\n" +
        " \"name\": \"user\",\n" +
        " \"fields\": [\n" +
        "     {\"name\": \"name\", \"type\": \"string\"},\n" +
        "     {\"name\": \"now\", \"type\": \"long\"},\n" +
        "     {\"name\": \"favorite_number\",  \"type\": \"int\"}" +
        "     ,\n{\"name\": \"favorite_color\", \"type\": \"string\", \"default\": \"green\"}" +
        " ]\n" +
        "}";