@@ -246,6 +246,23 @@ fn validate_custom_partition(custom_partition: &str) -> Result<(), CreateStreamE
246246 Ok ( ( ) )
247247}
248248
249+ fn validate_time_with_custom_partition (
250+ time_partition : & str ,
251+ custom_partition : & str ,
252+ ) -> Result < ( ) , CreateStreamError > {
253+ let custom_partition_list = custom_partition. split ( ',' ) . collect :: < Vec < & str > > ( ) ;
254+ if custom_partition_list. contains ( & time_partition) {
255+ return Err ( CreateStreamError :: Custom {
256+ msg : format ! (
257+ "time partition {} cannot be set as custom partition" ,
258+ time_partition
259+ ) ,
260+ status : StatusCode :: BAD_REQUEST ,
261+ } ) ;
262+ }
263+ Ok ( ( ) )
264+ }
265+
249266fn validate_static_schema (
250267 body : & Bytes ,
251268 stream_name : & str ,
@@ -338,6 +355,10 @@ async fn create_update_stream(
338355 validate_custom_partition ( & custom_partition) ?;
339356 }
340357
358+ if !time_partition. is_empty ( ) && !custom_partition. is_empty ( ) {
359+ validate_time_with_custom_partition ( & time_partition, & custom_partition) ?;
360+ }
361+
341362 let schema = validate_static_schema (
342363 body,
343364 stream_name,
@@ -741,6 +762,7 @@ pub async fn update_custom_partition_in_stream(
741762 custom_partition : & str ,
742763) -> Result < ( ) , CreateStreamError > {
743764 let static_schema_flag = STREAM_INFO . get_static_schema_flag ( & stream_name) . unwrap ( ) ;
765+ let time_partition = STREAM_INFO . get_time_partition ( & stream_name) . unwrap ( ) ;
744766 if static_schema_flag. is_some ( ) {
745767 let schema = STREAM_INFO . schema ( & stream_name) . unwrap ( ) ;
746768
@@ -766,6 +788,18 @@ pub async fn update_custom_partition_in_stream(
766788 status : StatusCode :: BAD_REQUEST ,
767789 } ) ;
768790 }
791+
792+ if let Some ( time_partition) = time_partition. clone ( ) {
793+ if time_partition == * partition {
794+ return Err ( CreateStreamError :: Custom {
795+ msg : format ! (
796+ "time partition {} cannot be set as custom partition" ,
797+ partition
798+ ) ,
799+ status : StatusCode :: BAD_REQUEST ,
800+ } ) ;
801+ }
802+ }
769803 }
770804 }
771805 }
0 commit comments