Skip to content

Commit

Permalink
Merge pull request #474 from splitgraph/refactor-context
Browse files Browse the repository at this point in the history
chore: Refactor Seafowl context
  • Loading branch information
gruuya authored Nov 29, 2023
2 parents 404c480 + e40c47f commit 40b1158
Show file tree
Hide file tree
Showing 14 changed files with 2,627 additions and 2,688 deletions.
6 changes: 3 additions & 3 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod commands;
mod helper;

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

pub struct SeafowlCli {
ctx: Arc<DefaultSeafowlContext>,
ctx: Arc<SeafowlContext>,
}

impl SeafowlCli {
// Instantiate new CLI instance
pub fn new(ctx: Arc<DefaultSeafowlContext>) -> Self {
pub fn new(ctx: Arc<SeafowlContext>) -> Self {
SeafowlCli { ctx }
}

Expand Down
7 changes: 3 additions & 4 deletions src/config/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{
catalog::{
DefaultCatalog, FunctionCatalog, TableCatalog, DEFAULT_DB, DEFAULT_SCHEMA,
},
context::DefaultSeafowlContext,
context::SeafowlContext,
repository::{interface::Repository, sqlite::SqliteRepository},
};
use datafusion::execution::context::SessionState;
Expand Down Expand Up @@ -151,7 +151,7 @@ pub fn build_state_with_table_factories(
state
}

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

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

#[cfg(test)]
mod tests {
use crate::context::SeafowlContext;
use sqlx::sqlite::SqliteJournalMode;

use super::*;
Expand Down
Loading

0 comments on commit 40b1158

Please sign in to comment.