@@ -468,21 +468,10 @@ impl Parseable {
468
468
}
469
469
470
470
if !time_partition. is_empty ( ) && custom_partition. is_some ( ) {
471
- let custom_partition_list = custom_partition
472
- . as_ref ( )
473
- . unwrap ( )
474
- . split ( ',' )
475
- . collect :: < Vec < & str > > ( ) ;
476
- if custom_partition_list. contains ( & time_partition. as_str ( ) ) {
477
- return Err ( CreateStreamError :: Custom {
478
- msg : format ! (
479
- "time partition {} cannot be set as custom partition" ,
480
- time_partition
481
- ) ,
482
- status : StatusCode :: BAD_REQUEST ,
483
- }
484
- . into ( ) ) ;
485
- }
471
+ return Err ( StreamError :: Custom {
472
+ msg : "Cannot set both time partition and custom partition" . to_string ( ) ,
473
+ status : StatusCode :: BAD_REQUEST ,
474
+ } ) ;
486
475
}
487
476
488
477
let schema = validate_static_schema (
@@ -630,9 +619,17 @@ impl Parseable {
630
619
stream_name : & str ,
631
620
custom_partition : Option < & String > ,
632
621
) -> Result < ( ) , StreamError > {
622
+ let stream = self . get_stream ( stream_name) . expect ( STREAM_EXISTS ) ;
623
+ if stream. get_time_partition ( ) . is_some ( ) {
624
+ return Err ( StreamError :: Custom {
625
+ msg : "Cannot set both time partition and custom partition" . to_string ( ) ,
626
+ status : StatusCode :: BAD_REQUEST ,
627
+ } ) ;
628
+ }
633
629
if let Some ( custom_partition) = custom_partition {
634
630
validate_custom_partition ( custom_partition) ?;
635
631
}
632
+
636
633
self . update_custom_partition_in_stream ( stream_name. to_string ( ) , custom_partition)
637
634
. await ?;
638
635
@@ -829,9 +826,9 @@ pub fn validate_time_partition_limit(
829
826
830
827
pub fn validate_custom_partition ( custom_partition : & str ) -> Result < ( ) , CreateStreamError > {
831
828
let custom_partition_list = custom_partition. split ( ',' ) . collect :: < Vec < & str > > ( ) ;
832
- if custom_partition_list. len ( ) > 3 {
829
+ if custom_partition_list. len ( ) > 1 {
833
830
return Err ( CreateStreamError :: Custom {
834
- msg : "Maximum 3 custom partition keys are supported" . to_string ( ) ,
831
+ msg : "Maximum 1 custom partition key is supported" . to_string ( ) ,
835
832
status : StatusCode :: BAD_REQUEST ,
836
833
} ) ;
837
834
}
0 commit comments