diff --git a/docs/docs/en/guide/upgrade/incompatible.md b/docs/docs/en/guide/upgrade/incompatible.md index 0f60fcb9986a..b560b92197ca 100644 --- a/docs/docs/en/guide/upgrade/incompatible.md +++ b/docs/docs/en/guide/upgrade/incompatible.md @@ -44,3 +44,7 @@ This document records the incompatible updates between each version. You need to * Remove import and export of workflow definition. ([#17940])(https://github.com/apache/dolphinscheduler/issues/17940) +## 3.5.0 + +* The workflow instance list APIs no longer return the following fields in the response body: `commandParam`, `globalParams`, `historyCmd`, `varPool`, `stateHistory`. To obtain these fields, use the detail API `GET /projects/{projectCode}/workflow-instances/{id}` instead.([#18444])(https://github.com/apache/dolphinscheduler/pull/18444) + diff --git a/docs/docs/zh/guide/upgrade/incompatible.md b/docs/docs/zh/guide/upgrade/incompatible.md index 2f0c4c044ff8..ffb06fa64e9a 100644 --- a/docs/docs/zh/guide/upgrade/incompatible.md +++ b/docs/docs/zh/guide/upgrade/incompatible.md @@ -48,3 +48,7 @@ * 移除导入导出工作流([#17940])(https://github.com/apache/dolphinscheduler/issues/17940) +## 3.5.0 + +* 工作流实例列表接口的响应体不再返回以下字段:`commandParam`、`globalParams`、`historyCmd`、`varPool`、`stateHistory`。如需获取这些字段,请使用详情接口 `GET /projects/{projectCode}/workflow-instances/{id}`([#18444])(https://github.com/apache/dolphinscheduler/pull/18444) + diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceController.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceController.java index 221acd99bd57..34ec5ca5fbe7 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceController.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceController.java @@ -23,6 +23,7 @@ import org.apache.dolphinscheduler.api.audit.enums.AuditType; import org.apache.dolphinscheduler.api.dto.DynamicSubWorkflowDto; import org.apache.dolphinscheduler.api.dto.gantt.GanttDto; +import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceQueryDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceTaskListDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceVariablesDTO; import org.apache.dolphinscheduler.api.enums.Status; @@ -233,13 +234,14 @@ public Result queryWorkflowInstanceById(@Parameter(hidden = tr @GetMapping(value = "/top-n") @ResponseStatus(HttpStatus.OK) @ApiException(Status.QUERY_WORKFLOW_INSTANCE_BY_ID_ERROR) - public Result> queryTopNLongestRunningWorkflowInstance(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, - @RequestParam("size") Integer size, - @RequestParam(value = "startTime", required = true) String startTime, - @RequestParam(value = "endTime", required = true) String endTime) { - List workflowInstances = workflowInstanceService.queryTopNLongestRunningWorkflowInstance( - loginUser, projectCode, size, startTime, endTime); + public Result> queryTopNLongestRunningWorkflowInstance(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @Parameter(name = "projectCode", description = "PROJECT_CODE", required = true) @PathVariable long projectCode, + @RequestParam("size") Integer size, + @RequestParam(value = "startTime", required = true) String startTime, + @RequestParam(value = "endTime", required = true) String endTime) { + List workflowInstances = + workflowInstanceService.queryTopNLongestRunningWorkflowInstance( + loginUser, projectCode, size, startTime, endTime); return Result.success(workflowInstances); } @@ -432,10 +434,10 @@ public Result batchDeleteWorkflowInstanceByIds(@RequestAttribute(value = C @GetMapping("/trigger") @ResponseStatus(HttpStatus.OK) @ApiException(QUERY_WORKFLOW_INSTANCE_LIST_PAGING_ERROR) - public Result> queryWorkflowInstancesByTriggerCode(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, - @PathVariable long projectCode, - @RequestParam(value = "triggerCode") Long triggerCode) { - List workflowInstances = + public Result> queryWorkflowInstancesByTriggerCode(@RequestAttribute(value = Constants.SESSION_USER) User loginUser, + @PathVariable long projectCode, + @RequestParam(value = "triggerCode") Long triggerCode) { + List workflowInstances = workflowInstanceService.queryByTriggerCode(loginUser, projectCode, triggerCode); return Result.success(workflowInstances); } diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/workflowInstance/WorkflowInstanceQueryDTO.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/workflowInstance/WorkflowInstanceQueryDTO.java new file mode 100644 index 000000000000..a512cadade62 --- /dev/null +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/dto/workflowInstance/WorkflowInstanceQueryDTO.java @@ -0,0 +1,194 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dolphinscheduler.api.dto.workflowInstance; + +import org.apache.dolphinscheduler.common.enums.CommandType; +import org.apache.dolphinscheduler.common.enums.FailureStrategy; +import org.apache.dolphinscheduler.common.enums.Flag; +import org.apache.dolphinscheduler.common.enums.Priority; +import org.apache.dolphinscheduler.common.enums.TaskDependType; +import org.apache.dolphinscheduler.common.enums.WarningType; +import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus; +import org.apache.dolphinscheduler.dao.entity.WorkflowInstance; + +import java.util.Date; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import io.swagger.v3.oas.annotations.media.Schema; + +/** + * Lightweight response DTO for workflow instance list / top-N / trigger queries. + * + *

Unlike {@link WorkflowInstance}, this DTO intentionally omits heavy columns + * ({@code commandParam}, {@code globalParams}, {@code historyCmd}, {@code varPool}, + * {@code stateHistory}) that are only needed for detail views or internal processing. + * This allows the corresponding DAO queries to use the optimized {@code listSql} + * projection instead of the full {@code baseSql}. + * + *

Incompatible API change (documented): The following fields that were + * previously present in list/topN/trigger API responses are no longer returned: + *

    + *
  • {@code commandParam}
  • + *
  • {@code globalParams}
  • + *
  • {@code historyCmd}
  • + *
  • {@code varPool}
  • + *
  • {@code stateHistory}
  • + *
+ * Consumers that require these fields should call the detail endpoint + * {@code GET /projects/{projectCode}/workflow-instances/{id}} instead, which + * continues to return the full {@link WorkflowInstance}. + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +@Schema(name = "WORKFLOW_INSTANCE_QUERY_RESPONSE") +public class WorkflowInstanceQueryDTO { + + @Schema(description = "workflow instance id") + private Integer id; + + @Schema(description = "workflow definition code") + private Long workflowDefinitionCode; + + @Schema(description = "workflow definition version") + private int workflowDefinitionVersion; + + @Schema(description = "project code") + private Long projectCode; + + @Schema(description = "workflow execution status") + private WorkflowExecutionStatus state; + + @Schema(description = "recovery flag") + private Flag recovery; + + @Schema(description = "start time") + private Date startTime; + + @Schema(description = "end time") + private Date endTime; + + @Schema(description = "run times") + private int runTimes; + + @Schema(description = "workflow instance name") + private String name; + + @Schema(description = "host") + private String host; + + @Schema(description = "command type") + private CommandType commandType; + + @Schema(description = "task depend type") + private TaskDependType taskDependType; + + @Schema(description = "max try times") + private int maxTryTimes; + + @Schema(description = "failure strategy") + private FailureStrategy failureStrategy; + + @Schema(description = "warning type") + private WarningType warningType; + + @Schema(description = "warning group id") + private Integer warningGroupId; + + @Schema(description = "schedule time") + private Date scheduleTime; + + @Schema(description = "command start time") + private Date commandStartTime; + + @Schema(description = "is sub workflow") + private Flag isSubWorkflow; + + @Schema(description = "executor id") + private int executorId; + + @Schema(description = "executor name") + private String executorName; + + @Schema(description = "workflow instance priority") + private Priority workflowInstancePriority; + + @Schema(description = "worker group") + private String workerGroup; + + @Schema(description = "environment code") + private Long environmentCode; + + @Schema(description = "timeout") + private int timeout; + + @Schema(description = "tenant code") + private String tenantCode; + + @Schema(description = "dry run") + private int dryRun; + + @Schema(description = "next workflow instance id") + private int nextWorkflowInstanceId; + + @Schema(description = "restart time") + private Date restartTime; + + @Schema(description = "duration string, e.g. 1h 2m 3s") + private String duration; + + /** + * Create a {@link WorkflowInstanceQueryDTO} from a {@link WorkflowInstance} entity. + */ + public static WorkflowInstanceQueryDTO fromEntity(WorkflowInstance instance) { + return new WorkflowInstanceQueryDTO( + instance.getId(), + instance.getWorkflowDefinitionCode(), + instance.getWorkflowDefinitionVersion(), + instance.getProjectCode(), + instance.getState(), + instance.getRecovery(), + instance.getStartTime(), + instance.getEndTime(), + instance.getRunTimes(), + instance.getName(), + instance.getHost(), + instance.getCommandType(), + instance.getTaskDependType(), + instance.getMaxTryTimes(), + instance.getFailureStrategy(), + instance.getWarningType(), + instance.getWarningGroupId(), + instance.getScheduleTime(), + instance.getCommandStartTime(), + instance.getIsSubWorkflow(), + instance.getExecutorId(), + instance.getExecutorName(), + instance.getWorkflowInstancePriority(), + instance.getWorkerGroup(), + instance.getEnvironmentCode(), + instance.getTimeout(), + instance.getTenantCode(), + instance.getDryRun(), + instance.getNextWorkflowInstanceId(), + instance.getRestartTime(), + instance.getDuration()); + } +} diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceService.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceService.java index 6c3e81753599..085b83d38d6d 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceService.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceService.java @@ -19,6 +19,7 @@ import org.apache.dolphinscheduler.api.dto.DynamicSubWorkflowDto; import org.apache.dolphinscheduler.api.dto.gantt.GanttDto; +import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceQueryDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceTaskListDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceVariablesDTO; import org.apache.dolphinscheduler.api.utils.PageInfo; @@ -36,11 +37,11 @@ public interface WorkflowInstanceService { /** * return top n SUCCESS workflow instance order by running time which started between startTime and endTime */ - List queryTopNLongestRunningWorkflowInstance(User loginUser, - long projectCode, - int size, - String startTime, - String endTime); + List queryTopNLongestRunningWorkflowInstance(User loginUser, + long projectCode, + int size, + String startTime, + String endTime); /** * query workflow instance by id @@ -70,18 +71,18 @@ WorkflowInstance queryWorkflowInstanceById(User loginUser, * @param otherParamsJson otherParamsJson handle other params * @return workflow instance list */ - Result> queryWorkflowInstanceList(User loginUser, - long projectCode, - long workflowDefinitionCode, - String startDate, - String endDate, - String searchVal, - String executorName, - WorkflowExecutionStatus stateType, - String host, - String otherParamsJson, - Integer pageNo, - Integer pageSize); + Result> queryWorkflowInstanceList(User loginUser, + long projectCode, + long workflowDefinitionCode, + String startDate, + String endDate, + String searchVal, + String executorName, + WorkflowExecutionStatus stateType, + String host, + String otherParamsJson, + Integer pageNo, + Integer pageSize); /** * query task list by workflow instance id @@ -218,7 +219,7 @@ List queryByWorkflowDefinitionCode(Long workflowDefinitionCode * @param triggerCode trigger code (nullable) * @return workflow instances triggered by the given trigger code */ - List queryByTriggerCode(User loginUser, long projectCode, Long triggerCode); + List queryByTriggerCode(User loginUser, long projectCode, Long triggerCode); void deleteWorkflowInstanceByWorkflowDefinitionCode(long workflowDefinitionCode); diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java index 5d024bbb5520..476577009fa4 100644 --- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java +++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/WorkflowInstanceServiceImpl.java @@ -30,6 +30,7 @@ import org.apache.dolphinscheduler.api.dto.DynamicSubWorkflowDto; import org.apache.dolphinscheduler.api.dto.gantt.GanttDto; import org.apache.dolphinscheduler.api.dto.gantt.Task; +import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceQueryDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceTaskListDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceVariablesDTO; import org.apache.dolphinscheduler.api.enums.Status; @@ -170,8 +171,9 @@ public class WorkflowInstanceServiceImpl extends BaseServiceImpl implements Work private TaskInstanceContextDao taskInstanceContextDao; @Override - public List queryTopNLongestRunningWorkflowInstance(User loginUser, long projectCode, int size, - String startTime, String endTime) { + public List queryTopNLongestRunningWorkflowInstance(User loginUser, long projectCode, + int size, + String startTime, String endTime) { Project project = projectDao.queryByCode(projectCode); // check user access for project projectService.checkProjectAndAuthThrowException(loginUser, project, WORKFLOW_INSTANCE); @@ -195,7 +197,10 @@ public List queryTopNLongestRunningWorkflowInstance(User login } return workflowInstanceDao.queryTopNWorkflowInstance(size, start, end, WorkflowExecutionStatus.SUCCESS, - projectCode); + projectCode) + .stream() + .map(WorkflowInstanceQueryDTO::fromEntity) + .collect(Collectors.toList()); } @Override @@ -221,18 +226,18 @@ public WorkflowInstance queryWorkflowInstanceById(User loginUser, long projectCo } @Override - public Result> queryWorkflowInstanceList(User loginUser, - long projectCode, - long workflowDefinitionCode, - String startDate, - String endDate, - String searchVal, - String executorName, - WorkflowExecutionStatus stateType, - String host, - String otherParamsJson, - Integer pageNo, - Integer pageSize) { + public Result> queryWorkflowInstanceList(User loginUser, + long projectCode, + long workflowDefinitionCode, + String startDate, + String endDate, + String searchVal, + String executorName, + WorkflowExecutionStatus stateType, + String host, + String otherParamsJson, + Integer pageNo, + Integer pageSize) { Result result = new Result(); // check user access for project @@ -248,7 +253,7 @@ public Result> queryWorkflowInstanceList(User loginUs Date end = checkAndParseDateParameters(endDate); Page page = new Page<>(pageNo, pageSize); - PageInfo pageInfo = new PageInfo<>(pageNo, pageSize); + PageInfo pageInfo = new PageInfo<>(pageNo, pageSize); IPage workflowInstanceList = workflowInstanceDao.queryWorkflowInstanceListPaging( page, @@ -281,7 +286,9 @@ public Result> queryWorkflowInstanceList(User loginUs } pageInfo.setTotal((int) workflowInstanceList.getTotal()); - pageInfo.setTotalList(workflowInstances); + pageInfo.setTotalList(workflowInstances.stream() + .map(WorkflowInstanceQueryDTO::fromEntity) + .collect(Collectors.toList())); result.setData(pageInfo); putMsg(result, Status.SUCCESS); return result; @@ -775,7 +782,7 @@ public List queryByWorkflowDefinitionCode(Long workflowDefinit } @Override - public List queryByTriggerCode(User loginUser, long projectCode, Long triggerCode) { + public List queryByTriggerCode(User loginUser, long projectCode, Long triggerCode) { Project project = projectDao.queryByCode(projectCode); // check user access for project @@ -784,7 +791,10 @@ public List queryByTriggerCode(User loginUser, long projectCod if (triggerCode == null) { return Collections.emptyList(); } - return workflowInstanceDao.queryByTriggerCode(triggerCode); + return workflowInstanceDao.queryByTriggerCode(triggerCode) + .stream() + .map(WorkflowInstanceQueryDTO::fromEntity) + .collect(Collectors.toList()); } @Override diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceControllerTest.java index ada5e70e92a6..a67bc789b211 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/WorkflowInstanceControllerTest.java @@ -24,6 +24,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceQueryDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceVariablesDTO; import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.exceptions.ServiceException; @@ -36,6 +37,7 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.List; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -254,4 +256,60 @@ public void queryWorkflowInstancesByTriggerCode() throws Exception { Assertions.assertNotNull(result); Assertions.assertEquals(Status.SUCCESS.getCode(), result.getCode().intValue()); } + + @Test + public void testWorkflowInstanceQueryDTO_omitsHeavyFields() { + // Verify via reflection that WorkflowInstanceQueryDTO does NOT declare + // the 5 fields that were removed from the list API response contract. + List omittedFields = java.util.Arrays.asList( + "commandParam", "globalParams", "historyCmd", "varPool", "stateHistory"); + for (String field : omittedFields) { + Assertions.assertThrows(NoSuchFieldException.class, + () -> WorkflowInstanceQueryDTO.class.getDeclaredField(field), + "WorkflowInstanceQueryDTO should NOT declare field '" + field + + "' — it was intentionally removed from the list API response contract"); + } + } + + @Test + public void testWorkflowInstanceQueryDTO_includesRequiredFields() { + // Verify that all fields present in listSql are also declared in the DTO. + List requiredFields = java.util.Arrays.asList( + "id", "name", "workflowDefinitionCode", "workflowDefinitionVersion", + "projectCode", "state", "recovery", "startTime", "endTime", + "runTimes", "host", "commandType", "taskDependType", + "maxTryTimes", "failureStrategy", "warningType", "warningGroupId", + "scheduleTime", "commandStartTime", + "isSubWorkflow", "executorId", "workflowInstancePriority", + "workerGroup", "environmentCode", "timeout", "tenantCode", + "dryRun", "nextWorkflowInstanceId", "restartTime", "duration", + "executorName"); + for (String field : requiredFields) { + Assertions.assertDoesNotThrow(() -> WorkflowInstanceQueryDTO.class.getDeclaredField(field), + "WorkflowInstanceQueryDTO should declare field '" + field + + "' — it must be present in the list API response contract"); + } + } + + @Test + public void testFromEntity_MapsAllDtoFields() { + // Build a minimal WorkflowInstance and ensure fromEntity maps without error + // and every DTO field is non-null where expected. + WorkflowInstance instance = new WorkflowInstance(); + instance.setId(1); + instance.setName("test-workflow"); + instance.setWorkflowDefinitionCode(123456L); + instance.setWorkflowDefinitionVersion(1); + instance.setProjectCode(789L); + instance.setState(WorkflowExecutionStatus.SUCCESS); + instance.setExecutorName("admin"); + + WorkflowInstanceQueryDTO dto = WorkflowInstanceQueryDTO.fromEntity(instance); + + Assertions.assertEquals(1, dto.getId()); + Assertions.assertEquals("test-workflow", dto.getName()); + Assertions.assertEquals(123456L, dto.getWorkflowDefinitionCode()); + Assertions.assertEquals(WorkflowExecutionStatus.SUCCESS, dto.getState()); + Assertions.assertEquals("admin", dto.getExecutorName()); + } } diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceServiceTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceServiceTest.java index 88e9051ffb16..4f907f4ebe76 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceServiceTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/WorkflowInstanceServiceTest.java @@ -26,6 +26,7 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.when; +import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceQueryDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceTaskListDTO; import org.apache.dolphinscheduler.api.dto.workflowInstance.WorkflowInstanceVariablesDTO; import org.apache.dolphinscheduler.api.enums.Status; @@ -310,12 +311,13 @@ public void queryByTriggerCode() { // project auth success, trigger code null returns empty list Mockito.doNothing().when(projectService).checkProjectAndAuthThrowException(loginUser, project, WORKFLOW_INSTANCE); - List nullTriggerRes = + List nullTriggerRes = workflowInstanceService.queryByTriggerCode(loginUser, projectCode, null); Assertions.assertTrue(nullTriggerRes.isEmpty()); when(workflowInstanceDao.queryByTriggerCode(999L)).thenReturn(new ArrayList<>()); - List emptyRes = workflowInstanceService.queryByTriggerCode(loginUser, projectCode, 999L); + List emptyRes = + workflowInstanceService.queryByTriggerCode(loginUser, projectCode, 999L); Assertions.assertTrue(emptyRes.isEmpty()); } @@ -344,8 +346,9 @@ public void testQueryTopNLongestRunningWorkflowInstance() { when(workflowInstanceDao.queryTopNWorkflowInstance(Mockito.eq(size), Mockito.any(), Mockito.any(), Mockito.eq(WorkflowExecutionStatus.SUCCESS), Mockito.eq(projectCode))) .thenReturn(new ArrayList<>()); - List successRes = workflowInstanceService.queryTopNLongestRunningWorkflowInstance(loginUser, - projectCode, size, startTime, endTime); + List successRes = + workflowInstanceService.queryTopNLongestRunningWorkflowInstance(loginUser, + projectCode, size, startTime, endTime); Assertions.assertNotNull(successRes); } diff --git a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.xml b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.xml index 906e72137f27..518f65d0a617 100644 --- a/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.xml +++ b/dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/WorkflowInstanceMapper.xml @@ -27,6 +27,20 @@ workflow_instance_priority, worker_group,environment_code, timeout, tenant_code, var_pool, dry_run, next_workflow_instance_id, restart_time, state_history + + + id + , name, workflow_definition_version, workflow_definition_code, project_code, state, recovery, start_time, end_time, run_times,host, + command_type, task_depend_type, max_try_times, failure_strategy, warning_type, + warning_group_id, schedule_time, command_start_time, flag, + update_time, is_sub_workflow, executor_id, + workflow_instance_priority, worker_group,environment_code, timeout, tenant_code, + dry_run, next_workflow_instance_id, restart_time + select - + from t_ds_workflow_instance where state = #{status} @@ -77,7 +91,7 @@ - select - + from t_ds_workflow_instance where is_sub_workflow=0 and project_code = #{projectCode} @@ -195,7 +208,7 @@ - - select - + from t_ds_workflow_instance where workflow_definition_code=#{workflowDefinitionCode} @@ -286,10 +297,9 @@ order by id asc - SELECT - + FROM t_ds_workflow_instance where is_sub_workflow=0 @@ -357,7 +367,7 @@