kbendick commented on code in PR #4956:
URL: https://github.com/apache/iceberg/pull/4956#discussion_r889199722


##########
spark/v3.2/spark/src/main/java/org/apache/iceberg/spark/CommitMetadata.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.iceberg.spark;
+
+import java.util.Map;
+import java.util.concurrent.Callable;
+import org.apache.iceberg.relocated.com.google.common.collect.ImmutableMap;
+
+/**
+ * utility class to accept thread local commit properties
+ */
+public class CommitMetadata {
+  private static final ThreadLocal<Map<String, String>> COMMIT_PROPERTIES = 
ThreadLocal.withInitial(ImmutableMap::of);
+
+  public static <R> R withCommitProperties(Map<String, String> properties, 
Callable<R> callable) throws Exception {
+    COMMIT_PROPERTIES.set(properties);
+    try {
+      return callable.call();
+    } finally {
+      COMMIT_PROPERTIES.set(ImmutableMap.of());
+    }
+  }

Review Comment:
   I guess since this requires a `Callable`, then it's not a huge deal that the 
class only supports ThreadLocal CommitMetadata.
   
   But to not conflict with Structured Streaming's `CommitMetadata` (especially 
in Java programs that can't rename imports), it might be a good idea to update 
the name as mentioned above.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to