@@ -50,7 +50,7 @@ pub async fn create_update_stream(
5050 stream_type,
5151 ) = fetch_headers_from_put_stream_request ( req) ;
5252
53- if metadata:: STREAM_INFO . stream_exists ( stream_name) && update_stream_flag != "true" {
53+ if metadata:: STREAM_INFO . stream_exists ( stream_name) && !update_stream_flag {
5454 return Err ( StreamError :: Custom {
5555 msg : format ! (
5656 "Logstream {stream_name} already exists, please create a new log stream with unique name"
@@ -71,12 +71,12 @@ pub async fn create_update_stream(
7171 } ) ;
7272 }
7373
74- if update_stream_flag == "true" {
74+ if update_stream_flag {
7575 return update_stream (
7676 req,
7777 stream_name,
7878 & time_partition,
79- & static_schema_flag,
79+ static_schema_flag,
8080 & time_partition_limit,
8181 & custom_partition,
8282 )
@@ -102,15 +102,15 @@ pub async fn create_update_stream(
102102 stream_name,
103103 & time_partition,
104104 & custom_partition,
105- & static_schema_flag,
105+ static_schema_flag,
106106 ) ?;
107107
108108 create_stream (
109109 stream_name. to_string ( ) ,
110110 & time_partition,
111111 time_partition_in_days,
112112 & custom_partition,
113- & static_schema_flag,
113+ static_schema_flag,
114114 schema,
115115 & stream_type,
116116 )
@@ -123,7 +123,7 @@ async fn update_stream(
123123 req : & HttpRequest ,
124124 stream_name : & str ,
125125 time_partition : & str ,
126- static_schema_flag : & str ,
126+ static_schema_flag : bool ,
127127 time_partition_limit : & str ,
128128 custom_partition : & str ,
129129) -> Result < HeaderMap , StreamError > {
@@ -136,7 +136,7 @@ async fn update_stream(
136136 status : StatusCode :: BAD_REQUEST ,
137137 } ) ;
138138 }
139- if ! static_schema_flag. is_empty ( ) {
139+ if static_schema_flag {
140140 return Err ( StreamError :: Custom {
141141 msg : "Altering the schema of an existing stream is restricted." . to_string ( ) ,
142142 status : StatusCode :: BAD_REQUEST ,
@@ -167,12 +167,12 @@ async fn validate_and_update_custom_partition(
167167
168168pub fn fetch_headers_from_put_stream_request (
169169 req : & HttpRequest ,
170- ) -> ( String , String , String , String , String , String ) {
170+ ) -> ( String , String , String , bool , bool , String ) {
171171 let mut time_partition = String :: default ( ) ;
172172 let mut time_partition_limit = String :: default ( ) ;
173173 let mut custom_partition = String :: default ( ) ;
174- let mut static_schema_flag = String :: default ( ) ;
175- let mut update_stream = String :: default ( ) ;
174+ let mut static_schema_flag = false ;
175+ let mut update_stream_flag = false ;
176176 let mut stream_type = StreamType :: UserDefined . to_string ( ) ;
177177 req. headers ( ) . iter ( ) . for_each ( |( key, value) | {
178178 if key == TIME_PARTITION_KEY {
@@ -184,11 +184,11 @@ pub fn fetch_headers_from_put_stream_request(
184184 if key == CUSTOM_PARTITION_KEY {
185185 custom_partition = value. to_str ( ) . unwrap ( ) . to_string ( ) ;
186186 }
187- if key == STATIC_SCHEMA_FLAG {
188- static_schema_flag = value . to_str ( ) . unwrap ( ) . to_string ( ) ;
187+ if key == STATIC_SCHEMA_FLAG && value . to_str ( ) . unwrap ( ) == "true" {
188+ static_schema_flag = true ;
189189 }
190- if key == UPDATE_STREAM_KEY {
191- update_stream = value . to_str ( ) . unwrap ( ) . to_string ( ) ;
190+ if key == UPDATE_STREAM_KEY && value . to_str ( ) . unwrap ( ) == "true" {
191+ update_stream_flag = true ;
192192 }
193193 if key == STREAM_TYPE_KEY {
194194 stream_type = value. to_str ( ) . unwrap ( ) . to_string ( ) ;
@@ -200,7 +200,7 @@ pub fn fetch_headers_from_put_stream_request(
200200 time_partition_limit,
201201 custom_partition,
202202 static_schema_flag,
203- update_stream ,
203+ update_stream_flag ,
204204 stream_type,
205205 )
206206}
@@ -258,9 +258,9 @@ pub fn validate_static_schema(
258258 stream_name : & str ,
259259 time_partition : & str ,
260260 custom_partition : & str ,
261- static_schema_flag : & str ,
261+ static_schema_flag : bool ,
262262) -> Result < Arc < Schema > , CreateStreamError > {
263- if static_schema_flag == "true" {
263+ if static_schema_flag {
264264 if body. is_empty ( ) {
265265 return Err ( CreateStreamError :: Custom {
266266 msg : format ! (
@@ -317,7 +317,7 @@ pub async fn update_custom_partition_in_stream(
317317) -> Result < ( ) , CreateStreamError > {
318318 let static_schema_flag = STREAM_INFO . get_static_schema_flag ( & stream_name) . unwrap ( ) ;
319319 let time_partition = STREAM_INFO . get_time_partition ( & stream_name) . unwrap ( ) ;
320- if static_schema_flag. is_some ( ) {
320+ if static_schema_flag {
321321 let schema = STREAM_INFO . schema ( & stream_name) . unwrap ( ) ;
322322
323323 if !custom_partition. is_empty ( ) {
@@ -383,7 +383,7 @@ pub async fn create_stream(
383383 time_partition : & str ,
384384 time_partition_limit : Option < NonZeroU32 > ,
385385 custom_partition : & str ,
386- static_schema_flag : & str ,
386+ static_schema_flag : bool ,
387387 schema : Arc < Schema > ,
388388 stream_type : & str ,
389389) -> Result < ( ) , CreateStreamError > {
@@ -423,7 +423,7 @@ pub async fn create_stream(
423423 time_partition. to_string ( ) ,
424424 time_partition_limit,
425425 custom_partition. to_string ( ) ,
426- static_schema_flag. to_string ( ) ,
426+ static_schema_flag,
427427 static_schema,
428428 stream_type,
429429 SchemaVersion :: V1 , // New stream
@@ -473,7 +473,7 @@ pub async fn create_stream_and_schema_from_storage(stream_name: &str) -> Result<
473473 . time_partition_limit
474474 . and_then ( |limit| limit. parse ( ) . ok ( ) ) ;
475475 let custom_partition = stream_metadata. custom_partition . as_deref ( ) . unwrap_or ( "" ) ;
476- let static_schema_flag = stream_metadata. static_schema_flag . as_deref ( ) . unwrap_or ( "" ) ;
476+ let static_schema_flag = stream_metadata. static_schema_flag ;
477477 let stream_type = stream_metadata. stream_type . as_deref ( ) . unwrap_or ( "" ) ;
478478 let schema_version = stream_metadata. schema_version ;
479479
@@ -483,7 +483,7 @@ pub async fn create_stream_and_schema_from_storage(stream_name: &str) -> Result<
483483 time_partition. to_string ( ) ,
484484 time_partition_limit,
485485 custom_partition. to_string ( ) ,
486- static_schema_flag. to_string ( ) ,
486+ static_schema_flag,
487487 static_schema,
488488 stream_type,
489489 schema_version,
0 commit comments