delta_funnel/orchestrator/
session.rs1mod dry_run_report;
8mod errors;
9mod handles;
10mod options;
11mod query_handoff;
12mod registry;
13mod source_report;
14mod sql_server_workflows;
15#[cfg(test)]
16mod test_support;
17
18use std::fmt;
19
20use datafusion::prelude::SessionContext;
21
22use crate::{DeltaFunnelError, datafusion_session_context};
23
24pub use crate::report::delta::SourceUsageStatus;
25pub use handles::{
26 LazyTable, LazyTableKind, MssqlOutputTarget, OutputWritePlan, PlannedMssqlOutput, RunMode,
27};
28pub use options::SessionOptions;
29pub use registry::{RegisteredDerivedTable, RegisteredSessionSource};
30pub use sql_server_workflows::{WriteAllCacheMode, WriteAllOptions};
31
32pub use crate::report::sql_server::MssqlDryRunOutputReport;
33use registry::PendingDerivedTable;
34#[cfg(test)]
35pub(crate) use sql_server_workflows::OrchestratorMssqlOutputWriter;
36
37pub struct DeltaFunnelSession {
39 options: SessionOptions,
40 context: SessionContext,
41 next_table_id: u64,
42 sources: Vec<RegisteredSessionSource>,
43 derived_tables: Vec<RegisteredDerivedTable>,
44 pending_derived_tables: Vec<PendingDerivedTable>,
45}
46
47impl DeltaFunnelSession {
48 pub fn new(options: SessionOptions) -> Result<Self, DeltaFunnelError> {
55 options.validate()?;
56 let context = datafusion_session_context(options.query_options())?;
57 Ok(Self {
58 options,
59 context,
60 next_table_id: 0,
61 sources: Vec::new(),
62 derived_tables: Vec::new(),
63 pending_derived_tables: Vec::new(),
64 })
65 }
66
67 #[must_use]
69 pub const fn options(&self) -> &SessionOptions {
70 &self.options
71 }
72
73 #[must_use]
80 pub const fn context(&self) -> &SessionContext {
81 &self.context
82 }
83
84 #[must_use]
86 pub const fn next_table_id(&self) -> u64 {
87 self.next_table_id
88 }
89}
90
91impl fmt::Debug for DeltaFunnelSession {
92 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
93 formatter
94 .debug_struct("DeltaFunnelSession")
95 .field("options", &self.options)
96 .field("sources", &self.sources)
97 .field("derived_tables", &self.derived_tables)
98 .field("next_table_id", &self.next_table_id)
99 .finish_non_exhaustive()
100 }
101}