@@ -38,7 +38,11 @@ use ceresdbproto::storage::{
38
38
use common_types:: { request_id:: RequestId , table:: DEFAULT_SHARD_ID } ;
39
39
use common_util:: { error:: BoxError , runtime:: Runtime } ;
40
40
use futures:: FutureExt ;
41
- use interpreters:: { context:: Context as InterpreterContext , factory:: Factory , interpreter:: Output } ;
41
+ use interpreters:: {
42
+ context:: Context as InterpreterContext ,
43
+ factory:: Factory ,
44
+ interpreter:: { InterpreterPtr , Output } ,
45
+ } ;
42
46
use log:: { error, info} ;
43
47
use query_engine:: executor:: Executor as QueryExecutor ;
44
48
use query_frontend:: plan:: Plan ;
@@ -362,23 +366,64 @@ impl<Q: QueryExecutor + 'static> Proxy<Q> {
362
366
msg : "Request is blocked" ,
363
367
} ) ?;
364
368
369
+ let interpreter =
370
+ self . build_interpreter ( request_id, catalog, schema, plan, deadline, false ) ?;
371
+ Self :: interpreter_execute_plan ( interpreter, deadline) . await
372
+ }
373
+
374
+ async fn execute_plan_involving_partition_table (
375
+ & self ,
376
+ request_id : RequestId ,
377
+ catalog : & str ,
378
+ schema : & str ,
379
+ plan : Plan ,
380
+ deadline : Option < Instant > ,
381
+ ) -> Result < Output > {
382
+ self . instance
383
+ . limiter
384
+ . try_limit ( & plan)
385
+ . box_err ( )
386
+ . context ( Internal {
387
+ msg : "Request is blocked" ,
388
+ } ) ?;
389
+
390
+ let interpreter =
391
+ self . build_interpreter ( request_id, catalog, schema, plan, deadline, true ) ?;
392
+ Self :: interpreter_execute_plan ( interpreter, deadline) . await
393
+ }
394
+
395
+ fn build_interpreter (
396
+ & self ,
397
+ request_id : RequestId ,
398
+ catalog : & str ,
399
+ schema : & str ,
400
+ plan : Plan ,
401
+ deadline : Option < Instant > ,
402
+ enable_partition_table_access : bool ,
403
+ ) -> Result < InterpreterPtr > {
365
404
let interpreter_ctx = InterpreterContext :: builder ( request_id, deadline)
366
405
// Use current ctx's catalog and schema as default catalog and schema
367
406
. default_catalog_and_schema ( catalog. to_string ( ) , schema. to_string ( ) )
407
+ . enable_partition_table_access ( enable_partition_table_access)
368
408
. build ( ) ;
369
409
let interpreter_factory = Factory :: new (
370
410
self . instance . query_executor . clone ( ) ,
371
411
self . instance . catalog_manager . clone ( ) ,
372
412
self . instance . table_engine . clone ( ) ,
373
413
self . instance . table_manipulator . clone ( ) ,
374
414
) ;
375
- let interpreter = interpreter_factory
415
+ interpreter_factory
376
416
. create ( interpreter_ctx, plan)
377
417
. box_err ( )
378
418
. context ( Internal {
379
419
msg : "Failed to create interpreter" ,
380
- } ) ?;
420
+ } )
421
+ }
381
422
423
+ async fn interpreter_execute_plan (
424
+ interpreter : InterpreterPtr ,
425
+ deadline : Option < Instant > ,
426
+ ) -> Result < Output > {
382
427
if let Some ( deadline) = deadline {
383
428
tokio:: time:: timeout_at (
384
429
tokio:: time:: Instant :: from_std ( deadline) ,
@@ -406,4 +451,5 @@ impl<Q: QueryExecutor + 'static> Proxy<Q> {
406
451
pub struct Context {
407
452
pub timeout : Option < Duration > ,
408
453
pub runtime : Arc < Runtime > ,
454
+ pub enable_partition_table_access : bool ,
409
455
}
0 commit comments