if (fs.type != DataType.BYTEARRAY) {
if(determinedSchema == null || (fs.type != determinedSchema.getField(i).type)) {
// Either no schema was determined by loader OR the type
// from the "determinedSchema" is different
// from the type specified - so we need to cast
LOCast cast = new LOCast(p,
OperatorKey.genOpKey(scope), fs.type);
cast.setFieldSchema(fs);
p.add(cast);
p.connect(proj, cast);
cast.setFieldSchema(fs.clone());
FuncSpec loadFuncSpec = null;
if(lo instanceof LOLoad) {
loadFuncSpec = ((LOLoad)lo).getInputFile().getFuncSpec();
} else if (lo instanceof LOStream) {
StreamingCommand command = ((LOStream)lo).getStreamingCommand();
HandleSpec streamOutputSpec = command.getOutputSpec();
loadFuncSpec = new FuncSpec(streamOutputSpec.getSpec());
} else {
int errCode = 2006;
String msg = "TypeCastInserter invoked with an invalid operator class name: " + lo.getClass().getSimpleName();
throw new OptimizerException(msg, errCode, PigException.BUG);
}
cast.setLoadFuncSpec(loadFuncSpec);
typeChanges.put(fs.canonicalName, fs.type);
if(determinedSchema == null) {
// Reset the loads field schema to byte array so that it
// will reflect reality.
fs.type = DataType.BYTEARRAY;