From 3ae8a88198896b0c788c71d2264549f234feafeb Mon Sep 17 00:00:00 2001 From: Xin Hao Zhang Date: Tue, 21 Feb 2023 13:24:05 -0500 Subject: [PATCH] server: format jobs api query Reformats query string for the jobs admin endpoint. Epic: none Release note: None --- pkg/server/admin.go | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/pkg/server/admin.go b/pkg/server/admin.go index 7d2370abf3b3..b581eb160db6 100644 --- a/pkg/server/admin.go +++ b/pkg/server/admin.go @@ -2250,16 +2250,33 @@ func jobsHelper( q := makeSQLQuery() q.Append(` - SELECT job_id, job_type, description, statement, user_name, descriptor_ids, - case - when ` + retryRunningCondition + ` then 'retry-running' - when ` + retryRevertingCondition + ` then 'retry-reverting' - else status - end as status, running_status, created, started, finished, modified, fraction_completed, - high_water_timestamp, error, last_run, next_run, num_runs, execution_events::string, coordinator_id - FROM crdb_internal.jobs - WHERE true - `) +SELECT + job_id, + job_type, + description, + statement, + user_name, + descriptor_ids, + case + when ` + retryRunningCondition + ` then 'retry-running' + when ` + retryRevertingCondition + ` then 'retry-reverting' + else status + end as status, + running_status, + created, + started, + finished, + modified, + fraction_completed, + high_water_timestamp, + error, + last_run, + next_run, + num_runs, + execution_events::string, + coordinator_id +FROM crdb_internal.jobs +WHERE true`) // Simplifies filter construction below. if req.Status == "retrying" { q.Append(" AND ( ( " + retryRunningCondition + " ) OR ( " + retryRevertingCondition + " ) )") } else if req.Status != "" {