You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by "namrathamyske (via GitHub)" <gi...@apache.org> on 2023/03/01 16:36:31 UTC

[GitHub] [iceberg] namrathamyske commented on a diff in pull request #6965: Spark 3.3: Support write to branch through table identifier

namrathamyske commented on code in PR #6965:
URL: https://github.com/apache/iceberg/pull/6965#discussion_r1122023370


##########
spark/v3.3/spark/src/main/java/org/apache/iceberg/spark/Spark3Util.java:
##########
@@ -1017,4 +1019,41 @@ public String unknown(
       return String.format("%s(%s) %s %s", transform, sourceName, direction, nullOrder);
     }
   }
+
+  public static Map<String, String> buildWriteOptions(String branch, LogicalWriteInfo info) {
+    ImmutableMap.Builder<String, String> builder =
+        ImmutableMap.<String, String>builder().putAll(info.options());
+
+    if (branch != null) {
+      String optionBranch = info.options().get(SparkReadOptions.BRANCH);
+      if (optionBranch == null) {
+        builder.put(SparkWriteOptions.BRANCH, branch);
+      } else if (!optionBranch.equals(branch)) {
+        throw new ValidationException(
+            "Cannot override branch to write more than once, received %s in identifier and %s in write options",
+            branch, optionBranch);
+      }
+    }
+
+    return builder.build();
+  }
+
+  public static CaseInsensitiveStringMap buildScanOptions(
+      String branch, CaseInsensitiveStringMap options) {
+    ImmutableMap.Builder<String, String> builder =
+        ImmutableMap.<String, String>builder().putAll(options);
+
+    if (branch != null) {
+      String optionBranch = options.get(SparkReadOptions.BRANCH);
+      if (optionBranch == null) {
+        builder.put(SparkReadOptions.BRANCH, branch);
+      } else if (!optionBranch.equals(branch)) {
+        throw new ValidationException(
+            "Cannot override branch to read more than once, received %s in identifier and %s in scan options",

Review Comment:
   I agree that we should still keep spark read options. Waiting for others to reply.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org