use crate::adapters::motherduck_bridge::models::BridgeConnection;
use crate::memory_budget::models::{MemoryGuard, WatchedChild};
use crate::postgres_source::models::{ReadColumn, SourceTable};
use crate::project::models::ConnectionConfig;
#[derive(Debug, Clone)]
pub struct DuckDbReader {
pub(crate) database: String,
pub(crate) memory_limit: Option<u64>,
pub(crate) motherduck: Option<ConnectionConfig>,
pub(crate) bridge: std::sync::Arc<tokio::sync::OnceCell<SourceBridge>>,
pub(crate) guard: Option<std::sync::Arc<MemoryGuard>>,
}
#[derive(Debug)]
pub(crate) struct SourceBridge {
pub(crate) connection: BridgeConnection,
pub(crate) _watched: Option<WatchedChild>,
}
#[derive(Debug, Clone, Copy)]
pub struct DuckDbReadRequest<'a> {
pub table: &'a SourceTable,
pub sql: Option<&'a str>,
pub columns: &'a [ReadColumn],
pub filter: Option<&'a str>,
}
#[derive(Debug)]
pub(crate) struct ReadOnlyFile {
pub(crate) connection: duckdb::Connection,
pub(crate) _hold: FileHold,
}
#[derive(Debug)]
pub(crate) struct FileHold {
pub(crate) path: std::path::PathBuf,
}
#[derive(Debug)]
pub(crate) struct OpenFile {
pub(crate) reads: usize,
pub(crate) read_limit: Option<u64>,
pub(crate) connection: duckdb::Connection,
pub(crate) _spill: tempfile::TempDir,
}