wangxj3 commented on a change in pull request #6722:
URL: https://github.com/apache/dolphinscheduler/pull/6722#discussion_r759078247



##########
File path: 
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/TaskGroupQueueMapper.xml
##########
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 
"http://mybatis.org/dtd/mybatis-3-mapper.dtd";>
+<mapper 
namespace="org.apache.dolphinscheduler.dao.mapper.TaskGroupQueueMapper">
+
+    <resultMap type="org.apache.dolphinscheduler.dao.entity.TaskGroupQueue" 
id="TaskGroupQueueMap">
+        <result property="id" column="id" jdbcType="INTEGER"/>
+        <result property="taskId" column="task_id" jdbcType="INTEGER"/>
+        <result property="taskName" column="task_name" jdbcType="VARCHAR"/>
+        <result property="groupId" column="group_id" jdbcType="INTEGER"/>
+        <result property="processId" column="process_id" jdbcType="INTEGER"/>
+        <result property="priority" column="priority" jdbcType="INTEGER"/>
+        <result property="status" column="status" jdbcType="INTEGER"/>
+        <result property="forceStart" column="force_start" jdbcType="INTEGER"/>
+        <result property="inQueue" column="in_queue" jdbcType="INTEGER"/>
+        <result property="createTime" column="create_time" 
jdbcType="TIMESTAMP"/>
+        <result property="updateTime" column="update_time" 
jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id = "baseSql">
+        id, task_id, task_name, group_id, process_id, priority, status , 
force_start , in_queue, create_time, update_time
+    </sql>
+
+    <select id="queryTaskGroupQueuePaging" 
resultType="org.apache.dolphinscheduler.dao.entity.TaskGroupQueue">
+        select
+        <include refid="baseSql">
+        </include>
+        from t_ds_task_group_queue
+        <where>
+            <if test="groupId != 0">
+                and group_id = #{groupId}
+            </if>
+            <if test="processId != 0">
+                and process_id = #{processId}
+            </if>
+        </where>
+    </select>
+
+    <select id="queryByStatus" resultMap="TaskGroupQueueMap" resultType="map">
+        select
+        <include refid="baseSql">
+        </include>
+        from t_ds_task_group_queue
+        <where>
+            <if test="status != 0">
+                and status = #{status}
+            </if>
+        </where>
+    </select>
+
+    <delete id="deleteByTaskId">
+        delete from t_ds_task_group_queue
+        where task_id = #{taskId}
+    </delete>
+
+    <update id="updateStatusByTaskId">
+        update t_ds_task_group_queue
+        <set>
+            <if test="status != 0">
+                status = #{status},
+            </if>
+        </set>
+        where task_id = #{taskId}
+    </update>
+
+    <update id="updateInQueue">
+        update t_ds_task_group_queue
+               set in_queue = #{inQueue}
+        where id = #{id}
+    </update>
+
+    <update id="updateForceStart">
+        update t_ds_task_group_queue
+               set force_start = #{forceStart}
+        where task_id = #{taskId}
+    </update>
+
+    <update id="updateInQueueLimit1">
+        update t_ds_task_group_queue
+               set in_queue = #{newValue}
+        where group_id = #{groupId} and in_queue = #{oldValue} and status = 
#{status} order by priority desc limit 1
+    </update>
+
+    <update id="updateInQueueCAS">
+        update t_ds_task_group_queue
+               set in_queue = #{newValue}
+        where id = #{id} and in_queue = #{oldValue}
+    </update>
+
+    <select id="queryHighPriorityTasks" 
resultType="org.apache.dolphinscheduler.dao.entity.TaskGroupQueue">
+        select
+        <include refid="baseSql" />
+        from t_ds_task_group_queue
+        where group_id = #{groupId} and status = #{status} and  priority &gt; 
#{priority}
+    </select>
+    <select id="queryTheHighestPriorityTasks" 
resultType="org.apache.dolphinscheduler.dao.entity.TaskGroupQueue">
+        select
+        <include refid="baseSql" />
+        from t_ds_task_group_queue
+        where priority = (select max(priority) from t_ds_task_group_queue 
where group_id = #{groupId}

Review comment:
       if the result of sub sql is null ,this sql will return null ,this is the 
result we want




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to