Skip to content

[SPARK-59342][SQL] Allow configuring schema alignment behavior for DSv2 writes - #58632

Draft
johanl-db wants to merge 1 commit into
apache:masterfrom
johanl-db:schema-alignment-config
Draft

[SPARK-59342][SQL] Allow configuring schema alignment behavior for DSv2 writes#58632
johanl-db wants to merge 1 commit into
apache:masterfrom
johanl-db:schema-alignment-config

Conversation

@johanl-db

@johanl-db johanl-db commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This changes extends the DSv2 connector interface to allow connectors to configure schema alignment behavior and opt-out of the default behavior when required:

  • spark.sql.storeAssignmentPolicy=LEGACY being rejected for DSv2 writes.
  • Strict implicit casts check at analysis time for DSv2 writes under sparksql.storeAssignmentPolicy=ANSI

Extending the Table interface:

public interface Table {
 ...
  default SchemaAlignmentConfig schemaAlignmentConfig() {
     return SchemaAlignmentConfig.DEFAULT;   }
}

public interface SchemaAlignmentConfig {
  default boolean allowLegacyStoreAssignmentPolicy() {
     return false;
   }

  default boolean deferCastValidationToRuntime() {
     return false;
   }
}

Why are the changes needed?

Delta is migrating to DSv2, and historically has always allowed:

  • writes under spark.sql.storeAssignmentPolicy=LEGACY
  • Many implicit casts at analysis, relying instead on execution time checks to catch malformed values or overflows.

Without a way to configure this. behavior, this effectively blocks migrating Delta to DSv2.

How was this patch tested?

Add Spark suite SchemaAlignmentConfigSuite covering the configuration mechanism
Add Delta DSv2 variant of existing DeltaInsertIntoImplicitCastSuite, showing that casting behavior is preserved when running on DSv2.

@johanl-db johanl-db changed the title Allow configuring schema alignment behavior for DSv2 writes [SQL] Allow configuring schema alignment behavior for DSv2 writes Sep 8, 2026
@johanl-db johanl-db changed the title [SQL] Allow configuring schema alignment behavior for DSv2 writes [SPARK-59342][SQL] Allow configuring schema alignment behavior for DSv2 writes Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant