validateAlias(innerField.alias);
}
if(hcatField != null){
// Do the same validation for HCatSchema.
HCatFieldSchema arrayFieldScehma = hcatField.getArrayElementSchema().get(0);
Type hType = arrayFieldScehma.getType();
if(hType == Type.STRUCT){
for(HCatFieldSchema structFieldInBag : arrayFieldScehma.getStructSubSchema().getFields()){
if(structFieldInBag.getType() == Type.STRUCT || structFieldInBag.getType() == Type.ARRAY){
throw new FrontendException("Nested Complex types not allowed "+ hcatField, PigHCatUtil.PIG_EXCEPTION_CODE);
}
}
}
if(hType == Type.MAP){
if(arrayFieldScehma.getMapKeyType() != Type.STRING){
throw new FrontendException("Key Type of map must be String "+hcatField, PigHCatUtil.PIG_EXCEPTION_CODE);
}
if(arrayFieldScehma.getMapValueSchema().get(0).isComplex()){
throw new FrontendException("Value type of map cannot be complex "+hcatField, PigHCatUtil.PIG_EXCEPTION_CODE);
}
}
if(hType == Type.ARRAY) {
throw new FrontendException("Arrays cannot contain array within it. "+hcatField, PigHCatUtil.PIG_EXCEPTION_CODE);
}
}
break;
case DataType.TUPLE:
validateUnNested(pigField.schema);
if(hcatField != null){
for(HCatFieldSchema structFieldSchema : hcatField.getStructSubSchema().getFields()){
if(structFieldSchema.isComplex()){
throw new FrontendException("Nested Complex types are not allowed."+hcatField, PigHCatUtil.PIG_EXCEPTION_CODE);
}
}
}
break;
default:
throw new FrontendException("Internal Error.", PigHCatUtil.PIG_EXCEPTION_CODE);
}
}
}
for(HCatFieldSchema hcatField : tblSchema.getFields()){
// We dont do type promotion/demotion.
Type hType = hcatField.getType();
switch(hType){
case SMALLINT:
case TINYINT:
case BOOLEAN:
throw new FrontendException("Incompatible type found in hcat table schema: "+hcatField, PigHCatUtil.PIG_EXCEPTION_CODE);