-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
NIFI-11691: Support VARBINARY and LONGVARBINARY types in PutDatabaseRecord #7380
Conversation
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.
Thanks for addressing this issue @mattyb149, the general approach looks good, but I noted a couple questions about the alternative type handling.
try { | ||
ps.setBytes(index, byteArray); | ||
} catch (SQLException e) { | ||
throw new IOException("Unable to parse binary data " + value, e.getCause()); |
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.
Given the potential size of these objects, recommend replacing value
the array length to avoid extremely large log messages.
try { | ||
ps.setBytes(index, value.toString().getBytes(StandardCharsets.UTF_8)); | ||
} catch (SQLException e) { | ||
throw new IOException("Unable to parse binary data " + value, e.getCause()); |
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.
As noted above, recommend replacing value
with the length of the bytes.
} | ||
} else { | ||
try { | ||
ps.setBytes(index, value.toString().getBytes(StandardCharsets.UTF_8)); |
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.
It might be worth adding a comment on this line, since value.toString()
may not provide an expected representation of the underlying object type. Perhaps there should be some additional type checking in this conditional to determine if value
is an array type or collection type, otherwise it seems like this could produce unexpected results.
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.
This is just in case the data came in as a String
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.
Thanks for making the adjustments @mattyb149! +1 merging
Summary
NIFI-11691 This PR adds support for the java.sql.Types VARBINARY and LONGVARBINARY in PutDatabaseRecord. It converts the record field value to
byte[]
and then callssetBytes()
when setting the parameter value in the PreparedStatementTracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000
NIFI-00000
Pull Request Formatting
main
branchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
mvn clean install -P contrib-check
Licensing
LICENSE
andNOTICE
filesDocumentation