Skip to content

Commit e4ca566

Browse files
author
Devdutt Shenoi
authored
Merge branch 'main' into merge-sync
2 parents 4a2a659 + 245ec54 commit e4ca566

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/parseable/mod.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -468,21 +468,10 @@ impl Parseable {
468468
}
469469

470470
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+
});
486475
}
487476

488477
let schema = validate_static_schema(
@@ -630,9 +619,17 @@ impl Parseable {
630619
stream_name: &str,
631620
custom_partition: Option<&String>,
632621
) -> 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+
}
633629
if let Some(custom_partition) = custom_partition {
634630
validate_custom_partition(custom_partition)?;
635631
}
632+
636633
self.update_custom_partition_in_stream(stream_name.to_string(), custom_partition)
637634
.await?;
638635

@@ -829,9 +826,9 @@ pub fn validate_time_partition_limit(
829826

830827
pub fn validate_custom_partition(custom_partition: &str) -> Result<(), CreateStreamError> {
831828
let custom_partition_list = custom_partition.split(',').collect::<Vec<&str>>();
832-
if custom_partition_list.len() > 3 {
829+
if custom_partition_list.len() > 1 {
833830
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(),
835832
status: StatusCode::BAD_REQUEST,
836833
});
837834
}

0 commit comments

Comments
 (0)