yaooqinn opened a new pull request, #54597: URL: https://github.com/apache/spark/pull/54597
### What changes were proposed in this pull request? Followup to #54517. Simplifies NOT NULL constraint preservation per review feedback. Instead of calling `dataSchema.asNullable` in `resolveRelation()` and then restoring nullability from the user schema in `CreateDataSourceTableCommand`, this PR adds a `forceNullable` parameter to `resolveRelation()` and passes `false` from the create-table path. This eliminates `restoreNullability` and `restoreDataTypeNullability` helper methods entirely (-37 lines net). **Data flow (unchanged behavior):** - **CREATE TABLE**: `resolveRelation(forceNullable = false)` → schema preserves NOT NULL → stored in catalog ✓ - **READ**: `resolveRelation()` (default `forceNullable = true`) → `asNullable` → safe reads ✓ - **INSERT**: catalog schema (NOT NULL) → `PreprocessTableInsertion` restores nullability → `AssertNotNull` ✓ ### Why are the changes needed? Addresses review feedback from cloud-fan on #54517: "is it simpler to not do `dataSchema.asNullable` if the flag is on?" ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Existing SPARK-55716 tests (7 tests in InsertSuite) all pass. ShowCreateTableSuite (30 tests) passes. ### Was this patch authored or co-authored using generative AI tooling? Yes, co-authored with GitHub Copilot. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
