@Override
  public void initialize(Configuration configuration, Properties tableProperties, Properties partitionProperties)
      throws SerDeException {
    /*
     * Avro should always use the table properties for initialization (see
     * HIVE-6835). The tableProperties is modified directly by this SerDe when
     * the user supplies a schema file so do not make a copy.
     */
    super.initialize(configuration, tableProperties, null);

    // Reset member variables so we don't get in a half-constructed state
    if (schema != null) {
      LOG.debug("Resetting already initialized AvroSerDe");
    }

    LOG.debug("AvroSerde::initialize(): Preset value of avro.schema.literal == "
        + tableProperties.get(AvroSerdeUtils.AvroTableProperties.SCHEMA_LITERAL.getPropName()));

    schema = null;
    oi = null;
    columnNames = null;
    columnTypes = null;

    final String columnNameProperty = tableProperties.getProperty(serdeConstants.LIST_COLUMNS);
    final String columnTypeProperty = tableProperties.getProperty(serdeConstants.LIST_COLUMN_TYPES);
    final String columnCommentProperty = tableProperties.getProperty(LIST_COLUMN_COMMENTS, "");
    final String columnNameDelimiter = tableProperties.containsKey(serdeConstants.COLUMN_NAME_DELIMITER)
        ? tableProperties.getProperty(serdeConstants.COLUMN_NAME_DELIMITER)
        : String.valueOf(SerDeUtils.COMMA);

    boolean gotColTypesFromColProps = true;
    if (hasExternalSchema(tableProperties)
        || columnNameProperty == null || columnNameProperty.isEmpty()
        || columnTypeProperty == null || columnTypeProperty.isEmpty()) {
      schema = determineSchemaOrReturnErrorSchema(configuration, tableProperties);
      gotColTypesFromColProps = false;
    } else {
      // Get column names and sort order
      columnNames = StringInternUtils.internStringsInList(
          Arrays.asList(columnNameProperty.split(columnNameDelimiter)));
      columnTypes = TypeInfoUtils.getTypeInfosFromTypeString(columnTypeProperty);

      schema = getSchemaFromCols(tableProperties, columnNames, columnTypes, columnCommentProperty);
    }

    tableProperties.setProperty(AvroSerdeUtils.AvroTableProperties.SCHEMA_LITERAL.getPropName(), schema.toString());

    LOG.debug("Avro schema is: {}", schema);

    if (this.configuration.isPresent()) {
      this.configuration.get().set(AvroSerdeUtils.AvroTableProperties.AVRO_SERDE_SCHEMA.getPropName(),
          schema.toString(false));
    } else {
      LOG.debug("Configuration null, not inserting schema");
    }

    badSchema = (schema == SchemaResolutionProblem.SIGNAL_BAD_SCHEMA);

    AvroObjectInspectorGenerator aoig = new AvroObjectInspectorGenerator(schema);
    this.columnNames = StringInternUtils.internStringsInList(aoig.getColumnNames());
    this.columnTypes = aoig.getColumnTypes();
    this.oi = aoig.getObjectInspector();
    // HIVE-22595: Update the column/type properties to reflect the current, since the
    // these properties may be used
    if (!gotColTypesFromColProps) {
      LOG.info("Updating column name/type properties based on current schema");
      tableProperties.setProperty(serdeConstants.LIST_COLUMNS, String.join(",", columnNames));
      tableProperties.setProperty(serdeConstants.LIST_COLUMN_TYPES, String.join(",", TypeInfoUtils.getTypeStringsFromTypeInfo(columnTypes)));
    }

    if (badSchema) {
      throw new SerDeException("Invalid schema reported");
    }

    this.avroSerializer = new AvroSerializer(configuration);
    this.avroDeserializer = new AvroDeserializer(configuration);
  }
Read or write Avro data from Hive.
serde/src/java/org/apache/hadoop/hive/serde2/avro/AvroSerDe.java