Skip to content

NIFI-15856 - JsonRecordSetWriter silently ignores Timestamp Format#11158

Open
pvillard31 wants to merge 2 commits intoapache:mainfrom
pvillard31:NIFI-15856
Open

NIFI-15856 - JsonRecordSetWriter silently ignores Timestamp Format#11158
pvillard31 wants to merge 2 commits intoapache:mainfrom
pvillard31:NIFI-15856

Conversation

@pvillard31
Copy link
Copy Markdown
Contributor

Summary

NIFI-15856 - JsonRecordSetWriter silently ignores Timestamp Format

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

Copy link
Copy Markdown
Contributor

@exceptionfactory exceptionfactory 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 implementing this new property to clarify behavior @pvillard31. I noted a few minor things, but this looks close to completion.

Comment on lines +659 to +660
assertTrue(output.contains("\"ignoredExtra\":\"preserved\""),
"Default constructor preserves legacy fast-path behavior: raw bytes should be emitted verbatim");
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.

Should the output be equal, so that the strings can be compared, instead of checking for contains()?

final ByteArrayOutputStream fastPathBaos = new ByteArrayOutputStream();
try (final WriteJsonResult writer = new WriteJsonResult(Mockito.mock(ComponentLog.class), schema, new SchemaNameAsAttribute(), fastPathBaos, false,
NullSuppression.NEVER_SUPPRESS, OutputGrouping.OUTPUT_ARRAY, RecordFieldType.DATE.getDefaultFormat(),
RecordFieldType.TIME.getDefaultFormat(), "yyyy-MM-dd'T'HH:mm:ss.SSSX",
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.

It would be helpful to declare the date format in this method and use it in both places.

final Map<String, Object> values = new HashMap<>();
values.put("event", eventTimestamp);

final String rawForm = "{\"event\":\"2025-03-20T17:33:11.000+0000\"}";
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.

It would be helpful to declare the timestamp string and use String formatting here.

.description("""
Controls a throughput optimization that only applies to pure JSON pass-through flows. When set to true, and all of the \
following conditions are met, the writer will emit the record's original JSON bytes verbatim instead of re-serializing from typed field \
values: (1) the upstream reader is JsonTreeReader, (2) no data change, (3) the reader's and writer's record schemas are identical, \
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.

Would the JsonPathReader also work? The details are helpful, but I also wonder whether it is necessary to be this detailed.

Comment on lines +126 to +127
public static final PropertyDescriptor REUSE_INPUT_SERIALIZATION = new PropertyDescriptor.Builder()
.name("Reuse Input Serialization")
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.

Minor naming, but perhaps Use Input Serialization would be better?

@pvillard31
Copy link
Copy Markdown
Contributor Author

Thanks for the review @exceptionfactory - I pushed a commit to address your comments. Let me know what you think about the new property description.

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.

2 participants