diff --git a/src/common/src/types/mod.rs b/src/common/src/types/mod.rs index 75139c6bed5bf..7b6f393725e71 100644 --- a/src/common/src/types/mod.rs +++ b/src/common/src/types/mod.rs @@ -101,9 +101,10 @@ pub type F64 = ordered_float::OrderedFloat; #[derive( Debug, Display, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, EnumDiscriminants, FromStr, )] -#[strum_discriminants(derive(strum_macros::EnumIter, Hash, Ord, PartialOrd))] +#[strum_discriminants(derive(Hash, Ord, PartialOrd))] #[strum_discriminants(name(DataTypeName))] #[strum_discriminants(vis(pub))] +#[cfg_attr(test, strum_discriminants(derive(strum_macros::EnumIter)))] pub enum DataType { #[display("boolean")] #[from_str(regex = "(?i)^bool$|^boolean$")] diff --git a/src/meta/src/manager/streaming_job.rs b/src/meta/src/manager/streaming_job.rs index b10fce797b08e..5f989df4bb5d5 100644 --- a/src/meta/src/manager/streaming_job.rs +++ b/src/meta/src/manager/streaming_job.rs @@ -18,12 +18,15 @@ use risingwave_common::catalog::TableVersionId; use risingwave_common::util::epoch::Epoch; use risingwave_pb::catalog::{CreateType, Index, PbSource, Sink, Table}; use risingwave_pb::ddl_service::TableJobType; +use strum::EnumDiscriminants; use crate::model::FragmentId; // This enum is used in order to re-use code in `DdlServiceImpl` for creating MaterializedView and // Sink. -#[derive(Debug, Clone)] +#[derive(Debug, Clone, EnumDiscriminants)] +#[strum_discriminants(name(DdlType))] +#[strum_discriminants(vis(pub))] pub enum StreamingJob { MaterializedView(Table), Sink(Sink, Option<(Table, Option)>), @@ -32,15 +35,6 @@ pub enum StreamingJob { Source(PbSource), } -#[derive(Debug, Clone, Copy, PartialEq)] -pub enum DdlType { - MaterializedView, - Sink, - Table, - Index, - Source, -} - #[cfg(test)] #[allow(clippy::derivable_impls)] impl Default for DdlType { @@ -51,18 +45,6 @@ impl Default for DdlType { } } -impl From<&StreamingJob> for DdlType { - fn from(job: &StreamingJob) -> Self { - match job { - StreamingJob::MaterializedView(_) => DdlType::MaterializedView, - StreamingJob::Sink(_, _) => DdlType::Sink, - StreamingJob::Table(_, _, _) => DdlType::Table, - StreamingJob::Index(_, _) => DdlType::Index, - StreamingJob::Source(_) => DdlType::Source, - } - } -} - impl StreamingJob { pub fn mark_created(&mut self) { let created_at_epoch = Some(Epoch::now().0);