You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by "vamsikarnika (via GitHub)" <gi...@apache.org> on 2026/07/21 06:33:34 UTC
[PR] fix: relax existing column to nullable in reconcileSchema when source made it nullable [hudi]
vamsikarnika opened a new pull request, #19337:
URL: https://github.com/apache/hudi/pull/19337
### Change Logs
`AvroSchemaEvolutionUtils.reconcileSchema` — invoked from `HoodieSchemaUtils.deduceWriterSchema` when `hoodie.write.set.null.for.missing.columns=true` — rebuilds the writer schema **from the existing table schema** and only altered a shared column on a *data-type* change (`findType` ignores nullability). As a result, an existing column that the incoming/source schema relaxed from **required → nullable** stayed `REQUIRED` in the table indefinitely, so records arriving with `null` in that column failed record creation (and, where an error table is configured, were routed to the quarantine table).
Note the `set.null.for.missing.columns=false` path already preserved the relaxation (it uses the canonicalized source schema directly); only the `=true` path silently dropped it.
**Fix:** in `reconcileSchema`, detect existing columns whose incoming schema is nullable but the table is required (`nullabilityRelaxColumns`), exclude them from the early-return short-circuit, and relax them to nullable in the result via `updateColumnNullability(col, true)`. This **only ever widens, never tightens** (a nullable→required incoming leaves the table nullable), consistent with `reconcileSchemaRequirements`, and still null-fills genuinely missing columns.
Tests:
- `TestAvroSchemaEvolutionUtils` — direct `reconcileSchema` relax assertion + a no-tighten guard.
- `TestHoodieSchemaUtils` — end-to-end `deduceWriterSchema`, parameterized over the flag.
- Verified both new relax-cases **fail without the change** (`expected optional boolean but was required boolean`); full `TestAvroSchemaEvolutionUtils` (15) + `TestHoodieSchemaUtils` (11) pass with it.
### Impact
Tables ingesting via the streamer/datasource with `set.null.for.missing.columns=true` will now correctly evolve an existing column to nullable when the source relaxes it, instead of leaving it required and failing/quarantining null-bearing records. Widening-only; no existing column is ever tightened, and missing-column null-filling is unchanged.
### Risk level: low
Change is confined to `reconcileSchema` and only relaxes nullability of a shared column when the incoming schema is already nullable — a backwards-compatible schema widening. Covered by new unit tests and the existing `AvroSchemaEvolutionUtils` / `HoodieSchemaUtils` suites.
### Documentation Update
None required — behavior now matches the documented intent of schema evolution (a valid required→nullable relaxation should be applied).
### Contributor's checklist
- [x] Read through [contributor's guide](https://hudi.apache.org/contribute/how-to-contribute)
- [x] Change Logs and Impact were stated clearly
- [x] Adequate tests were added (unit tests, incl. a failing-without-fix check)
- [x] CI passes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Schema evolution: relax existing column to nullable in reconcileSchema [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19337:
URL: https://github.com/apache/hudi/pull/19337#issuecomment-5031469890
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587",
"triggerID" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"triggerType" : "PUSH"
}, {
"hash" : "41a56ac35cf54467bd472f2f1d242bc9c485d370",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15590",
"triggerID" : "41a56ac35cf54467bd472f2f1d242bc9c485d370",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6f203f3e47654ff2054adcfee7829e4d8fc0eea0 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587)
* 41a56ac35cf54467bd472f2f1d242bc9c485d370 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15590)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Schema evolution: relax existing column to nullable in reconcileSchema [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19337:
URL: https://github.com/apache/hudi/pull/19337#issuecomment-5030970413
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587",
"triggerID" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6f203f3e47654ff2054adcfee7829e4d8fc0eea0 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Schema evolution: relax existing column to nullable in reconcileSchema [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19337:
URL: https://github.com/apache/hudi/pull/19337#issuecomment-5030933172
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6f203f3e47654ff2054adcfee7829e4d8fc0eea0 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Schema evolution: relax existing column to nullable in reconcileSchema [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19337:
URL: https://github.com/apache/hudi/pull/19337#issuecomment-5032453648
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587",
"triggerID" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"triggerType" : "PUSH"
}, {
"hash" : "41a56ac35cf54467bd472f2f1d242bc9c485d370",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15590",
"triggerID" : "41a56ac35cf54467bd472f2f1d242bc9c485d370",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6f203f3e47654ff2054adcfee7829e4d8fc0eea0 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587)
* 41a56ac35cf54467bd472f2f1d242bc9c485d370 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15590)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Schema evolution: relax existing column to nullable in reconcileSchema [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19337:
URL: https://github.com/apache/hudi/pull/19337#issuecomment-5031010390
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"status" : "PENDING",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587",
"triggerID" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"triggerType" : "PUSH"
}, {
"hash" : "41a56ac35cf54467bd472f2f1d242bc9c485d370",
"status" : "UNKNOWN",
"url" : "TBD",
"triggerID" : "41a56ac35cf54467bd472f2f1d242bc9c485d370",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 6f203f3e47654ff2054adcfee7829e4d8fc0eea0 Azure: [PENDING](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587)
* 41a56ac35cf54467bd472f2f1d242bc9c485d370 UNKNOWN
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Schema evolution: relax existing column to nullable in reconcileSchema [hudi]
Posted by "hudi-agent (via GitHub)" <gi...@apache.org>.
hudi-agent commented on code in PR #19337:
URL: https://github.com/apache/hudi/pull/19337#discussion_r3624524080
##########
hudi-common/src/main/java/org/apache/hudi/common/schema/internal/utils/AvroSchemaEvolutionUtils.java:
##########
@@ -78,7 +78,19 @@ public static InternalSchema reconcileSchema(HoodieSchema incomingSchema, Intern
.stream()
.filter(f -> colNamesFromOldSchema.contains(f) && !inComingInternalSchema.findType(f).equals(oldTableSchema.findType(f)))
.collect(Collectors.toList());
- if (colNamesFromIncoming.size() == colNamesFromOldSchema.size() && diffFromOldSchema.size() == 0 && typeChangeColumns.isEmpty()) {
+ // check columns the incoming schema relaxed from required to nullable. Since the result is built from
+ // oldTableSchema (to preserve column order/ids and to null-fill missing columns), an existing column
+ // whose incoming counterpart became nullable would otherwise silently keep the table's REQUIRED
+ // nullability, blocking a valid required -> nullable evolution. We only ever relax (never tighten).
+ List<String> nullabilityRelaxColumns = colNamesFromIncoming
Review Comment:
🤖 nit: `nullabilityRelaxColumns` reads a bit oddly because `relax` is a verb — could you rename it to `relaxedToNullableColumns` (or `nullabilityRelaxedColumns`) to make it clear this is a list of columns *that have been* relaxed, matching the past-tense-adjective pattern of `typeChangeColumns` nearby?
<sub><i>⚠️ AI-generated; verify before applying. React 👍/👎 to flag quality.</i></sub>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Schema evolution: relax existing column to nullable in reconcileSchema [hudi]
Posted by "hudi-bot (via GitHub)" <gi...@apache.org>.
hudi-bot commented on PR #19337:
URL: https://github.com/apache/hudi/pull/19337#issuecomment-5032700330
<!--
Meta data
{
"version" : 1,
"metaDataEntries" : [ {
"hash" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"status" : "DELETED",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15587",
"triggerID" : "6f203f3e47654ff2054adcfee7829e4d8fc0eea0",
"triggerType" : "PUSH"
}, {
"hash" : "41a56ac35cf54467bd472f2f1d242bc9c485d370",
"status" : "SUCCESS",
"url" : "https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15590",
"triggerID" : "41a56ac35cf54467bd472f2f1d242bc9c485d370",
"triggerType" : "PUSH"
} ]
}-->
## CI report:
* 41a56ac35cf54467bd472f2f1d242bc9c485d370 Azure: [SUCCESS](https://dev.azure.com/apachehudi/a1a51da7-8592-47d4-88dc-fd67bed336bb/_build/results?buildId=15590)
<details>
<summary>Bot commands</summary>
@hudi-bot supports the following commands:
- `@hudi-bot run azure` re-run the last Azure build
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix: Schema evolution: relax existing column to nullable in reconcileSchema [hudi]
Posted by "nsivabalan (via GitHub)" <gi...@apache.org>.
nsivabalan merged PR #19337:
URL: https://github.com/apache/hudi/pull/19337
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@hudi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org