Search in sources :

Example 36 with FrontendException

use of org.apache.pig.impl.logicalLayer.FrontendException in project shifu by ShifuML.

the class GuaguaParquetMapReduceClient method getPigSchemaFromMultipleFiles.

/**
 * @param fileSchema
 *            the parquet schema from the file
 * @param keyValueMetaData
 *            the extra meta data from the files
 * @return the pig schema according to the file
 */
static Schema getPigSchemaFromMultipleFiles(MessageType fileSchema, Map<String, Set<String>> keyValueMetaData) {
    Set<String> pigSchemas = PigMetaData.getPigSchemas(keyValueMetaData);
    if (pigSchemas == null) {
        return pigSchemaConverter.convert(fileSchema);
    }
    Schema mergedPigSchema = null;
    for (String pigSchemaString : pigSchemas) {
        try {
            mergedPigSchema = union(mergedPigSchema, parsePigSchema(pigSchemaString));
        } catch (FrontendException e) {
            throw new ParquetDecodingException("can not merge " + pigSchemaString + " into " + mergedPigSchema, e);
        }
    }
    return mergedPigSchema;
}
Also used : ParquetDecodingException(parquet.io.ParquetDecodingException) Schema(org.apache.pig.impl.logicalLayer.schema.Schema) FieldSchema(org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema) FrontendException(org.apache.pig.impl.logicalLayer.FrontendException)

Aggregations

FrontendException (org.apache.pig.impl.logicalLayer.FrontendException)36 Schema (org.apache.pig.impl.logicalLayer.schema.Schema)27 FieldSchema (org.apache.pig.impl.logicalLayer.schema.Schema.FieldSchema)11 ArrayList (java.util.ArrayList)6 HCatFieldSchema (org.apache.hive.hcatalog.data.schema.HCatFieldSchema)5 HCatSchema (org.apache.hive.hcatalog.data.schema.HCatSchema)5 ResourceSchema (org.apache.pig.ResourceSchema)4 IOException (java.io.IOException)3 OriginalType (org.apache.parquet.schema.OriginalType)3 PigServer (org.apache.pig.PigServer)3 DataType (org.apache.pig.data.DataType)3 Tuple (org.apache.pig.data.Tuple)3 File (java.io.File)2 List (java.util.List)2 HCatException (org.apache.hive.hcatalog.common.HCatException)2 PigSchemaConverter.parsePigSchema (org.apache.parquet.pig.PigSchemaConverter.parsePigSchema)2 GroupType (org.apache.parquet.schema.GroupType)2 MessageType (org.apache.parquet.schema.MessageType)2 PrimitiveType (org.apache.parquet.schema.PrimitiveType)2 Type (org.apache.parquet.schema.Type)2