nastra commented on a change in pull request #2664:
URL: https://github.com/apache/iceberg/pull/2664#discussion_r649281347
##########
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:
you're right about returning an empty string being a red flag. Actually
it's completely fine if the author can't be found and therefore is set to
`null` in the `CommitMeta`. I'll remove returning an empty string and annotate
`getCommitAuthor()` with `@Nullable`
--
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]