-
Notifications
You must be signed in to change notification settings - Fork 3k
Spark 3.3: support write to WAP branch #7050
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,7 +98,22 @@ public String branch() { | |
| + "got [%s] in identifier and [%s] in options", | ||
| branch, | ||
| optionBranch); | ||
| return branch != null ? branch : optionBranch; | ||
| String inputBranch = branch != null ? branch : optionBranch; | ||
| if (inputBranch != null) { | ||
| return inputBranch; | ||
| } | ||
|
|
||
| boolean wapEnabled = | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I'd prefer a separate method called |
||
| PropertyUtil.propertyAsBoolean( | ||
| table.properties(), TableProperties.WRITE_AUDIT_PUBLISH_ENABLED, false); | ||
| if (wapEnabled) { | ||
| String wapBranch = spark.conf().get(SparkSQLProperties.WAP_BRANCH, null); | ||
| if (wapBranch != null && table.refs().containsKey(wapBranch)) { | ||
| return wapBranch; | ||
| } | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| public String tag() { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ | |
| import org.apache.iceberg.SnapshotSummary; | ||
| import org.apache.iceberg.Table; | ||
| import org.apache.iceberg.TableProperties; | ||
| import org.apache.iceberg.exceptions.ValidationException; | ||
| import org.apache.iceberg.relocated.com.google.common.collect.Maps; | ||
| import org.apache.spark.sql.RuntimeConfig; | ||
| import org.apache.spark.sql.SparkSession; | ||
|
|
@@ -128,7 +129,7 @@ public boolean wapEnabled() { | |
| } | ||
|
|
||
| public String wapId() { | ||
| return sessionConf.get("spark.wap.id", null); | ||
| return sessionConf.get(SparkSQLProperties.WAP_ID, null); | ||
| } | ||
|
|
||
| public boolean mergeSchema() { | ||
|
|
@@ -333,6 +334,28 @@ public boolean caseSensitive() { | |
| } | ||
|
|
||
| public String branch() { | ||
| if (wapEnabled()) { | ||
| String wapId = wapId(); | ||
| String wapBranch = | ||
| confParser.stringConf().sessionConf(SparkSQLProperties.WAP_BRANCH).parseOptional(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: What about a separate method like we have for |
||
|
|
||
| ValidationException.check( | ||
| wapId == null || wapBranch == null, | ||
| "Cannot set both WAP ID and branch, but got ID [%s] and branch [%s]", | ||
| wapId, | ||
| wapBranch); | ||
|
|
||
| if (wapBranch != null) { | ||
| ValidationException.check( | ||
| branch == null, | ||
| "Cannot write to both branch and WAP branch, but got branch [%s] and WAP branch [%s]", | ||
| branch, | ||
| wapBranch); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this behavior is a blocker because it is strict, but I would expect to be able to write to another branch with the WAP branch set. I'm curious what other people think the long-term behavior should be. I think this behavior does help ensure that there are no side-effects, which is good if you want people to trust the pattern. But that's undermined by enabling/disabling WAP on a per-table basis.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you! I added issue #7103 and we can discuss there with related people.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like a reasonable starting point to me. |
||
|
|
||
| return wapBranch; | ||
| } | ||
| } | ||
|
|
||
| return branch; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.