diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/LookupRecord.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/LookupRecord.java index 4a25736229..7301c26f63 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/LookupRecord.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/LookupRecord.java @@ -682,7 +682,18 @@ public class LookupRecord extends AbstractProcessor { } final FieldValue fieldValue = lookupFieldValues.get(0); - final Object coordinateValue = DataTypeUtils.convertType(fieldValue.getValue(), fieldValue.getField().getDataType(), null, null, null, fieldValue.getField().getFieldName()); + final Object coordinateValue = DataTypeUtils.convertType( + fieldValue.getValue(), + Optional.ofNullable(fieldValue.getField()) + .map(RecordField::getDataType) + .orElse(DataTypeUtils.inferDataType(fieldValue.getValue(), RecordFieldType.STRING.getDataType())), + null, + null, + null, + Optional.ofNullable(fieldValue.getField()) + .map(RecordField::getFieldName) + .orElse(coordinateKey) + ); lookupCoordinates.put(coordinateKey, coordinateValue); } diff --git a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestLookupRecord.java b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestLookupRecord.java index 89a0ed3759..2b15dfe2da 100644 --- a/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestLookupRecord.java +++ b/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestLookupRecord.java @@ -569,6 +569,19 @@ public class TestLookupRecord { out.assertContentEquals(new File("src/test/resources/TestLookupRecord/lookup-array-output-unmatched.json").toPath()); } + + @Test + public void testLiteralCoordinate() { + lookupService.addValue("lookupKey", "lookupValue"); + + runner.setProperty("lookup", "toString('lookupKey', 'UTF-8')"); + + runner.enqueue(""); + runner.run(); + + runner.assertAllFlowFilesTransferred(LookupRecord.REL_MATCHED, 1); + } + private static class MapLookup extends AbstractControllerService implements StringLookupService { protected final Map values = new HashMap<>(); private Map expectedContext;