Skip to content

Added array support for ndjson inputcodec #5875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

sivagnanam-arumugam
Copy link
Contributor

@sivagnanam-arumugam sivagnanam-arumugam commented Jul 4, 2025

Description

Array support for ndjson input codec,
Array line is handled in logstash json_lines codec, So added the support to data prepper.

Issues Resolved

Resolves #5874

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Copy link
Collaborator

@KarstenSchnitter KarstenSchnitter 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 providing this change. Looks good to me.

Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

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

void parse_with_array_of_objects_asserts_number_of_objects() throws IOException {
final NdjsonInputCodec objectUnderTest = createObjectUnderTest();

final String jsonArray = "[{\"key1\":\"value1\"},{\"key2\":\"value2\"}]";
Copy link
Member

Choose a reason for hiding this comment

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

Does this change support reading multiple arrays from different lines?

[{\"key1\":\"value1\"},{\"key2\":\"value2\"}]
[{\"key3\":\"value3\"},{\"key4\":\"value4\"}]

If so, we should test this too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added multiple array support and added unit test cases.
Added signed-off-by commit message.

Added test cases for multiple array support

Signed-off-by: sivagnanam-arumugam <[email protected]>
@sivagnanam-arumugam sivagnanam-arumugam force-pushed the array-support-ndjson-inputcodec branch from 27c9f6e to 366f512 Compare July 15, 2025 09:56
Copy link
Member

@dlvenable dlvenable left a comment

Choose a reason for hiding this comment

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

Thank you @sivagnanam-arumugam for this contribution and follow up changes!

@KarstenSchnitter , Would you like to take another look?

Copy link
Collaborator

@KarstenSchnitter KarstenSchnitter left a comment

Choose a reason for hiding this comment

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

Still looks good to me. Thanks for the contribution.

@dlvenable dlvenable merged commit 65e7033 into opensearch-project:main Jul 16, 2025
49 of 51 checks passed
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.

Array support in ndjson input codec
3 participants