Skip to content

Conversation

@geruh
Copy link
Contributor

@geruh geruh commented Oct 23, 2025

This PR adds support for default values in Spark. During the conversion of an Iceberg schema to Spark's StructType, default values are now passed through to Spark's column metadata using the CURRENT_DEFAULT and EXISTS_DEFAULT keys that Spark recognizes.

The changes extend TypeToSparkType() function to extract default values from Iceberg fields and convert them to Spark SQL string representations, enabling Spark to understand and utilize the defaults that were defined in Iceberg.

Tests for initial defaults weren't added here since that functionality already works without these changes. So I'll follow up with some to be added to this new test suite.

Note: The current tests focus on default Write capabilities as partial column inserts for DSV2 tables aren't available until Spark 4.1.0 per apache/spark#50044.

@github-actions github-actions bot added the spark label Oct 23, 2025
Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I think this looks pretty good for the first part of respecting default values in Spark. Just some minor comments
Thank you @geruh !

@huaxingao
Copy link
Contributor

@geruh Thanks for the PR! It looks good to me overall. Just left a few minor comments.

@amogh-jahagirdar amogh-jahagirdar changed the title Spark: Add schema conversion support for default values Spark 4.0: Add schema conversion support for default values Oct 29, 2025
Copy link
Contributor

@amogh-jahagirdar amogh-jahagirdar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @geruh, I'll leave it up for a bit in case anyone else has any comments.

@amogh-jahagirdar
Copy link
Contributor

Thanks @geruh and @huaxingao for reviewing!

@amogh-jahagirdar amogh-jahagirdar merged commit a99dc4f into apache:main Oct 29, 2025
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants