# Avro模式演变在字段类型从int变为long时失败

- **ID:** `data/avro-schema-evolution-field-type-change`
- **领域:** data
- **类别:** schema_error
- **错误码:** `AVRO_SCHEMA_EVOLUTION_TYPE_MISMATCH`
- **验证级别:** ai_generated
- **修复率:** 75%

## 根因

Avro模式演变不允许将字段类型从int改为long而没有自定义转换，因为这违反了向后兼容性规则。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Apache Avro 1.11.0 | active | — | — |
| Confluent Schema Registry 7.5.0 | active | — | — |

## 解决方案

1. ```
   Define a new field with the target type (e.g., 'new_field' as long) and deprecate the old field. Update producers to write to the new field and consumers to read from both.
   ```
2. ```
   Use a custom logical type conversion in the schema registry to handle int-to-long promotion, e.g., by setting `avro.schema.conversion` property.
   ```

## 无效尝试

- **** — Simply adding a default value to the field does not resolve the type change issue because Avro checks the type compatibility first. (80% 失败率)
- **** — Deleting and recreating the schema entirely breaks existing data streams and requires reprocessing all historical data. (90% 失败率)
