@@ -49,6 +49,7 @@ use crate::catalog::{self, manifest::Manifest, snapshot::Snapshot};
4949use crate :: correlation:: { CorrelationConfig , CorrelationError } ;
5050use crate :: event:: format:: LogSource ;
5151use crate :: event:: format:: LogSourceEntry ;
52+ use crate :: handlers:: http:: fetch_schema;
5253use crate :: handlers:: http:: modal:: ingest_server:: INGESTOR_EXPECT ;
5354use crate :: handlers:: http:: modal:: ingest_server:: INGESTOR_META ;
5455use crate :: handlers:: http:: users:: CORRELATION_DIR ;
@@ -652,44 +653,18 @@ pub trait ObjectStorage: Debug + Send + Sync + 'static {
652653 Ok ( Bytes :: new ( ) )
653654 }
654655
655- ///create schema from querier schema from storage
656- async fn create_schema_from_querier (
656+ ///create schema from storage
657+ async fn create_schema_from_storage (
657658 & self ,
658659 stream_name : & str ,
659660 ) -> Result < Bytes , ObjectStorageError > {
660- let path =
661- RelativePathBuf :: from_iter ( [ stream_name, STREAM_ROOT_DIRECTORY , SCHEMA_FILE_NAME ] ) ;
662- if let Ok ( querier_schema_bytes) = self . get_object ( & path) . await {
663- self . put_object ( & schema_path ( stream_name) , querier_schema_bytes. clone ( ) )
664- . await ?;
665- return Ok ( querier_schema_bytes) ;
666- }
667- Ok ( Bytes :: new ( ) )
668- }
669-
670- ///create schema from ingestor schema from storage
671- async fn create_schema_from_ingestor (
672- & self ,
673- stream_name : & str ,
674- ) -> Result < Bytes , ObjectStorageError > {
675- let path = RelativePathBuf :: from_iter ( [ stream_name, STREAM_ROOT_DIRECTORY ] ) ;
676- if let Some ( schema_obs) = self
677- . get_objects (
678- Some ( & path) ,
679- Box :: new ( |file_name| {
680- file_name. starts_with ( ".ingestor" ) && file_name. ends_with ( "schema" )
681- } ) ,
682- )
683- . await
684- . into_iter ( )
685- . next ( )
686- {
687- let schema_ob = & schema_obs[ 0 ] ;
688- self . put_object ( & schema_path ( stream_name) , schema_ob. clone ( ) )
689- . await ?;
690- return Ok ( schema_ob. clone ( ) ) ;
691- }
692- Ok ( Bytes :: new ( ) )
661+ let schema = fetch_schema ( stream_name) . await ?;
662+ // convert to bytes
663+ let schema = serde_json:: to_vec ( & schema) ?;
664+ let schema_bytes = Bytes :: from ( schema) ;
665+ self . put_object ( & schema_path ( stream_name) , schema_bytes. clone ( ) )
666+ . await ?;
667+ Ok ( schema_bytes)
693668 }
694669
695670 async fn get_stream_meta_from_storage (
0 commit comments