-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathTaskMapper.xml
More file actions
137 lines (125 loc) · 5.23 KB
/
TaskMapper.xml
File metadata and controls
137 lines (125 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?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.dinky.mapper.TaskMapper">
<select id="selectForProTable" resultType="org.dinky.data.model.Task">
select
a.*
from
dinky_task a
<where>
1=1
<if test='param.name!=null and param.name!=""'>
and a.name like concat('%',#{param.name},'%')
</if>
<if test='param.createTime!=null and param.createTime!=""'>
and a.create_time <![CDATA[>=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test='param.updateTime!=null and param.updateTime!=""'>
and a.update_time <![CDATA[>=]]> str_to_date( #{param.updateTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!="" and !ew.sqlSegment.startsWith(" ORDER BY")'>
and
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!=""'>
${ew.sqlSegment}
</if>
</where>
</select>
<select id="queryAllSizeByName" resultType="java.lang.Integer">
SELECT count(*)
from dinky_task
where `name` REGEXP concat(#{name}, '-[0-9]$')
</select>
<select id="getTaskByNameAndTenantId" resultType="org.dinky.data.model.Task">
select *
from dinky_task
where 1 = 1
and name = #{name}
and tenant_id = #{tenantId}
</select>
<select id="getTenantByTaskId" resultType="java.lang.Integer">
select tenant_id
from dinky_task
where id = #{id}
</select>
<select id="getTenantByTaskName" resultType="java.lang.Integer">
select tenant_id
from dinky_task
where name = #{taskName}
</select>
<select id="queryOnLineTaskByDoneStatus" resultType="org.dinky.data.model.Task">
select t.id as id, t.name as name
from dinky_task t
left join dinky_catalogue c on c.task_id = t.id
left join dinky_job_instance i on i.id = t.job_instance_id
where
c.parent_id in
<foreach collection="parentIds" item="parentId" open="(" close=")" separator=",">
#{parentId}
</foreach>
and c.task_id is not null
and c.is_leaf = 1
and t.step in
<foreach collection="stepIds" item="stepId" open="(" close=")" separator=",">
#{stepId}
</foreach>
and t.enabled = 1
<if test="includeNull == true">
and ((i.status is null) or (i.status in <foreach collection="jobStatuses" item="jobStatus" open="("
close=")" separator=",">
#{jobStatus}
</foreach>))
</if>
<if test="includeNull != true">
and i.status in
<foreach collection="jobStatuses" item="jobStatus" open="(" close=")" separator=",">
#{jobStatus}
</foreach>
</if>
</select>
<select id="getTaskOnlineRate" resultType="org.dinky.data.model.home.JobTypeOverView">
SELECT dialect jobType,
round(coalesce(sum(CASE WHEN step = 5 THEN 1 ELSE 0 END) /
CASE
WHEN sum(CASE WHEN step <![CDATA[ < ]]> 5 THEN 1 ELSE 0 END) = 0 then 1
else sum(CASE WHEN step <![CDATA[ < ]]> 5 THEN 1 ELSE 0 END) end
*
100, 0),
2) rate
FROM dinky_task
WHERE enabled = 1
GROUP BY dialect
</select>
<select id="getJobStreamingOrBatchModelOverview" resultType="org.dinky.data.model.home.JobModelOverview">
select coalesce(sum(case when batch_model = 'streaming' then cnt else 0 end),0) as streamingJobCount,
coalesce(sum(case when batch_model = 'batch' then cnt else 0 end) ,0) as batchJobCount
from (select case a.batch_model when 0 then 'streaming' when 1 then 'batch' end as batch_model,
coalesce(count(1), 0) as cnt
from dinky_task a
where a.batch_model is not null
and a.dialect in (
'FlinkSql',
'FlinkJar',
'KubernetesApplication')
group by a.batch_model) a
;
</select>
</mapper>