case DataType.BAG:
Schema bagSchema = fSchema.schema;
List<HowlFieldSchema> arrFields = new ArrayList<HowlFieldSchema>(1);
arrFields.add(getHowlFSFromPigFS(bagSchema.getField(0)));
return new HowlFieldSchema(fSchema.alias, Type.ARRAY, new HowlSchema(arrFields), "");
case DataType.TUPLE:
List<String> fieldNames = new ArrayList<String>();
List<HowlFieldSchema> howlFSs = new ArrayList<HowlFieldSchema>();
for( FieldSchema fieldSchema : fSchema.schema.getFields()){
fieldNames.add( fieldSchema.alias);
howlFSs.add(getHowlFSFromPigFS(fieldSchema));
}
return new HowlFieldSchema(fSchema.alias, Type.STRUCT, new HowlSchema(howlFSs), "");
case DataType.MAP:{
// Pig's schema contain no type information about map's keys and
// values. So, if its a new column assume <string,string> if its existing
// return whatever is contained in the existing column.
HowlFieldSchema mapField = getTableCol(fSchema.alias, howlTblSchema);
HowlFieldSchema valFS;
List<HowlFieldSchema> valFSList = new ArrayList<HowlFieldSchema>(1);
if(mapField != null){
Type mapValType = mapField.getMapValueSchema().get(0).getType();
switch(mapValType){
case STRING:
case BIGINT:
case INT:
case FLOAT:
case DOUBLE:
valFS = new HowlFieldSchema(fSchema.alias, mapValType, null);
break;
default:
throw new FrontendException("Only pig primitive types are supported as map value types.", PigHowlUtil.PIG_EXCEPTION_CODE);
}
valFSList.add(valFS);
return new HowlFieldSchema(fSchema.alias,Type.MAP,Type.STRING, new HowlSchema(valFSList),"");
}
// Column not found in target table. Its a new column. Its schema is map<string,string>
valFS = new HowlFieldSchema(fSchema.alias, Type.STRING, "");
valFSList.add(valFS);
return new HowlFieldSchema(fSchema.alias,Type.MAP,Type.STRING, new HowlSchema(valFSList),"");
}
default:
throw new FrontendException("Unsupported type: "+type+" in Pig's schema", PigHowlUtil.PIG_EXCEPTION_CODE);
}