-
Notifications
You must be signed in to change notification settings - Fork 2.9k
NIFI-15224 Add Pre-Query and Post-Query to PutDatabaseRecord #10536
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
base: main
Are you sure you want to change the base?
Conversation
exceptionfactory
left a comment
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 proposing this improvement @spects.
The general approach looks good, aligning with the feature implemented in ExecuteSQL.
I noted a few minor implementation recommendations.
| * Executes given queries using pre-defined connection. | ||
| * Returns null on success, or a query string if failed. | ||
| */ | ||
| private Pair<String, SQLException> executeConfigStatements(final Connection con, final List<String> configQueries) { |
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.
Catching and returning the exception, just to throw it from the calling method, does not seem like the best approach. I recommend simply declaring throws SQLException on this method and not returning anything.
| .description("A semicolon-delimited list of queries executed before the main SQL query is executed. " + | ||
| "For example, set session properties before main query. " + | ||
| "It's possible to include semicolons in the statements themselves by escaping them with a backslash ('\\;'). " + | ||
| "Results/outputs from these queries will be suppressed if there are no errors.") |
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.
A multiline string can be used instead of string concatenation to build the description.
| assertTrue(rs.next()); | ||
| assertEquals(1, rs.getInt(1)); | ||
| assertEquals("rec1", rs.getString(2)); | ||
| assertEquals(101, rs.getInt(3)); | ||
| assertEquals(jdbcDate1.toString(), rs.getDate(4).toString()); | ||
| assertTrue(rs.next()); | ||
| assertEquals(2, rs.getInt(1)); | ||
| assertEquals("rec2", rs.getString(2)); | ||
| assertEquals(102, rs.getInt(3)); | ||
| assertEquals(jdbcDate2.toString(), rs.getDate(4).toString()); | ||
| assertTrue(rs.next()); | ||
| assertEquals(3, rs.getInt(1)); | ||
| assertEquals("rec3", rs.getString(2)); | ||
| assertEquals(103, rs.getInt(3)); | ||
| assertNull(rs.getDate(4)); | ||
| assertTrue(rs.next()); | ||
| assertEquals(4, rs.getInt(1)); | ||
| assertEquals("rec4", rs.getString(2)); | ||
| assertEquals(104, rs.getInt(3)); | ||
| assertNull(rs.getDate(4)); | ||
| assertTrue(rs.next()); | ||
| assertEquals(5, rs.getInt(1)); | ||
| assertNull(rs.getString(2)); | ||
| assertEquals(105, rs.getInt(3)); | ||
| assertNull(rs.getDate(4)); | ||
| assertFalse(rs.next()); |
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.
These assertions appear to be duplicated in the other test method. Recommend creating a shared private assertResultsFound() method or similar to delegate the evaluation.
Summary
NIFI-15224
Implement SQL Pre-Query and SQL Post-Query in PutDatabaseRecord. Implementation draws from AbstractExecuteSQL's implementation.
Tracking
Please complete the following tracking steps prior to pull request creation.
Issue Tracking
Pull Request Tracking
NIFI-00000NIFI-00000Pull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation