-
Notifications
You must be signed in to change notification settings - Fork 2.9k
NIFI-1234 Correcting container functionality for single Avro records. #136
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
|
@trkurc good catches on the comments. Overall would you feel like this is a bug? That's the impression I get and trying to think if this is adjusted is it breaking? I imagine it could be but have a hard time envisioning that behavior being desirable. Thoughts? |
|
both the code and processor description strongly indicated this was intentional. "If an incoming FlowFile contains a stream of multiple Avro records, the resultant FlowFile will contain a JSON Array containing all of the Avro records." |
|
I am on the side of @apiri. I can't imagine that was the desirable behavior either, since it was simply inconsistent. If one explicitly requests an array, than it should return an array, no matter how many elements in it. |
|
It covers the case of records but not record. I read the documentation to mean that as long as the input flowfile was of Avro formatted record(s), it would perform the associated conversion but admittedly the comments in the code provide much more context. Regardless, have updated the comments and pushed the branch. |
|
So, some evidence that this was intentional.
I believe 3 is a valid use case, and this change may break flows. I highly recommend adding a flag to preserve this behavior. I explained more in jira (https://issues.apache.org/jira/browse/NIFI-1234) |
|
@trkurc Sorry, missed some of your earlier comments (these were from last night when you expanded the cases) in flipping between here and Github. Also hate the property bloat, but think it is necessary to avoid the breaking change. Had a hard time grokking the use cases that steered it away from bug status, so am onboard with your viewpoint. |
… records and adjusting formatting in ConvertAvroToJSON. This closes apache#136.
|
Made the changes to include a property which defaults to the old behavior but enables control over whether a single record is placed in a container |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For next time, comment is good, but parens would make the logic more clear for the next coder to come along:
if ((recordCount > 1 && useContainer) || wrapSingleRecord) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually, isn't that the wrong logic? shouldn't it be
if (useContainer && (recordCount > 1 || wrapSingleRecord))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is correct.
useContainer only applies to the case where there is more than one record. Those cases where there are zero or one are driven by wrapSingleRecord which incorporates whether or not the container should be used. Happy to rework this (and the grouping) if I can get some better clarity. Could certainly alleviate the line where it is defined earlier.
wrapSingleRecord is defined as:
final boolean wrapSingleRecord = context.getProperty(WRAP_SINGLE_RECORD).asBoolean() && useContainer;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now from line 127 that this is what is happening
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apiri how logic flows through code is a personal preference. I was confused for a spell, but there were unit tests checking the behavior.
This closes apache#136.
@joemeszaros Had a user open an issue concerning the processor's handling of events with only one record. I agree that the functionality seems a bit odd and was wondering if there was a specific case that would be missed should the containerOption be the only item to dictate format.