@@ -28,9 +28,9 @@ use crate::{
2828 metadata:: load_stream_metadata_on_server_start,
2929 option:: { validation:: human_size_to_bytes, Config , Mode , CONFIG } ,
3030 storage:: {
31- object_storage:: { parseable_json_path, stream_json_path} ,
31+ object_storage:: { parseable_json_path, schema_path , stream_json_path} ,
3232 ObjectStorage , ObjectStorageError , PARSEABLE_METADATA_FILE_NAME , PARSEABLE_ROOT_DIRECTORY ,
33- SCHEMA_FILE_NAME , STREAM_ROOT_DIRECTORY ,
33+ STREAM_ROOT_DIRECTORY ,
3434 } ,
3535} ;
3636use arrow_schema:: Schema ;
@@ -166,15 +166,22 @@ async fn migration_hot_tier(stream: &str) -> anyhow::Result<()> {
166166
167167async fn migration_stream ( stream : & str , storage : & dyn ObjectStorage ) -> anyhow:: Result < ( ) > {
168168 let mut arrow_schema: Schema = Schema :: empty ( ) ;
169- let query_schema_path =
170- RelativePathBuf :: from_iter ( [ stream, STREAM_ROOT_DIRECTORY , SCHEMA_FILE_NAME ] ) ;
171- let schema = if let Ok ( schema) = storage. get_object ( & query_schema_path) . await {
169+ let schema_path = schema_path ( stream) ;
170+ let schema = if let Ok ( schema) = storage. get_object ( & schema_path) . await {
172171 schema
173172 } else {
174- storage
175- . create_schema_from_ingestor ( stream)
173+ let querier_schema = storage
174+ . create_schema_from_querier ( stream)
176175 . await
177- . unwrap_or_default ( )
176+ . unwrap_or_default ( ) ;
177+ if !querier_schema. is_empty ( ) {
178+ querier_schema
179+ } else {
180+ storage
181+ . create_schema_from_ingestor ( stream)
182+ . await
183+ . unwrap_or_default ( )
184+ }
178185 } ;
179186
180187 let path = stream_json_path ( stream) ;
@@ -222,7 +229,7 @@ async fn migration_stream(stream: &str, storage: &dyn ObjectStorage) -> anyhow::
222229 let schema = serde_json:: from_slice ( & schema) . ok ( ) ;
223230 arrow_schema = schema_migration:: v1_v4 ( schema) ?;
224231 storage
225- . put_object ( & query_schema_path , to_bytes ( & arrow_schema) )
232+ . put_object ( & schema_path , to_bytes ( & arrow_schema) )
226233 . await ?;
227234 }
228235 Some ( "v2" ) => {
@@ -236,7 +243,7 @@ async fn migration_stream(stream: &str, storage: &dyn ObjectStorage) -> anyhow::
236243 let schema = serde_json:: from_slice ( & schema) ?;
237244 arrow_schema = schema_migration:: v2_v4 ( schema) ?;
238245 storage
239- . put_object ( & query_schema_path , to_bytes ( & arrow_schema) )
246+ . put_object ( & schema_path , to_bytes ( & arrow_schema) )
240247 . await ?;
241248 }
242249 Some ( "v3" ) => {
0 commit comments