This is an automated email from the ASF dual-hosted git repository.
leonbao pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git
The following commit(s) were added to refs/heads/dev by this push:
new 923f3f38e3 [Fix-9316] [Task] Configure DB2 data source SQL script
execution report ResultSet has been closed exception in SQL task (#9317)
923f3f38e3 is described below
commit 923f3f38e3271d7f1d22b3abc3497cecb6957e4a
Author: Kerwin <[email protected]>
AuthorDate: Mon Apr 11 13:19:48 2022 +0800
[Fix-9316] [Task] Configure DB2 data source SQL script execution report
ResultSet has been closed exception in SQL task (#9317)
* fix db2 error in the sql task
* update limit in sql task
---
.../apache/dolphinscheduler/plugin/task/sql/SqlTask.java | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git
a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
index e85ccc6432..ad31202004 100644
---
a/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
+++
b/dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java
@@ -243,7 +243,11 @@ public class SqlTask extends AbstractTaskExecutor {
int rowCount = 0;
int limit = sqlParameters.getLimit() == 0 ? QUERY_LIMIT :
sqlParameters.getLimit();
- while (rowCount < limit && resultSet.next()) {
+ while (resultSet.next()) {
+ if (rowCount == limit) {
+ logger.info("sql result limit : {} exceeding results are
filtered", limit);
+ break;
+ }
ObjectNode mapOfColValues = JSONUtils.createObjectNode();
for (int i = 1; i <= num; i++) {
mapOfColValues.set(md.getColumnLabel(i),
JSONUtils.toJsonNode(resultSet.getObject(i)));
@@ -252,17 +256,12 @@ public class SqlTask extends AbstractTaskExecutor {
rowCount++;
}
int displayRows = sqlParameters.getDisplayRows() > 0 ?
sqlParameters.getDisplayRows() : TaskConstants.DEFAULT_DISPLAY_ROWS;
- displayRows = Math.min(displayRows, resultJSONArray.size());
+ displayRows = Math.min(displayRows, rowCount);
logger.info("display sql result {} rows as follows:", displayRows);
for (int i = 0; i < displayRows; i++) {
String row = JSONUtils.toJsonString(resultJSONArray.get(i));
logger.info("row {} : {}", i + 1, row);
}
- if (resultSet.next()) {
- logger.info("sql result limit : {} exceeding results are
filtered", limit);
- String log = String.format("sql result limit : %d exceeding
results are filtered", limit);
- resultJSONArray.add(JSONUtils.toJsonNode(log));
- }
}
String result = JSONUtils.toJsonString(resultJSONArray);
if (sqlParameters.getSendEmail() == null ||
sqlParameters.getSendEmail()) {