Apache pig 阿帕奇猪;清管器avro接头类型

Apache pig 阿帕奇猪;清管器avro接头类型,apache-pig,avro,Apache Pig,Avro,我有一份关于工会的记录 union {TypeA, TypeB, TypeC, TypeD, TypeE} mydata; 我有avro格式的序列化数据,但是当我试图使用piggybank.jar的AvroStorage函数来加载avro数据时,它给出了以下错误: Caused by: java.io.IOException: We don't accept schema containing generic unions. at org.apache.pig.piggybank.st

我有一份关于工会的记录

union {TypeA, TypeB, TypeC, TypeD, TypeE} mydata;
我有avro格式的序列化数据,但是当我试图使用piggybank.jar的AvroStorage函数来加载avro数据时,它给出了以下错误:

Caused by: java.io.IOException: We don't accept schema containing generic unions.
    at org.apache.pig.piggybank.storage.avro.AvroSchema2Pig.convert(AvroSchema2Pig.java:54)
    at org.apache.pig.piggybank.storage.avro.AvroStorage.getSchema(AvroStorage.java:384)
    at org.apache.pig.newplan.logical.relational.LOLoad.getSchemaFromMetaData(LOLoad.java:174)
    ... 23 more
所以,在阅读了这里的piggybank源代码之后

/**确定联合是否为可空联合;
*请注意,此函数不检查包含
*输入联合的类型是递归的*/
公共静态布尔值isAcceptableUnion(中的架构){
如果(!in.getType().equals(Schema.Type.UNION))
返回false;
列表类型=in.getTypes();
if(types.size()2){
return false;/*包含两种以上的类型*/
}否则{
/*两种类型中的一种为NULL*/
返回types.get(0.getType().equals(Schema.Type.NULL)| | types.get(1.getType().equals(Schema.Type.NULL);
}
}

基本上piggybank的AvroStorage不支持超过2种联合类型,我想知道这个决定背后的想法是什么?为什么不让它与Avro兼容?

您能定义一下“联合类型”是什么意思吗?“联合类型”指的是Avro联合中的任意类型,即您在联合中指定的类型,如我在顶部的示例中所示。抱歉有点模棱两可。投票结束,因为我不相信“为什么”软件是按现状制作的,这是本网站的本体论问题。
    /** determine whether a union is a nullable union;
    * note that this function doesn't check containing
    * types of the input union recursively. */
    public static boolean isAcceptableUnion(Schema in) {
        if (! in.getType().equals(Schema.Type.UNION))
           return false;

    List<Schema> types = in.getTypes();
    if (types.size() <= 1) {
        return true;
    } else if (types.size() > 2) {
        return false; /*contains more than 2 types */
    } else {
        /* one of two types is NULL */
        return types.get(0).getType().equals(Schema.Type.NULL) || types.get(1) .getType().equals(Schema.Type.NULL);
    }
}