Skip to content

Commit 40b1158

Browse files
authored
Merge pull request #474 from splitgraph/refactor-context
chore: Refactor Seafowl context
2 parents 404c480 + e40c47f commit 40b1158

14 files changed

Lines changed: 2627 additions & 2688 deletions

File tree

src/cli/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod commands;
22
mod helper;
33

44
use crate::cli::commands::all_commands_info;
5-
use crate::context::{DefaultSeafowlContext, SeafowlContext};
5+
use crate::context::SeafowlContext;
66
use arrow::util::pretty::pretty_format_batches_with_options;
77
use commands::Command;
88
use datafusion_common::Result;
@@ -14,12 +14,12 @@ use std::time::Instant;
1414
const SEAFOWL_CLI_HISTORY: &str = ".history";
1515

1616
pub struct SeafowlCli {
17-
ctx: Arc<DefaultSeafowlContext>,
17+
ctx: Arc<SeafowlContext>,
1818
}
1919

2020
impl SeafowlCli {
2121
// Instantiate new CLI instance
22-
pub fn new(ctx: Arc<DefaultSeafowlContext>) -> Self {
22+
pub fn new(ctx: Arc<SeafowlContext>) -> Self {
2323
SeafowlCli { ctx }
2424
}
2525

src/config/context.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
catalog::{
55
DefaultCatalog, FunctionCatalog, TableCatalog, DEFAULT_DB, DEFAULT_SCHEMA,
66
},
7-
context::DefaultSeafowlContext,
7+
context::SeafowlContext,
88
repository::{interface::Repository, sqlite::SqliteRepository},
99
};
1010
use datafusion::execution::context::SessionState;
@@ -151,7 +151,7 @@ pub fn build_state_with_table_factories(
151151
state
152152
}
153153

154-
pub async fn build_context(cfg: &schema::SeafowlConfig) -> Result<DefaultSeafowlContext> {
154+
pub async fn build_context(cfg: &schema::SeafowlConfig) -> Result<SeafowlContext> {
155155
let mut runtime_config = RuntimeConfig::new();
156156
if let Some(max_memory) = cfg.runtime.max_memory {
157157
runtime_config = runtime_config
@@ -203,7 +203,7 @@ pub async fn build_context(cfg: &schema::SeafowlConfig) -> Result<DefaultSeafowl
203203
// the user is connected to), but in this case we can just use the same context everywhere
204204
// (it will reload its schema before running the query)
205205

206-
Ok(DefaultSeafowlContext {
206+
Ok(SeafowlContext {
207207
inner: context,
208208
table_catalog: tables,
209209
function_catalog: functions,
@@ -217,7 +217,6 @@ pub async fn build_context(cfg: &schema::SeafowlConfig) -> Result<DefaultSeafowl
217217

218218
#[cfg(test)]
219219
mod tests {
220-
use crate::context::SeafowlContext;
221220
use sqlx::sqlite::SqliteJournalMode;
222221

223222
use super::*;

0 commit comments

Comments
 (0)