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

Improve strict schema string match with smarter matching #621

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andyl-db
Copy link
Collaborator

@andyl-db andyl-db commented Dec 19, 2024

This PR improves the strict schema string match with smarter matching i.e. subset matching

Added unit test

Tested against DBR:
image

@andyl-db andyl-db force-pushed the tolerate-schema-subset branch 2 times, most recently from bb68ecb to ef53c76 Compare January 6, 2025 23:19
val newSchemaFieldNames = newSchemaFields.keySet
val currentSchemaFieldNames = currentSchemaFields.keySet

// Ensure that all the new schema field names are a subset of current schema field names
Copy link
Collaborator

Choose a reason for hiding this comment

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

is subset good enough?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel we could follow this Delta check in general. Right now I see few differences:

  1. For the Delta check, they ensure current schema fields are a subset new schema fields, but we're doing the opposite.
  2. They have checks on the nullability too.

I'm not familiar with the rationale behind the check either. Might worth to ask Ryan or Delta folks to make sure the change is safe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. Reversed the check
  2. Nullability is checked within DataType.equalsStructurally

field.name -> field.dataType
}).toMap

val schemaChangedException = new SparkException(
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: do we want to include the info of culprit field in the error message?

val newSchemaFieldNames = newSchemaFields.keySet
val currentSchemaFieldNames = currentSchemaFields.keySet

// Ensure that all the new schema field names are a subset of current schema field names
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel we could follow this Delta check in general. Right now I see few differences:

  1. For the Delta check, they ensure current schema fields are a subset new schema fields, but we're doing the opposite.
  2. They have checks on the nullability too.

I'm not familiar with the rationale behind the check either. Might worth to ask Ryan or Delta folks to make sure the change is safe.

@andyl-db andyl-db force-pushed the tolerate-schema-subset branch from ef53c76 to 781b9c3 Compare January 10, 2025 18:52
@andyl-db andyl-db force-pushed the tolerate-schema-subset branch from 781b9c3 to 0384302 Compare January 10, 2025 19:04
@andyl-db andyl-db requested a review from zsxwing January 10, 2025 19:11
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.

3 participants