From 09657d8576cd04d7008f78c295c872f7b4a9c5c3 Mon Sep 17 00:00:00 2001 From: Kirs Date: Wed, 20 Oct 2021 14:58:46 +0800 Subject: [PATCH] [#6337]When the SQL result reaches the limit value, increase the log result prompt (#6528) --- .../dolphinscheduler/plugin/task/sql/SqlTask.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 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 cc18d5e468..302d4185e3 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 @@ -84,7 +84,7 @@ public class SqlTask extends AbstractTaskExecutor { /** * default query sql limit */ - private static final int LIMIT = 10000; + private static final int QUERY_LIMIT = 10000; /** * Abstract Yarn Task @@ -239,7 +239,7 @@ public class SqlTask extends AbstractTaskExecutor { int num = md.getColumnCount(); int rowCount = 0; - int limit = sqlParameters.getLimit() == 0 ? LIMIT : sqlParameters.getLimit(); + int limit = sqlParameters.getLimit() == 0 ? QUERY_LIMIT : sqlParameters.getLimit(); while (rowCount < limit && resultSet.next()) { ObjectNode mapOfColValues = JSONUtils.createObjectNode(); @@ -249,7 +249,6 @@ public class SqlTask extends AbstractTaskExecutor { resultJSONArray.add(mapOfColValues); rowCount++; } - int displayRows = sqlParameters.getDisplayRows() > 0 ? sqlParameters.getDisplayRows() : TaskConstants.DEFAULT_DISPLAY_ROWS; displayRows = Math.min(displayRows, resultJSONArray.size()); logger.info("display sql result {} rows as follows:", displayRows); @@ -257,6 +256,11 @@ public class SqlTask extends AbstractTaskExecutor { 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()) {