18
18
19
19
use crate :: event:: error:: EventError ;
20
20
use crate :: handlers:: http:: fetch_schema;
21
+ use crate :: option:: Mode ;
21
22
use crate :: utils:: arrow:: record_batches_to_json;
22
23
use actix_web:: http:: header:: ContentType ;
23
24
use actix_web:: web:: { self , Json } ;
@@ -113,6 +114,7 @@ pub async fn query(req: HttpRequest, query_request: Query) -> Result<HttpRespons
113
114
let time_range =
114
115
TimeRange :: parse_human_time ( & query_request. start_time , & query_request. end_time ) ?;
115
116
let tables = resolve_stream_names ( & query_request. query ) ?;
117
+ update_schema_when_distributed ( & tables) . await ?;
116
118
let query: LogicalQuery =
117
119
into_query ( & query_request, & session_state, time_range, & tables) . await ?;
118
120
let creds = extract_session_key_from_req ( & req) ?;
@@ -122,7 +124,6 @@ pub async fn query(req: HttpRequest, query_request: Query) -> Result<HttpRespons
122
124
. first ( )
123
125
. ok_or_else ( || QueryError :: MalformedQuery ( "No table name found in query" ) ) ?;
124
126
user_auth_for_datasets ( & permissions, & tables) . await ?;
125
- update_schema_when_distributed ( & tables) . await ?;
126
127
let time = Instant :: now ( ) ;
127
128
128
129
// if the query is `select count(*) from <dataset>`
@@ -392,12 +393,13 @@ pub async fn update_schema_when_distributed(tables: &Vec<String>) -> Result<(),
392
393
// if the mode is query or prism, we need to update the schema in memory
393
394
// no need to commit schema to storage
394
395
// as the schema is read from memory everytime
395
- for table in tables {
396
- if let Ok ( new_schema) = fetch_schema ( table) . await {
397
- commit_schema ( table, Arc :: new ( new_schema) ) ?;
396
+ if PARSEABLE . options . mode == Mode :: Query || PARSEABLE . options . mode == Mode :: Prism {
397
+ for table in tables {
398
+ if let Ok ( new_schema) = fetch_schema ( table) . await {
399
+ commit_schema ( table, Arc :: new ( new_schema) ) ?;
400
+ }
398
401
}
399
402
}
400
-
401
403
Ok ( ( ) )
402
404
}
403
405
0 commit comments