risingwave_frontend/handler/
cancel_job.rsuse pgwire::pg_response::{PgResponse, StatementType};
use risingwave_common::types::Fields;
use risingwave_pb::meta::cancel_creating_jobs_request::{CreatingJobIds, PbJobs};
use risingwave_sqlparser::ast::JobIdents;
use super::RwPgResponseBuilderExt;
use crate::error::Result;
use crate::handler::{HandlerArgs, RwPgResponse};
pub(super) async fn handle_cancel(
handler_args: HandlerArgs,
jobs: JobIdents,
) -> Result<RwPgResponse> {
let session = handler_args.session;
let canceled_jobs = session
.env()
.meta_client()
.cancel_creating_jobs(PbJobs::Ids(CreatingJobIds { job_ids: jobs.0 }))
.await?;
let rows = canceled_jobs
.into_iter()
.map(|id| CancelRow { id: id.to_string() });
Ok(PgResponse::builder(StatementType::CANCEL_COMMAND)
.rows(rows)
.into())
}
#[derive(Fields)]
#[fields(style = "Title Case")]
struct CancelRow {
id: String,
}