Lehel44 commented on a change in pull request #5038:
URL: https://github.com/apache/nifi/pull/5038#discussion_r644268396
##########
File path:
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/UpdateRecord.java
##########
@@ -159,14 +397,19 @@ protected Record process(Record record, final FlowFile
flowFile, final ProcessCo
if (evaluateValueAsRecordPath) {
final String replacementValue =
context.getProperty(recordPathText).evaluateAttributeExpressions(flowFile).getValue();
- final RecordPath replacementRecordPath =
recordPathCache.getCompiled(replacementValue);
-
- // If we have an Absolute RecordPath, we need to evaluate the
RecordPath only once against the Record.
- // If the RecordPath is a Relative Path, then we have to
evaluate it against each FieldValue.
- if (replacementRecordPath.isAbsolute()) {
- record = processAbsolutePath(replacementRecordPath,
result.getSelectedFields(), record);
+ if ("".equals(replacementValue)) {
+ List<FieldValue> selectedFields =
result.getSelectedFields().collect(Collectors.toList());
+ record = remove(record, selectedFields);
} else {
- record = processRelativePath(replacementRecordPath,
result.getSelectedFields(), record);
+ final RecordPath replacementRecordPath =
recordPathCache.getCompiled(replacementValue);
+
+ // If we have an Absolute RecordPath, we need to evaluate
the RecordPath only once against the Record.
+ // If the RecordPath is a Relative Path, then we have to
evaluate it against each FieldValue.
+ if (replacementRecordPath.isAbsolute()) {
+ record = processAbsolutePath(replacementRecordPath,
result.getSelectedFields(), record);
+ } else {
+ record = processRelativePath(replacementRecordPath,
result.getSelectedFields(), record);
Review comment:
I don't think the assignment here to record is necessary because
processRelativePath does not modify it.
--
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]