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

feat: implement logic to determine super types between iceberg types #50412

Open
wants to merge 6 commits into
base: iceberg-schema-comparator
Choose a base branch
from

Conversation

subodh1810
Copy link
Contributor

@subodh1810 subodh1810 commented Dec 24, 2024

@subodh1810 subodh1810 self-assigned this Dec 24, 2024
@subodh1810 subodh1810 requested a review from a team as a code owner December 24, 2024 10:02
Copy link

vercel bot commented Dec 24, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
airbyte-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 25, 2024 4:54am

@subodh1810 subodh1810 changed the title Iceberg schema supertype finder feat: implement logic to determine super types between iceberg types Dec 24, 2024
Comment on lines 69 to 77
private fun validateTypeIds(typeId1: TypeID, typeId2: TypeID) {
val unsupportedTypeIds = setOf(BINARY, DECIMAL, FIXED, UUID, MAP, TIMESTAMP_NANO)
if (typeId1 in unsupportedTypeIds || typeId2 in unsupportedTypeIds) {
val badTypeId = if (typeId1 in unsupportedTypeIds) typeId1 else typeId2
throw IllegalArgumentException(
"Unsupported or unmapped Iceberg type: $badTypeId. Please implement handling if needed."
)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I find this slightly easier to read:

Suggested change
private fun validateTypeIds(typeId1: TypeID, typeId2: TypeID) {
val unsupportedTypeIds = setOf(BINARY, DECIMAL, FIXED, UUID, MAP, TIMESTAMP_NANO)
if (typeId1 in unsupportedTypeIds || typeId2 in unsupportedTypeIds) {
val badTypeId = if (typeId1 in unsupportedTypeIds) typeId1 else typeId2
throw IllegalArgumentException(
"Unsupported or unmapped Iceberg type: $badTypeId. Please implement handling if needed."
)
}
}
private fun validateTypeIds(typeId1: TypeID, typeId2: TypeID) {
val unsupportedTypes = setOf(BINARY, DECIMAL, FIXED, UUID, MAP, TIMESTAMP_NANO)
val providedTypes = listOf(typeId1, typeId2)
val foundUnsupported = providedTypes.filter { it in unsupportedTypes }
if (foundUnsupported.isNotEmpty()) {
throw IllegalArgumentException(
"Unsupported or unmapped Iceberg type(s): ${foundUnsupported.joinToString()}. Please implement handling if needed."
)
}
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

validateTypeIds(existingTypeId, incomingTypeId)

// If promotion is not allowed by Iceberg, fail fast.
if (!TypeUtil.isPromotionAllowed(existingType, incomingType)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be happening even before validateTypeIds?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants