Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions crates/embucket-lambda/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ pub struct EnvConfig {
pub embucket_version: String,
pub metastore_config: Option<PathBuf>,
pub jwt_secret: Option<String>,
pub read_only: bool,
pub max_concurrent_table_fetches: usize,
}

Expand All @@ -37,7 +36,6 @@ impl EnvConfig {
embucket_version: env_or_default("EMBUCKET_VERSION", "0.1.0"),
metastore_config: env::var("METASTORE_CONFIG").ok().map(PathBuf::from),
jwt_secret: env::var("JWT_SECRET").ok(),
read_only: parse_env("READ_ONLY").unwrap_or(true),
max_concurrent_table_fetches: parse_env("MAX_CONCURRENT_TABLE_FETCHES").unwrap_or(5),
}
}
Expand All @@ -53,7 +51,6 @@ impl EnvConfig {
mem_pool_size_mb: self.mem_pool_size_mb,
mem_enable_track_consumers_pool: self.mem_enable_track_consumers_pool,
disk_pool_size_mb: self.disk_pool_size_mb,
read_only: self.read_only,
max_concurrent_table_fetches: self.max_concurrent_table_fetches,
}
}
Expand All @@ -63,12 +60,6 @@ fn env_or_default(name: &str, default: &str) -> String {
env::var(name).unwrap_or_else(|_| default.to_string())
}

fn env_bool(name: &str) -> bool {
env::var(name)
.map(|value| matches!(value.to_lowercase().as_str(), "1" | "true" | "yes" | "on"))
.unwrap_or(false)
}

fn parse_mem_pool_type() -> Option<MemPoolType> {
env::var("MEM_POOL_TYPE")
.ok()
Expand Down
1 change: 0 additions & 1 deletion crates/embucket-lambda/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ async fn main() -> Result<(), LambdaError> {
mem_pool_type = ?env_config.mem_pool_type,
mem_pool_size_mb = ?env_config.mem_pool_size_mb,
disk_pool_size_mb = ?env_config.disk_pool_size_mb,
read_only = env_config.read_only,
metastore_config = env_config.metastore_config.as_ref().map(|p| p.display().to_string()),
"Loaded Lambda configuration"
);
Expand Down
8 changes: 0 additions & 8 deletions crates/embucketd/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,6 @@ pub struct CliOpts {
)]
jwt_secret: Option<String>,

#[arg(
long,
env = "READ_ONLY",
default_value = "true",
help = "If the service should only accept read only commands (selects)"
)]
pub read_only: bool,

#[arg(
long,
env = "MAX_CONCURRENT_TABLE_FETCHES",
Expand Down
1 change: 0 additions & 1 deletion crates/embucketd/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ async fn async_main(
mem_pool_size_mb: opts.mem_pool_size_mb,
mem_enable_track_consumers_pool: opts.mem_enable_track_consumers_pool,
disk_pool_size_mb: opts.disk_pool_size_mb,
read_only: opts.read_only,
max_concurrent_table_fetches: opts.max_concurrent_table_fetches,
};
let host = opts.host.clone().unwrap();
Expand Down
7 changes: 0 additions & 7 deletions crates/executor/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,13 +632,6 @@ pub enum Error {
#[snafu(implicit)]
location: Location,
},

#[snafu(display("Statement not supported in read_only mode: {statement}"))]
NotSupportedStatementInReadOnlyMode {
statement: String,
#[snafu(implicit)]
location: Location,
},
}

