diff --git a/src/parseable/mod.rs b/src/parseable/mod.rs index 10da8c1b0..8e485c589 100644 --- a/src/parseable/mod.rs +++ b/src/parseable/mod.rs @@ -468,21 +468,10 @@ impl Parseable { } if !time_partition.is_empty() && custom_partition.is_some() { - let custom_partition_list = custom_partition - .as_ref() - .unwrap() - .split(',') - .collect::>(); - if custom_partition_list.contains(&time_partition.as_str()) { - return Err(CreateStreamError::Custom { - msg: format!( - "time partition {} cannot be set as custom partition", - time_partition - ), - status: StatusCode::BAD_REQUEST, - } - .into()); - } + return Err(StreamError::Custom { + msg: "Cannot set both time partition and custom partition".to_string(), + status: StatusCode::BAD_REQUEST, + }); } let schema = validate_static_schema( @@ -630,9 +619,17 @@ impl Parseable { stream_name: &str, custom_partition: Option<&String>, ) -> Result<(), StreamError> { + let stream = self.get_stream(stream_name).expect(STREAM_EXISTS); + if stream.get_time_partition().is_some() { + return Err(StreamError::Custom { + msg: "Cannot set both time partition and custom partition".to_string(), + status: StatusCode::BAD_REQUEST, + }); + } if let Some(custom_partition) = custom_partition { validate_custom_partition(custom_partition)?; } + self.update_custom_partition_in_stream(stream_name.to_string(), custom_partition) .await?; @@ -829,9 +826,9 @@ pub fn validate_time_partition_limit( pub fn validate_custom_partition(custom_partition: &str) -> Result<(), CreateStreamError> { let custom_partition_list = custom_partition.split(',').collect::>(); - if custom_partition_list.len() > 3 { + if custom_partition_list.len() > 1 { return Err(CreateStreamError::Custom { - msg: "Maximum 3 custom partition keys are supported".to_string(), + msg: "Maximum 1 custom partition key is supported".to_string(), status: StatusCode::BAD_REQUEST, }); }