private Schema createAvroPrimitive(TypeInfo typeInfo) {
    PrimitiveTypeInfo primitiveTypeInfo = (PrimitiveTypeInfo) typeInfo;
    Schema schema;
    switch (primitiveTypeInfo.getPrimitiveCategory()) {
      case STRING:
        schema = Schema.create(Schema.Type.STRING);
        break;
      case CHAR:
        schema = AvroSerdeUtils.getSchemaFor("{" +
            "\"type\":\"" + AvroSerDe.AVRO_STRING_TYPE_NAME + "\"," +
            "\"logicalType\":\"" + AvroSerDe.CHAR_TYPE_NAME + "\"," +
            "\"maxLength\":" + ((CharTypeInfo) typeInfo).getLength() + "}");
        break;
      case VARCHAR:
        schema = AvroSerdeUtils.getSchemaFor("{" +
            "\"type\":\"" + AvroSerDe.AVRO_STRING_TYPE_NAME + "\"," +
            "\"logicalType\":\"" + AvroSerDe.VARCHAR_TYPE_NAME + "\"," +
            "\"maxLength\":" + ((VarcharTypeInfo) typeInfo).getLength() + "}");
        break;
      case BINARY:
        schema = Schema.create(Schema.Type.BYTES);
        break;
      case BYTE:
        schema = Schema.create(Schema.Type.INT);
        break;
      case SHORT:
        schema = Schema.create(Schema.Type.INT);
        break;
      case INT:
        schema = Schema.create(Schema.Type.INT);
        break;
      case LONG:
        schema = Schema.create(Schema.Type.LONG);
        break;
      case FLOAT:
        schema = Schema.create(Schema.Type.FLOAT);
        break;
      case DOUBLE:
        schema = Schema.create(Schema.Type.DOUBLE);
        break;
      case BOOLEAN:
        schema = Schema.create(Schema.Type.BOOLEAN);
        break;
      case DECIMAL:
        DecimalTypeInfo decimalTypeInfo = (DecimalTypeInfo) typeInfo;
        String precision = String.valueOf(decimalTypeInfo.precision());
        String scale = String.valueOf(decimalTypeInfo.scale());
        schema = AvroSerdeUtils.getSchemaFor("{" +
            "\"type\":\"bytes\"," +
            "\"logicalType\":\"decimal\"," +
            "\"precision\":" + precision + "," +
            "\"scale\":" + scale + "}");
        break;
      case DATE:
        schema = AvroSerdeUtils.getSchemaFor("{" +
            "\"type\":\"" + AvroSerDe.AVRO_INT_TYPE_NAME + "\"," +
            "\"logicalType\":\"" + AvroSerDe.DATE_TYPE_NAME + "\"}");
        break;
      case TIMESTAMP:
        schema = AvroSerdeUtils.getSchemaFor("{" +
          "\"type\":\"" + AvroSerDe.AVRO_LONG_TYPE_NAME + "\"," +
          "\"logicalType\":\"" + AvroSerDe.TIMESTAMP_TYPE_NAME + "\"}");
        break;
      case VOID:
        schema = Schema.create(Schema.Type.NULL);
        break;
      default:
        throw new UnsupportedOperationException(typeInfo + " is not supported.");
    }
    return schema;
  }
Converts Hive schema to avro schema

@param columnNames Names of the hive columns
@param columnTypes Hive Column types
@param namespace   Namespace of Avro schema
@param name        Avro schema name
@param doc         Avro schema doc
@return Avro Schema
serde/src/java/org/apache/hadoop/hive/serde2/avro/TypeInfoToSchema.java