Skip to content

NIFI-12165 Changed the properties "Custom Transformation Class Name" and "Custom Module Directory" to depend on the "Jolt Transformation DSL" property when its value is "Custom"#7890

Closed
dan-s1 wants to merge 2 commits intoapache:mainfrom
dan-s1:NIFI-12165

Conversation

@dan-s1
Copy link
Copy Markdown
Contributor

@dan-s1 dan-s1 commented Oct 17, 2023

Summary

NIFI-12165

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 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 mvn clean install -P contrib-check
    • JDK 21

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

…and "Custom Module Directory" to depend on the "Jolt Transformation DSL" property when its value is "Custom"
Copy link
Copy Markdown
Contributor

@ChrisSamo632 ChrisSamo632 left a comment

Choose a reason for hiding this comment

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

The same problem exists for JoltTransformRecord, that should be updated in this PR too

@mattyb149 mattyb149 added the hacktoberfest-accepted Hacktoberfest Accepted label Oct 19, 2023
@dan-s1 dan-s1 requested a review from ChrisSamo632 October 20, 2023 13:41
@dan-s1
Copy link
Copy Markdown
Contributor Author

dan-s1 commented Oct 20, 2023

@ChrisSamo632 @exceptionfactory
I understand the history from #7782 that there had to be two processors JoltTransformJSON and JoltTransformRecord. But my question is why is there duplicate code between the two processors? This MR and NIFI-11959 (#7678) are consequences of duplicate code (i.e. the need to make the same fix in both places). Is there something we can do here to refactor and extract the duplicate code to be shared with these two classes?

Copy link
Copy Markdown
Contributor

@ChrisSamo632 ChrisSamo632 left a comment

Choose a reason for hiding this comment

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

Thanks for the updates @dan-s1 , LGTM 👍 merging

@asfgit asfgit closed this in 7f7e3f0 Oct 23, 2023
asfgit pushed a commit that referenced this pull request Oct 23, 2023
…and "Custom Module Directory" to depend on the "Jolt Transformation DSL" property when its value is "Custom"

This closes #7890

Signed-off-by: Chris Sampson <chris.sampson82@gmail.com>
@ChrisSamo632
Copy link
Copy Markdown
Contributor

@ChrisSamo632 @exceptionfactory I understand the history from #7782 that there had to be two processors JoltTransformJSON and JoltTransformRecord. But my question is why is there duplicate code between the two processors? This MR and NIFI-11959 (#7678) are consequences of duplicate code (i.e. the need to make the same fix in both places). Is there something we can do here to refactor and extract the duplicate code to be shared with these two classes?

@dan-s1 absolutely, I was thinking similar when I made the comment about the *Record processor in this PR, although I didn't think it was worth extending this PR to cover such a refactor. Could you raise a separate Jira ticket to refactor these processors to merge the logic where possible, e.g. the PropertyDescriptors and such, at the very least, could be merged together.

It would be good to explore whether things such as the custom UI available in the JoltTransformJSON could be merged together with JoltTransformRecord in the future, plus the handling of JOLT logic where possible. I'm not overly familiar with these processor, but without spending much time looking at the code, I'd hope that the only real difference should be whether the processor is applying the transform to the entire FlowFile content (i.e. in the *JSON processor) or every Record within (e.g. JSON Object within an Array, or every line of an ndjson/jsonl/json-ld file) - once the appropriate content has been read into memory, presumably the same JOLT transformation logic should be executed, then the result serialised either directly as the FlowFile's content (i.e. for *JSON) or via the configured Record Set Writer (i.e. for *Record).

I've tried to do a similar thing for the PutElastisearch* processors previously (i.e. *JSON and *Record), which both extend an AbstractPutElasticsearch base in an attempt to minimise repetition and avoid maintenance problems/inconsistent behaviour between the processors.

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

Labels

hacktoberfest-accepted Hacktoberfest Accepted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants