@@ -65,6 +65,7 @@ use crate::catalog::{self, manifest::Manifest, snapshot::Snapshot};
6565use crate :: correlation:: { CorrelationConfig , CorrelationError } ;
6666use crate :: event:: format:: LogSource ;
6767use crate :: event:: format:: LogSourceEntry ;
68+ use crate :: handlers:: http:: fetch_schema;
6869use crate :: handlers:: http:: ingest:: PostError ;
6970use crate :: handlers:: http:: modal:: ingest_server:: INGESTOR_EXPECT ;
7071use crate :: handlers:: http:: modal:: ingest_server:: INGESTOR_META ;
@@ -671,44 +672,18 @@ pub trait ObjectStorage: Debug + Send + Sync + 'static {
671672 Ok ( Bytes :: new ( ) )
672673 }
673674
674- ///create schema from querier schema from storage
675- async fn create_schema_from_querier (
675+ ///create schema from storage
676+ async fn create_schema_from_storage (
676677 & self ,
677678 stream_name : & str ,
678679 ) -> Result < Bytes , ObjectStorageError > {
679- let path =
680- RelativePathBuf :: from_iter ( [ stream_name, STREAM_ROOT_DIRECTORY , SCHEMA_FILE_NAME ] ) ;
681- if let Ok ( querier_schema_bytes) = self . get_object ( & path) . await {
682- self . put_object ( & schema_path ( stream_name) , querier_schema_bytes. clone ( ) )
683- . await ?;
684- return Ok ( querier_schema_bytes) ;
685- }
686- Ok ( Bytes :: new ( ) )
687- }
688-
689- ///create schema from ingestor schema from storage
690- async fn create_schema_from_ingestor (
691- & self ,
692- stream_name : & str ,
693- ) -> Result < Bytes , ObjectStorageError > {
694- let path = RelativePathBuf :: from_iter ( [ stream_name, STREAM_ROOT_DIRECTORY ] ) ;
695- if let Some ( schema_obs) = self
696- . get_objects (
697- Some ( & path) ,
698- Box :: new ( |file_name| {
699- file_name. starts_with ( ".ingestor" ) && file_name. ends_with ( "schema" )
700- } ) ,
701- )
702- . await
703- . into_iter ( )
704- . next ( )
705- {
706- let schema_ob = & schema_obs[ 0 ] ;
707- self . put_object ( & schema_path ( stream_name) , schema_ob. clone ( ) )
708- . await ?;
709- return Ok ( schema_ob. clone ( ) ) ;
710- }
711- Ok ( Bytes :: new ( ) )
680+ let schema = fetch_schema ( stream_name) . await ?;
681+ // convert to bytes
682+ let schema = serde_json:: to_vec ( & schema) ?;
683+ let schema_bytes = Bytes :: from ( schema) ;
684+ self . put_object ( & schema_path ( stream_name) , schema_bytes. clone ( ) )
685+ . await ?;
686+ Ok ( schema_bytes)
712687 }
713688
714689 async fn get_stream_meta_from_storage (
0 commit comments