use std::sync::Arc;
use crate::adapters::session::types::{CallerConnection, CallerSession};
use crate::column_types::models::Warehouse;
#[derive(Debug, Clone)]
pub struct SessionConnection {
pub warehouse: Warehouse,
pub motherduck: bool,
pub database: Option<String>,
pub caller: Arc<dyn CallerConnection>,
}
impl SessionConnection {
pub fn kind(&self) -> &'static str {
match (self.warehouse, self.motherduck) {
(Warehouse::DuckDb, true) => "motherduck",
(Warehouse::DuckDb, false) => "duckdb",
(Warehouse::Snowflake, _) => "snowflake",
(Warehouse::Databricks, _) => "databricks",
(Warehouse::BigQuery, _) => "bigquery",
(Warehouse::Postgres, _) => "postgres",
(Warehouse::ClickHouse, _) => "clickhouse",
(Warehouse::Parquet, _) => "filesystem",
}
}
}
#[derive(Debug, Clone)]
pub struct SessionDestination {
pub connection: SessionConnection,
pub database: Option<String>,
pub session: Arc<tokio::sync::OnceCell<Arc<dyn CallerSession>>>,
pub ddl: Arc<tokio::sync::Mutex<()>>,
}
#[derive(Debug)]
pub struct SessionWriter {
pub destination: SessionDestination,
pub staged: Vec<String>,
pub written: u64,
pub folder: tempfile::TempDir,
}