mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2026-05-21 07:20:41 +00:00
feat: support show triggers (#6465)
* feat: support show triggers * add enterprise feature * chore: remove unused error
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -7,6 +7,9 @@ license.workspace = true
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
[features]
|
||||
enterprise = []
|
||||
|
||||
[dependencies]
|
||||
ahash.workspace = true
|
||||
api.workspace = true
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user