risingwave_frontend/handler/
cancel_job.rs1use pgwire::pg_response::{PgResponse, StatementType};
16use risingwave_common::types::Fields;
17use risingwave_pb::meta::cancel_creating_jobs_request::{CreatingJobIds, PbJobs};
18use risingwave_sqlparser::ast::JobIdents;
19
20use super::RwPgResponseBuilderExt;
21use crate::error::Result;
22use crate::handler::{HandlerArgs, RwPgResponse};
23
24pub(super) async fn handle_cancel(
25 handler_args: HandlerArgs,
26 jobs: JobIdents,
27) -> Result<RwPgResponse> {
28 let session = handler_args.session;
29
30 let canceled_jobs = session
31 .env()
32 .meta_client()
33 .cancel_creating_jobs(PbJobs::Ids(CreatingJobIds { job_ids: jobs.0 }))
34 .await?;
35 let rows = canceled_jobs
36 .into_iter()
37 .map(|id| CancelRow { id: id.to_string() });
38 Ok(PgResponse::builder(StatementType::CANCEL_COMMAND)
39 .rows(rows)
40 .into())
41}
42
43#[derive(Fields)]
44#[fields(style = "Title Case")]
45struct CancelRow {
46 id: String,
47}