Skip to content

Commit

Permalink
https://github.com/gbif/pipelines/issues/1047
Browse files Browse the repository at this point in the history
  • Loading branch information
fmendezh committed Apr 9, 2024
1 parent ab25c91 commit 35c47e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void updateStatus(String downloadKey, Status status) {
updateDownload(download);
} else {
log.debug(
"Skiping downloads status updating for download {}, status is already {}",
"Skipping downloads status updating for download {}, status is already {}",
downloadKey,
status);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,17 @@ public class CleanDelimiterArraysUdf implements UDF1<WrappedArray<String>,String

@Override
public String[] call(WrappedArray<String> field) throws Exception {
return field != null? JavaConverters.asJavaCollection(field).stream()
.map(CLEAN_DELIMITERS)
.filter(s -> s != null && !s.isEmpty())
.toArray(String[]::new) : null;
return field != null && !field.isEmpty()? toArray(field) : null;
}

/**
* Converts to an array, returns null if the produced array is empty.
*/
private String[] toArray(WrappedArray<String> field) {
String[] value = JavaConverters.asJavaCollection(field).stream()
.map(CLEAN_DELIMITERS)
.filter(s -> s != null && !s.isEmpty())
.toArray(String[]::new);
return value.length > 0? value : null;
}
}

0 comments on commit 35c47e9

Please sign in to comment.