Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK] Support CTAS from a table with a deleted default value #4142

Conversation

olaky
Copy link
Contributor

@olaky olaky commented Feb 11, 2025

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

We are currently leaking values using the 'EXISTS_DEFAULT' config key that is used for default columns in Spark into table schemas. The 'EXISTS_DEFAULT' key holds values for rows that existed when a new column with a default value was added to the table. This use case is not supported in Delta.

In this PR, we remove the 'EXISTS_DEFAULT' entries every time we update the metadata of a table. This includes the case when a table is created. This ensures that new tables do not have 'EXISTS_DEFAULT' entries and operations that update metadata remove entries that existed before because previous versions added them.

This change also now allows us to CTAS from a table where a default value existed in the past but has been dropped. It does not enable CTAS from a table with an active default value.

The feature has a kill switch: REMOVE_EXISTS_DEFAULT_FROM_SCHEMA_ON_EVERY_METADATA_CHANGE

How was this patch tested?

Added new tests

Does this PR introduce any user-facing changes?

Previously it was not possible to CTAS from a table with a removed default without setting the delta.feature.allowColumnDefaults even though no default value was actually part of the new table. this is now possible.

@scottsand-db scottsand-db merged commit 6e9498c into delta-io:master Feb 26, 2025
18 of 21 checks passed
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.

4 participants