Skip to content

Commit 069a7cc

Browse files
authored
[UniForm] Refactor IcebergCompat (delta-io#4341)
<!-- Thanks for sending a pull request! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: https://github.com/delta-io/delta/blob/master/CONTRIBUTING.md 2. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP] Your PR title ...'. 3. Be sure to keep the PR description updated to reflect all changes. 4. Please write your PR title to summarize what this PR proposes. 5. If possible, provide a concise example to reproduce the issue for a faster review. 6. If applicable, include the corresponding issue number in the PR title and link it in the body. --> #### Which Delta project/connector is this regarding? <!-- Please add the component selected below to the beginning of the pull request title For example: [Spark] Title of my pull request --> - [x] Spark - [ ] Standalone - [ ] Flink - [ ] Kernel - [ ] Other (fill in here) ## Description This PR refactors the UniForm IcebergCompat <!-- - Describe what this PR changes. - Describe why we need the change. If this PR resolves an issue be sure to include "Resolves #XXX" to correctly link and close the issue upon merge. --> ## How was this patch tested? UT <!-- If tests were added, say they were added here. Please make sure to test the changes thoroughly including negative and positive cases if possible. If the changes were tested in any way other than unit tests, please clarify how you tested step by step (ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future). If the changes were not tested, please explain why. --> ## Does this PR introduce _any_ user-facing changes? No <!-- If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible. If possible, please also clarify if this is a user-facing change compared to the released Delta Lake versions or within the unreleased branches such as master. If no, write 'No'. -->
1 parent b08e8ba commit 069a7cc

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

spark/src/main/scala/org/apache/spark/sql/delta/IcebergCompat.scala

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,10 @@ case class IcebergCompatBase(
149149
if (isCreatingOrReorgTable) {
150150
tblFeatureUpdates += f
151151
} else {
152-
throw DeltaErrors.icebergCompatMissingRequiredTableFeatureException(version, f)
152+
handleMissingTableFeature(f)
153153
}
154154
case (true, false) => // txn is removing/un-supporting it!
155-
throw DeltaErrors.icebergCompatDisablingRequiredTableFeatureException(version, f)
155+
handleDisablingRequiredTableFeature(f)
156156
}
157157
}
158158

@@ -163,9 +163,6 @@ case class IcebergCompatBase(
163163
val newestValueOkay = validator(newestValue)
164164
val newestValueExplicitlySet = newestMetadata.configuration.contains(deltaConfig.key)
165165

166-
val err = DeltaErrors.icebergCompatWrongRequiredTablePropertyException(
167-
version, deltaConfig.key, newestValue.toString, autoSetValue)
168-
169166
if (!newestValueOkay) {
170167
if (!newestValueExplicitlySet && isCreatingOrReorgTable) {
171168
// This case covers both CREATE and REPLACE TABLE commands that
@@ -175,7 +172,8 @@ case class IcebergCompatBase(
175172
} else {
176173
// In all other cases, if the property value is not compatible
177174
// with the IcebergV1 requirements, we fail
178-
throw err
175+
handleMissingRequiredTableProperties(
176+
deltaConfig.key, newestValue.toString, autoSetValue)
179177
}
180178
}
181179
}
@@ -218,6 +216,17 @@ case class IcebergCompatBase(
218216
(protocolResult, metadataResult)
219217
}
220218
}
219+
220+
protected def handleMissingTableFeature(feature: TableFeature): Unit =
221+
throw DeltaErrors.icebergCompatMissingRequiredTableFeatureException(version, feature)
222+
223+
protected def handleDisablingRequiredTableFeature(feature: TableFeature): Unit =
224+
throw DeltaErrors.icebergCompatDisablingRequiredTableFeatureException(version, feature)
225+
226+
protected def handleMissingRequiredTableProperties(
227+
confKey: String, actualVal: String, requiredVal: String): Unit =
228+
throw DeltaErrors.icebergCompatWrongRequiredTablePropertyException(
229+
version, confKey, actualVal, requiredVal)
221230
}
222231

223232
/**

0 commit comments

Comments
 (0)