Browse Source

[#6337]When the SQL result reaches the limit value, increase the log result prompt (#6528)

3.0.0/version-upgrade
Kirs 3 years ago committed by GitHub
parent
commit
09657d8576
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java

10
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 * default query sql limit
*/ */
private static final int LIMIT = 10000; private static final int QUERY_LIMIT = 10000;
/** /**
* Abstract Yarn Task * Abstract Yarn Task
@ -239,7 +239,7 @@ public class SqlTask extends AbstractTaskExecutor {
int num = md.getColumnCount(); int num = md.getColumnCount();
int rowCount = 0; 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()) { while (rowCount < limit && resultSet.next()) {
ObjectNode mapOfColValues = JSONUtils.createObjectNode(); ObjectNode mapOfColValues = JSONUtils.createObjectNode();
@ -249,7 +249,6 @@ public class SqlTask extends AbstractTaskExecutor {
resultJSONArray.add(mapOfColValues); resultJSONArray.add(mapOfColValues);
rowCount++; rowCount++;
} }
int displayRows = sqlParameters.getDisplayRows() > 0 ? sqlParameters.getDisplayRows() : TaskConstants.DEFAULT_DISPLAY_ROWS; int displayRows = sqlParameters.getDisplayRows() > 0 ? sqlParameters.getDisplayRows() : TaskConstants.DEFAULT_DISPLAY_ROWS;
displayRows = Math.min(displayRows, resultJSONArray.size()); displayRows = Math.min(displayRows, resultJSONArray.size());
logger.info("display sql result {} rows as follows:", displayRows); 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)); String row = JSONUtils.toJsonString(resultJSONArray.get(i));
logger.info("row {} : {}", i + 1, row); 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); String result = JSONUtils.toJsonString(resultJSONArray);
if (sqlParameters.getSendEmail() == null || sqlParameters.getSendEmail()) { if (sqlParameters.getSendEmail() == null || sqlParameters.getSendEmail()) {

Loading…
Cancel
Save