# Hive动态分区插入时分区列的值被静默覆盖为NULL

- **ID:** `data/hive-partition-column-null-overwrite`
- **领域:** data
- **类别:** data_error
- **错误码:** `HIVE-16997`
- **验证级别:** ai_generated
- **修复率:** 82%

## 根因

在Hive INSERT OVERWRITE中使用动态分区时，如果SELECT子句中的分区列名与插入的列名匹配，分区列会被错误地解释为普通列，导致分区值被覆盖为NULL。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Apache Hive 3.1.2 | active | — | — |
| Apache Hive 4.0.0-alpha-1 | active | — | — |
| CDH 6.3.2 | active | — | — |

## 解决方案

1. ```
   Explicitly list the partition column in the SELECT clause with a different alias or use static partition assignment in the INSERT statement.
   ```
2. ```
   Use INSERT INTO with explicit partition specification instead of INSERT OVERWRITE, then manually clean duplicates.
   ```

## 无效尝试

- **** — Nonstrict mode bypasses validation but does not fix the column mapping, so data is still overwritten. (95% 失败率)
- **** — Hive's column resolution is based on names, not positions, so extra columns cause schema mismatch. (80% 失败率)
