operator/statement/
describe.rs1use common_error::ext::BoxedError;
16use common_query::Output;
17use common_telemetry::tracing;
18use session::context::QueryContextRef;
19use session::table_name::table_idents_to_full_name;
20use snafu::{OptionExt, ResultExt};
21use sql::statements::describe::DescribeTable;
22use sql::util::format_raw_object_name;
23
24use crate::error::{
25 CatalogSnafu, DescribeStatementSnafu, ExternalSnafu, Result, TableNotFoundSnafu,
26};
27use crate::statement::StatementExecutor;
28
29impl StatementExecutor {
30 #[tracing::instrument(skip_all)]
31 pub(super) async fn describe_table(
32 &self,
33 stmt: DescribeTable,
34 query_ctx: QueryContextRef,
35 ) -> Result<Output> {
36 let (catalog, schema, table) = table_idents_to_full_name(stmt.name(), &query_ctx)
37 .map_err(BoxedError::new)
38 .context(ExternalSnafu)?;
39
40 let table = self
41 .catalog_manager
42 .table(&catalog, &schema, &table, Some(&query_ctx))
43 .await
44 .context(CatalogSnafu)?
45 .with_context(|| TableNotFoundSnafu {
46 table_name: format_raw_object_name(stmt.name()),
47 })?;
48
49 query::sql::describe_table(table).context(DescribeStatementSnafu)
50 }
51}