Browse Source

[Fix][Task] sql limit param no default value (#6337) (#6387)

* add default query sql limit
2.0.7-release
mask 3 years ago committed by GitHub
parent
commit
a62a7a7216
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-task-plugin/dolphinscheduler-task-sql/src/main/java/org/apache/dolphinscheduler/plugin/task/sql/SqlTask.java

8
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)));

Loading…
Cancel
Save