feat: support show triggers (#6465)

* feat: support show triggers

* add enterprise feature

* chore: remove unused error
This commit is contained in:
fys
2025-07-07 11:30:57 +08:00
committed by GitHub
parent 351c741c70
commit 3508fddd74
5 changed files with 40 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ license.workspace = true
[features]
testing = []
enterprise = ["common-meta/enterprise", "sql/enterprise"]
enterprise = ["common-meta/enterprise", "sql/enterprise", "query/enterprise"]
[lints]
workspace = true

View File

@@ -829,13 +829,6 @@ pub enum Error {
location: Location,
},
#[cfg(feature = "enterprise")]
#[snafu(display("Trigger related operations are not currently supported"))]
UnsupportedTrigger {
#[snafu(implicit)]
location: Location,
},
#[snafu(display("Invalid time index type: {}", ty))]
InvalidTimeIndexType {
ty: arrow::datatypes::DataType,
@@ -902,8 +895,6 @@ impl ErrorExt for Error {
Error::NotSupported { .. }
| Error::ShowCreateTableBaseOnly { .. }
| Error::SchemaReadOnly { .. } => StatusCode::Unsupported,
#[cfg(feature = "enterprise")]
Error::UnsupportedTrigger { .. } => StatusCode::Unsupported,
Error::TableMetadataManager { source, .. } => source.status_code(),
Error::ParseSql { source, .. } => source.status_code(),
Error::InvalidateTableCache { source, .. } => source.status_code(),

View File

@@ -231,10 +231,12 @@ impl StatementExecutor {
#[tracing::instrument(skip_all)]
pub(super) async fn show_triggers(
&self,
_stmt: sql::statements::show::trigger::ShowTriggers,
_query_ctx: QueryContextRef,
stmt: sql::statements::show::trigger::ShowTriggers,
query_ctx: QueryContextRef,
) -> Result<Output> {
crate::error::UnsupportedTriggerSnafu.fail()
query::sql::show_triggers(stmt, &self.query_engine, &self.catalog_manager, query_ctx)
.await
.context(ExecuteStatementSnafu)
}
#[tracing::instrument(skip_all)]

View File

@@ -7,6 +7,9 @@ license.workspace = true
[lints]
workspace = true
[features]
enterprise = []
[dependencies]
ahash.workspace = true
api.workspace = true

View File

@@ -950,6 +950,37 @@ pub async fn show_flows(
.await
}
#[cfg(feature = "enterprise")]
pub async fn show_triggers(
stmt: sql::statements::show::trigger::ShowTriggers,
query_engine: &QueryEngineRef,
catalog_manager: &CatalogManagerRef,
query_ctx: QueryContextRef,
) -> Result<Output> {
use catalog::information_schema::TRIGGER_LIST;
const TRIGGER_NAME: &str = "trigger_name";
const TRIGGERS_COLUMN: &str = "Triggers";
let projects = vec![(TRIGGER_NAME, TRIGGERS_COLUMN)];
let like_field = Some(TRIGGER_NAME);
let sort = vec![col(TRIGGER_NAME).sort(true, true)];
query_from_information_schema_table(
query_engine,
catalog_manager,
query_ctx,
TRIGGER_LIST,
vec![],
projects,
vec![],
like_field,
sort,
stmt.kind,
)
.await
}
pub fn show_create_flow(
flow_name: ObjectName,
flow_val: FlowInfoValue,