Program: 125347
Project: 125347
Buggy source:
/** 
 * @param in A field from an incoming schema
 * @return A MetadataColumn containing all the information from the Schema, including any information included theschema as JSON property annotations for Talend 6 generated schemas.
 */
public static org.talend.core.model.metadata.builder.connection.MetadataColumn convertFromAvro(Schema.Field field){
  org.talend.core.model.metadata.builder.connection.MetadataColumn col=ConnectionFactory.eINSTANCE.createMetadataColumn();
  Schema in=field.schema();
  col.setId(field.name());
  col.setLabel(field.name());
  col.setName(field.name());
  Schema nonnullable=AvroUtils.unwrapIfNullable(in);
  if (AvroUtils.isSameType(nonnullable,AvroUtils._boolean())) {
    col.setTalendType(JavaTypesManager.BOOLEAN.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._byte())) {
    col.setTalendType(JavaTypesManager.BYTE.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._bytes())) {
    col.setTalendType(JavaTypesManager.BYTE_ARRAY.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._character())) {
    col.setTalendType(JavaTypesManager.CHARACTER.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._date())) {
    col.setTalendType(JavaTypesManager.DATE.getId());
    TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_DATE_NO_LOGICAL_TYPE,"String_Node_Str");
    col.getTaggedValue().add(tv);
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._decimal())) {
    col.setTalendType(JavaTypesManager.BIGDECIMAL.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._double())) {
    col.setTalendType(JavaTypesManager.DOUBLE.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._float())) {
    col.setTalendType(JavaTypesManager.FLOAT.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._int())) {
    if (LogicalTypes.fromSchemaIgnoreInvalid(nonnullable) == LogicalTypes.date()) {
      col.setTalendType(JavaTypesManager.DATE.getId());
      TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_DATE_DATE,"String_Node_Str");
      col.getTaggedValue().add(tv);
    }
 else {
      col.setTalendType(JavaTypesManager.INTEGER.getId());
    }
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._long())) {
    if (LogicalTypes.fromSchemaIgnoreInvalid(nonnullable) == LogicalTypes.timestampMillis()) {
      col.setTalendType(JavaTypesManager.DATE.getId());
      TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_DATE_TIMESTAMP,"String_Node_Str");
      col.getTaggedValue().add(tv);
    }
 else {
      col.setTalendType(JavaTypesManager.LONG.getId());
    }
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._short())) {
    col.setTalendType(JavaTypesManager.SHORT.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._string())) {
    col.setTalendType(JavaTypesManager.STRING.getId());
  }
 else   if (nonnullable.getProp(SchemaConstants.JAVA_CLASS_FLAG) != null) {
    col.setTalendType(JavaTypesManager.OBJECT.getId());
  }
  col.setNullable(AvroUtils.isNullable(in));
  String prop;
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_ID))) {
    col.setId(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COMMENT))) {
    col.setComment(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_LABEL))) {
    col.setLabel(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_IS_READ_ONLY))) {
    TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_IS_READ_ONLY,prop);
    col.getTaggedValue().add(tv);
  }
  for (  String key : field.getJsonProps().keySet()) {
    if (key.startsWith(DiSchemaConstants.TALEND6_ADDITIONAL_PROPERTIES)) {
      String originalKey=key.substring(DiSchemaConstants.TALEND6_ADDITIONAL_PROPERTIES.length());
      TaggedValue tv=TaggedValueHelper.createTaggedValue(originalKey,field.getProp(key));
      col.getTaggedValue().add(tv);
    }
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_CUSTOM))) {
    TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_CUSTOM,prop);
    col.getTaggedValue().add(tv);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_IS_KEY))) {
    col.setKey(Boolean.parseBoolean(prop));
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_SOURCE_TYPE))) {
    col.setSourceType(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_TALEND_TYPE))) {
    col.setTalendType(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_PATTERN))) {
    if (!StringUtils.isEmpty(prop)) {
      col.setPattern(TalendQuoteUtils.addQuotesIfNotExist(prop));
    }
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_LENGTH))) {
    Long value=Long.parseLong(prop);
    col.setLength(value >= 0 ? value : -1);
  }
 else {
    col.setLength(-1);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_ORIGINAL_LENGTH))) {
    Long value=Long.parseLong(prop);
    col.setOriginalLength(value >= 0 ? value : -1);
  }
 else {
    col.setOriginalLength(-1);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_IS_NULLABLE))) {
    col.setNullable(Boolean.parseBoolean(prop));
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_PRECISION))) {
    Long value=Long.parseLong(prop);
    col.setPrecision(value >= 0 ? value : -1);
  }
 else {
    col.setPrecision(-1);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_SCALE))) {
    Long value=Long.parseLong(prop);
    col.setScale(value >= 0 ? value : -1);
  }
 else {
    col.setScale(-1);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_DEFAULT))) {
    col.setDefaultValue(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_ORIGINAL_DB_COLUMN_NAME))) {
    col.setName(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_RELATED_ENTITY))) {
    col.setRelatedEntity(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_RELATIONSHIP_TYPE))) {
    col.setRelationshipType(prop);
  }
  if (col.getTalendType() == null) {
    throw new UnsupportedOperationException("String_Node_Str" + in);
  }
  return col;
}

Fixed version (ground truth):
/** 
 * @param in A field from an incoming schema
 * @return A MetadataColumn containing all the information from the Schema, including any information included theschema as JSON property annotations for Talend 6 generated schemas.
 */
public static org.talend.core.model.metadata.builder.connection.MetadataColumn convertFromAvro(Schema.Field field){
  org.talend.core.model.metadata.builder.connection.MetadataColumn col=ConnectionFactory.eINSTANCE.createMetadataColumn();
  Schema in=field.schema();
  col.setId(field.name());
  col.setLabel(field.name());
  col.setName(field.name());
  Schema nonnullable=AvroUtils.unwrapIfNullable(in);
  LogicalType logicalType=LogicalTypes.fromSchemaIgnoreInvalid(nonnullable);
  if (AvroUtils.isSameType(nonnullable,AvroUtils._boolean())) {
    col.setTalendType(JavaTypesManager.BOOLEAN.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._byte())) {
    col.setTalendType(JavaTypesManager.BYTE.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._bytes())) {
    col.setTalendType(JavaTypesManager.BYTE_ARRAY.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._character())) {
    col.setTalendType(JavaTypesManager.CHARACTER.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._date())) {
    col.setTalendType(JavaTypesManager.DATE.getId());
    TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_DATE_NO_LOGICAL_TYPE,"String_Node_Str");
    col.getTaggedValue().add(tv);
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._decimal())) {
    col.setTalendType(JavaTypesManager.BIGDECIMAL.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._double())) {
    col.setTalendType(JavaTypesManager.DOUBLE.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._float())) {
    col.setTalendType(JavaTypesManager.FLOAT.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._int())) {
    if (logicalType == LogicalTypes.date()) {
      col.setTalendType(JavaTypesManager.DATE.getId());
      TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_DATE_DATE,"String_Node_Str");
      col.getTaggedValue().add(tv);
    }
 else {
      col.setTalendType(JavaTypesManager.INTEGER.getId());
    }
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._long())) {
    if (logicalType == LogicalTypes.timestampMillis()) {
      col.setTalendType(JavaTypesManager.DATE.getId());
      TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_DATE_TIMESTAMP,"String_Node_Str");
      col.getTaggedValue().add(tv);
    }
 else {
      col.setTalendType(JavaTypesManager.LONG.getId());
    }
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._short())) {
    col.setTalendType(JavaTypesManager.SHORT.getId());
  }
 else   if (AvroUtils.isSameType(nonnullable,AvroUtils._string())) {
    col.setTalendType(JavaTypesManager.STRING.getId());
  }
 else   if (nonnullable.getProp(SchemaConstants.JAVA_CLASS_FLAG) != null) {
    col.setTalendType(JavaTypesManager.OBJECT.getId());
  }
  col.setNullable(AvroUtils.isNullable(in));
  String prop;
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_ID))) {
    col.setId(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COMMENT))) {
    col.setComment(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_LABEL))) {
    col.setLabel(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_IS_READ_ONLY))) {
    TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_IS_READ_ONLY,prop);
    col.getTaggedValue().add(tv);
  }
  for (  String key : field.getJsonProps().keySet()) {
    if (key.startsWith(DiSchemaConstants.TALEND6_ADDITIONAL_PROPERTIES)) {
      String originalKey=key.substring(DiSchemaConstants.TALEND6_ADDITIONAL_PROPERTIES.length());
      TaggedValue tv=TaggedValueHelper.createTaggedValue(originalKey,field.getProp(key));
      col.getTaggedValue().add(tv);
    }
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_CUSTOM))) {
    TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_CUSTOM,prop);
    col.getTaggedValue().add(tv);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_IS_KEY))) {
    col.setKey(Boolean.parseBoolean(prop));
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_SOURCE_TYPE))) {
    col.setSourceType(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_TALEND_TYPE))) {
    col.setTalendType(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_PATTERN))) {
    if (!StringUtils.isEmpty(prop)) {
      col.setPattern(TalendQuoteUtils.addQuotesIfNotExist(prop));
    }
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_LENGTH))) {
    Long value=Long.parseLong(prop);
    col.setLength(value >= 0 ? value : -1);
  }
 else {
    col.setLength(-1);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_ORIGINAL_LENGTH))) {
    Long value=Long.parseLong(prop);
    col.setOriginalLength(value >= 0 ? value : -1);
  }
 else {
    col.setOriginalLength(-1);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_IS_NULLABLE))) {
    col.setNullable(Boolean.parseBoolean(prop));
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_PRECISION))) {
    Long value=Long.parseLong(prop);
    col.setPrecision(value >= 0 ? value : -1);
  }
 else {
    col.setPrecision(-1);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_SCALE))) {
    Long value=Long.parseLong(prop);
    col.setScale(value >= 0 ? value : -1);
  }
 else {
    col.setScale(-1);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_DEFAULT))) {
    col.setDefaultValue(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_ORIGINAL_DB_COLUMN_NAME))) {
    col.setName(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_RELATED_ENTITY))) {
    col.setRelatedEntity(prop);
  }
  if (null != (prop=field.getProp(DiSchemaConstants.TALEND6_COLUMN_RELATIONSHIP_TYPE))) {
    col.setRelationshipType(prop);
  }
  if (logicalType != null) {
    TaggedValue tv=TaggedValueHelper.createTaggedValue(DiSchemaConstants.TALEND6_COLUMN_LOGICAL_TYPE,logicalType.getName());
    col.getTaggedValue().add(tv);
  }
  if (col.getTalendType() == null) {
    throw new UnsupportedOperationException("String_Node_Str" + in);
  }
  return col;
}