mod dry_run_report;
mod errors;
mod handles;
mod options;
mod query_handoff;
mod registry;
mod source_report;
mod sql_server_workflows;
#[cfg(test)]
mod test_support;
use std::fmt;
use datafusion::prelude::SessionContext;
use crate::{DeltaFunnelError, datafusion_session_context};
pub use crate::report::delta::SourceUsageStatus;
pub use handles::{
LazyTable, LazyTableKind, MssqlOutputTarget, OutputWritePlan, PlannedMssqlOutput, RunMode,
};
pub use options::SessionOptions;
pub use registry::{RegisteredDerivedTable, RegisteredSessionSource};
pub use sql_server_workflows::{WriteAllCacheMode, WriteAllOptions};
pub use crate::report::sql_server::MssqlDryRunOutputReport;
use registry::PendingDerivedTable;
#[cfg(test)]
pub(crate) use sql_server_workflows::OrchestratorMssqlOutputWriter;
pub struct DeltaFunnelSession {
options: SessionOptions,
context: SessionContext,
next_table_id: u64,
sources: Vec<RegisteredSessionSource>,
derived_tables: Vec<RegisteredDerivedTable>,
pending_derived_tables: Vec<PendingDerivedTable>,
}
impl DeltaFunnelSession {
pub fn new(options: SessionOptions) -> Result<Self, DeltaFunnelError> {
options.validate()?;
let context = datafusion_session_context(options.query_options())?;
Ok(Self {
options,
context,
next_table_id: 0,
sources: Vec::new(),
derived_tables: Vec::new(),
pending_derived_tables: Vec::new(),
})
}
#[must_use]
pub const fn options(&self) -> &SessionOptions {
&self.options
}
#[must_use]
pub const fn context(&self) -> &SessionContext {
&self.context
}
#[must_use]
pub const fn next_table_id(&self) -> u64 {
self.next_table_id
}
}
impl fmt::Debug for DeltaFunnelSession {
fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
formatter
.debug_struct("DeltaFunnelSession")
.field("options", &self.options)
.field("sources", &self.sources)
.field("derived_tables", &self.derived_tables)
.field("next_table_id", &self.next_table_id)
.finish_non_exhaustive()
}
}