executor: fix threshold check without group by bug (#14961)

Signed-off-by: crazycs <crazycs520@gmail.com>
This commit is contained in:
crazycs
2020-02-27 10:30:13 +08:00
committed by GitHub
parent 902c6ca2b9
commit e45584a9b7

View File

@ -682,11 +682,12 @@ func (c compareStoreStatus) genSQL(timeRange plannercore.QueryTimeRange) string
t2.time>='%[1]s' and t2.time<='%[2]s'`, timeRange.From.Format(plannercore.MetricTableTimeFormat),
timeRange.To.Format(plannercore.MetricTableTimeFormat))
return fmt.Sprintf(`select t1.address,t1.value,t2.address,t2.value,
(t1.value-t2.value)/greatest(t1.value,t2.value) as ratio
(t1.value-t2.value)/t1.value as ratio
from metrics_schema.pd_scheduler_store_status t1 join metrics_schema.pd_scheduler_store_status t2
%s and t1.type='%s' and
%s and t1.type='%s' and t1.time = t2.time and
t1.type=t2.type and t1.address != t2.address and
(t1.value-t2.value)/t1.value>%v;`, condition, c.tp, c.threshold)
(t1.value-t2.value)/t1.value>%v group by t1.address,t1.value,t2.address,t2.value order by ratio desc`,
condition, c.tp, c.threshold)
}
func (c compareStoreStatus) genResult(_ string, row chunk.Row) inspectionResult {