impl Error {
Expand Down
63 changes: 0 additions & 63 deletions crates/executor/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,69 +266,6 @@ impl UserQuery {
// 3. Single place to construct Logical plan from this AST
// 4. Single place to rewrite-optimize-adjust logical plan
// etc
if self.session.config.read_only {
match statement {
DFStatement::Statement(s) => match *s {
Statement::Query(subquery) => {
return self.execute_query_statement(subquery).await;
}
Statement::Use(entity) => {
return self.execute_use_statement(entity).await;
}
Statement::ShowDatabases { .. }
| Statement::ShowSchemas { .. }
| Statement::ShowTables { .. }
| Statement::ShowColumns { .. }
| Statement::ShowViews { .. }
| Statement::ShowFunctions { .. }
| Statement::ShowObjects { .. }
| Statement::ShowVariables { .. }
| Statement::ShowVariable { .. } => return Box::pin(self.show_query(*s)).await,
other => {
return ex_error::NotSupportedStatementInReadOnlyModeSnafu {
statement: other.to_string(),
}
.fail();
}
},
DFStatement::Explain(explain) => match *explain.statement {
DFStatement::Statement(s) => match *s {
Statement::Query(..)
| Statement::Use(..)
| Statement::ShowDatabases { .. }
| Statement::ShowSchemas { .. }
| Statement::ShowTables { .. }
| Statement::ShowColumns { .. }
| Statement::ShowViews { .. }
| Statement::ShowFunctions { .. }
| Statement::ShowObjects { .. }
| Statement::ShowVariables { .. }
| Statement::ShowVariable { .. } => {
return self.execute_sql(&self.query).await;
}
other => {
return ex_error::NotSupportedStatementInReadOnlyModeSnafu {
statement: other.to_string(),
}
.fail();
}
},
other => {
return ex_error::NotSupportedStatementInReadOnlyModeSnafu {
statement: other.to_string(),
}
.fail();
}
},
other => {
return ex_error::NotSupportedStatementInReadOnlyModeSnafu {
statement: other.to_string(),
}
.fail();
}
}
}

if let DFStatement::Statement(s) = statement {
match *s {
Statement::AlterSession {
Expand Down
157 changes: 0 additions & 157 deletions crates/executor/src/tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::models::{QueryContext, QueryResult};
use crate::service::{CoreExecutionService, ExecutionService};
use crate::utils::Config;
use catalog_metastore::InMemoryMetastore;
use catalog_metastore::metastore_config::MetastoreBootstrapConfig;
use catalog_metastore::models::table::TableIdent as MetastoreTableIdent;
use catalog_metastore::{
Database as MetastoreDatabase, Schema as MetastoreSchema, SchemaIdent as MetastoreSchemaIdent,
Expand Down Expand Up @@ -435,159 +434,3 @@ async fn test_query_timeout() {
"Expected query execution exceeded timeout error but got {res:?}"
);
}

#[tokio::test]
#[allow(clippy::expect_used)]
async fn test_execute_read_only_mode() {
//setup
let metastore = Arc::new(InMemoryMetastore::new());
let metastore_config = MetastoreBootstrapConfig::bootstrap();
metastore_config
.apply(metastore.clone())
.await
.expect("Failed to apply config");

let execution_svc = CoreExecutionService::new(metastore.clone(), Arc::new(Config::default()))
.await
.expect("Failed to create execution service");

execution_svc
.create_session("test_session_id")
.await
.expect("Failed to create session");

execution_svc
.query(
"test_session_id",
"CREATE OR REPLACE TABLE fetch_test(c1 INT)",
QueryContext::default(),
)
.await
.expect("Failed to execute query");

execution_svc
.query(
"test_session_id",
"INSERT INTO fetch_test VALUES (1),(2),(3),(4)",
QueryContext::default(),
)
.await
.expect("Failed to execute query");

drop(execution_svc);

//read only mode test
let execution_svc =
CoreExecutionService::new(metastore, Arc::new(Config::default().with_read_only(true)))
.await
.expect("Failed to create execution service");

execution_svc
.create_session("test_session_id")
.await
.expect("Failed to create session");

//should fail
execution_svc
.query(
"test_session_id",
"CREATE OR REPLACE TABLE fetch_test(c1 INT)",
QueryContext::default(),
)
.await
.expect_err("Read only mode failed");

//should fail
execution_svc
.query(
"test_session_id",
"INSERT INTO fetch_test VALUES (1),(2),(3),(4)",
QueryContext::default(),
)
.await
.expect_err("Read only mode failed");

execution_svc
.query("test_session_id", "SELECT 1", QueryContext::default())
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query(
"test_session_id",
"EXPLAIN SELECT 1",
QueryContext::default(),
)
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query(
"test_session_id",
"WITH limited_data AS (
SELECT c1 FROM fetch_test ORDER BY c1 FETCH FIRST 3 ROWS
)
SELECT * FROM limited_data ORDER BY c1;",
QueryContext::default(),
)
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query(
"test_session_id",
"EXPLAIN WITH limited_data AS (
SELECT c1 FROM fetch_test ORDER BY c1 FETCH FIRST 3 ROWS
)
SELECT * FROM limited_data ORDER BY c1;",
QueryContext::default(),
)
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query(
"test_session_id",
"SELECT 1 UNION ALL SELECT c1 FROM fetch_test;",
QueryContext::default(),
)
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query(
"test_session_id",
"EXPLAIN SELECT 1 UNION ALL SELECT c1 FROM fetch_test;",
QueryContext::default(),
)
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query(
"test_session_id",
"USE SCHEMA public;",
QueryContext::default(),
)
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query("test_session_id", "SHOW TABLES;", QueryContext::default())
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query("test_session_id", "SHOW SCHEMAS;", QueryContext::default())
.await
.expect("Failed to execute query in read only mode");

execution_svc
.query(
"test_session_id",
"SHOW DATABASES;",
QueryContext::default(),
)
.await
.expect("Failed to execute query in read only mode");
}
8 changes: 0 additions & 8 deletions crates/executor/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ pub struct Config {
pub mem_pool_size_mb: Option<usize>,
pub mem_enable_track_consumers_pool: Option<bool>,
pub disk_pool_size_mb: Option<usize>,
pub read_only: bool,
pub max_concurrent_table_fetches: usize,
}

Expand All @@ -62,7 +61,6 @@ impl Default for Config {
mem_pool_size_mb: None,
mem_enable_track_consumers_pool: None,
disk_pool_size_mb: None,
read_only: false,
max_concurrent_table_fetches: 5,
}
}
Expand All @@ -80,12 +78,6 @@ impl Config {
self.query_timeout_secs = timeout_secs;
self
}

#[must_use]
pub const fn with_read_only(mut self, read_only: bool) -> Self {
self.read_only = read_only;
self
}
}

#[derive(Copy, Clone, PartialEq, Eq, EnumString, Debug, Display, Default)]
Expand Down