From a62a7a7216fe2021d1516b6d7370598123cced37 Mon Sep 17 00:00:00 2001 From: mask <39329477+Narcasserun@users.noreply.github.com> Date: Tue, 28 Sep 2021 11:38:22 +0800 Subject: [PATCH] [Fix][Task] sql limit param no default value (#6337) (#6387) * add default query sql limit --- .../apache/dolphinscheduler/plugin/task/sql/SqlTask.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 3846c35c1c..cc18d5e468 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 @@ -81,6 +81,11 @@ public class SqlTask extends AbstractTaskExecutor { */ private static final String CREATE_FUNCTION_FORMAT = "create temporary function {0} as ''{1}''"; + /** + * default query sql limit + */ + private static final int LIMIT = 10000; + /** * Abstract Yarn Task * @@ -234,8 +239,9 @@ public class SqlTask extends AbstractTaskExecutor { int num = md.getColumnCount(); int rowCount = 0; + int limit = sqlParameters.getLimit() == 0 ? LIMIT : sqlParameters.getLimit(); - while (rowCount < sqlParameters.getLimit() && resultSet.next()) { + while (rowCount < limit && resultSet.next()) { ObjectNode mapOfColValues = JSONUtils.createObjectNode(); for (int i = 1; i <= num; i++) { mapOfColValues.set(md.getColumnLabel(i), JSONUtils.toJsonNode(resultSet.getObject(i)));