rdblue commented on a change in pull request #2664:
URL: https://github.com/apache/iceberg/pull/2664#discussion_r648769586



##########
File path: nessie/src/main/java/org/apache/iceberg/nessie/NessieUtil.java
##########
@@ -82,10 +90,25 @@ static ContentsKey toKey(TableIdentifier tableIdentifier) {
     return key;
   }
 
+  static CommitMeta buildCommitMetadata(String commitMsg, Map<String, String> 
catalogOptions) {
+    Preconditions.checkArgument(null != catalogOptions, "catalogOptions must 
not be null");
+    ImmutableCommitMeta.Builder cm = CommitMeta.builder().message(commitMsg)
+        .author(NessieUtil.getCommitAuthor(catalogOptions));
+    cm.putProperties("application.type", "iceberg");
+    if (catalogOptions.containsKey(SPARK_APP_ID)) {
+      cm.putProperties("spark.app.id", catalogOptions.get(SPARK_APP_ID));
+    }
+
+    return cm.build();
+  }
+
   /**
-   * @return The current OS user as defined by the system property 
<b>user.name</b> or an empty string
+   * @param catalogOptions The options where to look for the <b>spark.user</b>
+   * @return The author that can be used for a commit, which is either the 
<b>spark.user</b> from the given
+   * <code>catalogOptions</code> or the logged in user as defined in the 
<b>user.name</b> JVM properties.
    */
-  static String getCommitAuthor() {
-    return System.getProperty("user.name", "");
+  private static String getCommitAuthor(Map<String, String> catalogOptions) {

Review comment:
       Why not return an `Option`? Returning an empty string is a red flag that 
you're producing bad data. If `.author` in `buildCommitMetadata` is required, 
then it would be better to put the empty string there and add a comment 
explaining that it is required by the Nessie API.




-- 
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.

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