Github user yjhyjhyjh0 commented on a diff in the pull request: https://github.com/apache/nifi/pull/3156#discussion_r231754034 --- Diff: nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/test/java/org/apache/nifi/processors/standard/TestExecuteSQLRecord.java --- @@ -350,6 +352,141 @@ public void invokeOnTriggerRecords(final Integer queryTimeout, final String quer assertEquals(durationTime, fetchTime + executionTime); } + @Test + public void testPreQuery() throws Exception { + // remove previous test database, if any + final File dbLocation = new File(DB_LOCATION); + dbLocation.delete(); + + // load test data to database + final Connection con = ((DBCPService) runner.getControllerService("dbcp")).getConnection(); + Statement stmt = con.createStatement(); + + try { + stmt.execute("drop table TEST_NULL_INT"); + } catch (final SQLException sqle) { + } + + stmt.execute("create table TEST_NULL_INT (id integer not null, val1 integer, val2 integer, constraint my_pk primary key (id))"); + + runner.setIncomingConnection(true); + runner.setProperty(ExecuteSQL.SQL_PRE_QUERY, "insert into TEST_NULL_INT values(1,2,3);insert into TEST_NULL_INT values(4,5,6)"); --- End diff -- That's indeed great use case, I'll update test cases. Thanks for the sharing the information.
---