@@ -2,7 +2,6 @@ use crate::models::{QueryContext, QueryResult};
22use crate :: service:: { CoreExecutionService , ExecutionService } ;
33use crate :: utils:: Config ;
44use catalog_metastore:: InMemoryMetastore ;
5- use catalog_metastore:: metastore_config:: MetastoreBootstrapConfig ;
65use catalog_metastore:: models:: table:: TableIdent as MetastoreTableIdent ;
76use catalog_metastore:: {
87 Database as MetastoreDatabase , Schema as MetastoreSchema , SchemaIdent as MetastoreSchemaIdent ,
@@ -435,159 +434,3 @@ async fn test_query_timeout() {
435434 "Expected query execution exceeded timeout error but got {res:?}"
436435 ) ;
437436}
438-
439- #[ tokio:: test]
440- #[ allow( clippy:: expect_used) ]
441- async fn test_execute_read_only_mode ( ) {
442- //setup
443- let metastore = Arc :: new ( InMemoryMetastore :: new ( ) ) ;
444- let metastore_config = MetastoreBootstrapConfig :: bootstrap ( ) ;
445- metastore_config
446- . apply ( metastore. clone ( ) )
447- . await
448- . expect ( "Failed to apply config" ) ;
449-
450- let execution_svc = CoreExecutionService :: new ( metastore. clone ( ) , Arc :: new ( Config :: default ( ) ) )
451- . await
452- . expect ( "Failed to create execution service" ) ;
453-
454- execution_svc
455- . create_session ( "test_session_id" )
456- . await
457- . expect ( "Failed to create session" ) ;
458-
459- execution_svc
460- . query (
461- "test_session_id" ,
462- "CREATE OR REPLACE TABLE fetch_test(c1 INT)" ,
463- QueryContext :: default ( ) ,
464- )
465- . await
466- . expect ( "Failed to execute query" ) ;
467-
468- execution_svc
469- . query (
470- "test_session_id" ,
471- "INSERT INTO fetch_test VALUES (1),(2),(3),(4)" ,
472- QueryContext :: default ( ) ,
473- )
474- . await
475- . expect ( "Failed to execute query" ) ;
476-
477- drop ( execution_svc) ;
478-
479- //read only mode test
480- let execution_svc =
481- CoreExecutionService :: new ( metastore, Arc :: new ( Config :: default ( ) . with_read_only ( true ) ) )
482- . await
483- . expect ( "Failed to create execution service" ) ;
484-
485- execution_svc
486- . create_session ( "test_session_id" )
487- . await
488- . expect ( "Failed to create session" ) ;
489-
490- //should fail
491- execution_svc
492- . query (
493- "test_session_id" ,
494- "CREATE OR REPLACE TABLE fetch_test(c1 INT)" ,
495- QueryContext :: default ( ) ,
496- )
497- . await
498- . expect_err ( "Read only mode failed" ) ;
499-
500- //should fail
501- execution_svc
502- . query (
503- "test_session_id" ,
504- "INSERT INTO fetch_test VALUES (1),(2),(3),(4)" ,
505- QueryContext :: default ( ) ,
506- )
507- . await
508- . expect_err ( "Read only mode failed" ) ;
509-
510- execution_svc
511- . query ( "test_session_id" , "SELECT 1" , QueryContext :: default ( ) )
512- . await
513- . expect ( "Failed to execute query in read only mode" ) ;
514-
515- execution_svc
516- . query (
517- "test_session_id" ,
518- "EXPLAIN SELECT 1" ,
519- QueryContext :: default ( ) ,
520- )
521- . await
522- . expect ( "Failed to execute query in read only mode" ) ;
523-
524- execution_svc
525- . query (
526- "test_session_id" ,
527- "WITH limited_data AS (
528- SELECT c1 FROM fetch_test ORDER BY c1 FETCH FIRST 3 ROWS
529- )
530- SELECT * FROM limited_data ORDER BY c1;" ,
531- QueryContext :: default ( ) ,
532- )
533- . await
534- . expect ( "Failed to execute query in read only mode" ) ;
535-
536- execution_svc
537- . query (
538- "test_session_id" ,
539- "EXPLAIN WITH limited_data AS (
540- SELECT c1 FROM fetch_test ORDER BY c1 FETCH FIRST 3 ROWS
541- )
542- SELECT * FROM limited_data ORDER BY c1;" ,
543- QueryContext :: default ( ) ,
544- )
545- . await
546- . expect ( "Failed to execute query in read only mode" ) ;
547-
548- execution_svc
549- . query (
550- "test_session_id" ,
551- "SELECT 1 UNION ALL SELECT c1 FROM fetch_test;" ,
552- QueryContext :: default ( ) ,
553- )
554- . await
555- . expect ( "Failed to execute query in read only mode" ) ;
556-
557- execution_svc
558- . query (
559- "test_session_id" ,
560- "EXPLAIN SELECT 1 UNION ALL SELECT c1 FROM fetch_test;" ,
561- QueryContext :: default ( ) ,
562- )
563- . await
564- . expect ( "Failed to execute query in read only mode" ) ;
565-
566- execution_svc
567- . query (
568- "test_session_id" ,
569- "USE SCHEMA public;" ,
570- QueryContext :: default ( ) ,
571- )
572- . await
573- . expect ( "Failed to execute query in read only mode" ) ;
574-
575- execution_svc
576- . query ( "test_session_id" , "SHOW TABLES;" , QueryContext :: default ( ) )
577- . await
578- . expect ( "Failed to execute query in read only mode" ) ;
579-
580- execution_svc
581- . query ( "test_session_id" , "SHOW SCHEMAS;" , QueryContext :: default ( ) )
582- . await
583- . expect ( "Failed to execute query in read only mode" ) ;
584-
585- execution_svc
586- . query (
587- "test_session_id" ,
588- "SHOW DATABASES;" ,
589- QueryContext :: default ( ) ,
590- )
591- . await
592- . expect ( "Failed to execute query in read only mode" ) ;
593- }
0 commit comments