Skip to content

NIFI-14861 Add EnrichGraphRecord processor#11316

Open
tpalfy wants to merge 3 commits into
apache:mainfrom
tpalfy:NIFI-14861-EnrichGraphRecord
Open

NIFI-14861 Add EnrichGraphRecord processor#11316
tpalfy wants to merge 3 commits into
apache:mainfrom
tpalfy:NIFI-14861-EnrichGraphRecord

Conversation

@tpalfy

@tpalfy tpalfy commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

NIFI-14861

Tracking

Please complete the following tracking steps prior to pull request creation.

Issue Tracking

Pull Request Tracking

  • Pull Request title starts with Apache NiFi Jira issue number, such as NIFI-00000
  • Pull Request commit message starts with Apache NiFi Jira issue number, as such NIFI-00000
  • Pull request contains commits signed with a registered key indicating Verified status

Pull Request Formatting

  • Pull Request based on current revision of the main branch
  • Pull Request refers to a feature branch with one commit containing changes

Verification

Please indicate the verification steps performed prior to pull request creation.

Build

  • Build completed using ./mvnw clean install -P contrib-check
    • JDK 21
    • JDK 25

Licensing

  • New dependencies are compatible with the Apache License 2.0 according to the License Policy
  • New dependencies are documented in applicable LICENSE and NOTICE files

Documentation

  • Documentation formatting appears as expected in rendered files

throw new IOException("Identifier field(s) not found in record, check the RecordPath expression");
}

final LinkedHashMap<String, Object> identifierFieldNameToValue = new LinkedHashMap<>(identifierFieldValues.size());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe PMD is complaining that the assignment should be to an interface

Suggested change
final LinkedHashMap<String, Object> identifierFieldNameToValue = new LinkedHashMap<>(identifierFieldValues.size());
final Map<String, Object> identifierFieldNameToValue = new LinkedHashMap<>(identifierFieldValues.size());

@hleonps hleonps left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for working on this!

I left a comment related to value normalization. But everything else LGTM.

Comment on lines +422 to +440
if (RecordFieldType.ARRAY.equals(rawFieldType)) {
final DataType arrayElementDataType = ((ArrayDataType) rawDataType).getElementType();
if (RecordFieldType.RECORD.getDataType().equals(arrayElementDataType)) {
final Object[] rawValueArray = (Object[]) rawValue;
final Object[] mappedValueArray = new Object[rawValueArray.length];
for (int index = 0; index < rawValueArray.length; index++) {
final MapRecord mapRecord = (MapRecord) rawValueArray[index];
mappedValueArray[index] = mapRecord.toMap(true);
}
return mappedValueArray;
}

return rawValue;
}

if (RecordFieldType.RECORD.equals(rawFieldType)) {
final MapRecord mapRecord = (MapRecord) rawValue;
return mapRecord.toMap(true);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normalization won't work if the record have a nested array. The record could be normalized recursively to avoid the same problem in deeper levels of nesting.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think those scenarios are supported in graph databases.
not in neo4j at least.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought, handling deeply nested values have a particular benefit. while not a useful feature on it's own, it let's us delegate to the underlying database to report it's domain-specifc error instead of crash in nifi.
I'll add it.

@Test
void testGenerateSetPropertiesMutationForNode() {
final Neo4JCypherQueryGeneratorService service = new Neo4JCypherQueryGeneratorService();
final LinkedHashMap<String, Object> identifiers = new LinkedHashMap<>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When running with -Pcontrib-check I get 4 PMD violations for using LinkedHashMap instead of Map

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was addressed already in an earlier comment.

@hleonps hleonps left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is working as expected. The type validation is delegated to the database instead of NiFi as expected.

Fixing the PMD violations is the only thing pending.

@mattyb149

Copy link
Copy Markdown
Contributor

With my data I got the following errors, but it might just be a problem with the input:
Caused by: org.neo4j.driver.exceptions.ClientException: Property values can only be of primitive types or arrays thereof. Encountered: Map{hasBroadSynonym -> List{}, hasExactSynonym -> List{Map{element -> String("retinitis pigmentosa type 59")}, Map{element -> String("DHDDS retinitis pigmentosa")}, Map{element -> String("congenital disorder of glycosylation, type 1bb")}, Map{element -> String("RP59")}, Map{element -> String("retinitis pigmentosa 59")}, Map{element -> String("retinitis pigmentosa caused by mutation in DHDDS")}}, hasRelatedSynonym -> List{Map{element -> String("congenital disorder of glycosylation, type Ibb")}}, hasNarrowSynonym -> List{}}.

@tpalfy

tpalfy commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

With my data I got the following errors, but it might just be a problem with the input: Caused by: org.neo4j.driver.exceptions.ClientException: Property values can only be of primitive types or arrays thereof. Encountered: Map{hasBroadSynonym -> List{}, hasExactSynonym -> List{Map{element -> String("retinitis pigmentosa type 59")}, Map{element -> String("DHDDS retinitis pigmentosa")}, Map{element -> String("congenital disorder of glycosylation, type 1bb")}, Map{element -> String("RP59")}, Map{element -> String("retinitis pigmentosa 59")}, Map{element -> String("retinitis pigmentosa caused by mutation in DHDDS")}}, hasRelatedSynonym -> List{Map{element -> String("congenital disorder of glycosylation, type Ibb")}}, hasNarrowSynonym -> List{}}.

Neo4J doesn't support nested values as edge/node properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants