Expand description
Read Delta Lake tables, query them with DataFusion SQL, preview results, and load selected outputs into Microsoft SQL Server with high-throughput native TDS bulk writes, without ODBC or JDBC.
Delta Funnel provides a session-oriented workflow for:
- registering one or more Delta Lake sources;
- building lazy tables from DataFusion SQL;
- executing bounded previews without contacting SQL Server;
- validating output plans with dry runs;
- streaming single or multiple outputs through native TDS bulk writes; and
- collecting structured source, validation, cache, and write reports.
§Quickstart
DeltaFunnelSession owns registered sources and lazy tables. Synchronous
applications can use DeltaFunnelRuntime to run the session’s async query
actions.
use delta_funnel::{
DeltaFunnelRuntime, DeltaFunnelSession, DeltaSourceConfig, LoadMode,
MssqlConnectionConfig, MssqlOutputTarget, MssqlTargetConfig,
MssqlTargetTable, OutputWritePlan, RunMode, SessionOptions,
};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let ado_connection_string = concat!(
"server=tcp:localhost,1433;",
"database=warehouse;",
"User ID=etl_user;",
"Password=REPLACE_ME;",
"encrypt=true;",
"TrustServerCertificate=yes",
);
let default_connection = MssqlConnectionConfig::new(ado_connection_string)?
.with_display_label("warehouse");
let mut session = DeltaFunnelSession::new(
SessionOptions::new().with_default_mssql_connection(default_connection),
)?;
let runtime = DeltaFunnelRuntime::new()?;
// Register the Delta table as "orders" so SQL can reference it.
let _orders = runtime.delta_lake(
&mut session,
DeltaSourceConfig::new("orders", "file:///path/to/orders-delta"),
)?;
// Build a lazy DataFusion SQL query. No rows are read yet.
let daily_orders = runtime.table_from_sql(
&mut session,
r#"
select customer_id, order_date, total_amount
from orders
where order_date >= date '2026-01-01'
"#,
)?;
// Preview executes the DataFusion query with a limit.
let preview = runtime.preview_table(&session, &daily_orders, 20)?;
println!("{}", preview.text());
// Write executes the query and loads the result into SQL Server.
let target = MssqlTargetConfig::new(MssqlTargetTable::new("dbo", "daily_orders")?)
.with_load_mode(LoadMode::CreateAndLoad);
let output = OutputWritePlan::new(
daily_orders,
MssqlOutputTarget::new("daily_orders", target, RunMode::Execute),
);
let report = runtime.write_to_mssql(&session, &output)?;
println!("wrote output {}", report.output_name());
Ok(())
}Previewing executes the DataFusion query with the requested row limit. It does not contact SQL Server or write rows.
§Dry runs and multiple outputs
Build an OutputWritePlan with RunMode::DryRun and pass it to
DeltaFunnelRuntime::dry_run_to_mssql to validate an output plan without
writing rows. DeltaFunnelRuntime::write_all can execute multiple outputs
while caching shared lazy-query dependencies when beneficial.
See the Rust quickstart for a complete write example and the project documentation for installation, SQL Server, and workflow guidance.
Re-exports§
pub use error::DeltaFunnelError;pub use error::SqlTablePhase;
Modules§
- error
- Shared error pattern for DeltaFunnel.
Structs§
- Batch
Handoff Outcome - Successful result for one completed query-output handoff.
- Batch
Handoff Stats - Per-output batch handoff counters.
- Delta
Data Fusion Metrics Snapshot - Stable Delta Funnel view of one DataFusion Delta scan’s metrics.
- Delta
Funnel Runtime - Blocking runtime boundary for high-level Delta Funnel session actions.
- Delta
Funnel Session - Rust backing session for lazy query-load workflows.
- Delta
Protocol Report - Protocol details for one named Delta source.
- Delta
Provider Scheduling Report - Configured provider scheduling options included with a Delta source report.
- Delta
Read Metrics Snapshot - Stable Delta Funnel view of one Delta reader scan’s metrics.
- Delta
Source Config - Caller-provided configuration for one named Delta source.
- Delta
Source Report - Source-level readiness report for one registered Delta source.
- Lazy
Table - Lazy table identity owned by a query-load session.
- Mssql
Batch Shaping Report - Per-output query stream and identity batch-shaping counters.
- Mssql
Connection Config - A SQL Server connection configuration with secret-bearing material hidden from display.
- Mssql
Connection Summary - Redacted SQL Server connection context suitable for reports and errors.
- Mssql
DdlPlan - Planned SQL Server DDL artifacts for one selected output.
- Mssql
DryRun Output Field Report - Output schema field included in an MSSQL dry-run report.
- Mssql
DryRun Output Report - Dry-run planning report for one selected MSSQL output.
- Mssql
DryRun SqlIdentity Report - Redacted SQL identity included in an MSSQL dry-run output report.
- Mssql
DryRun Workflow Report - Dry-run planning report for a multi-output MSSQL workflow.
- Mssql
Lifecycle Plan - Planned SQL Server table lifecycle behavior for one selected output.
- Mssql
Output Batch Validation Report - Redacted report for a successful planned-output schema validation.
- Mssql
Output Field Report - Output schema field included in an MSSQL execute report.
- Mssql
Output Target - MSSQL output target selected from a lazy table.
- Mssql
Output Write Job - One deferred SQL Server output write job.
- Mssql
Prepared Target - Prepared SQL Server target identity and redacted report.
- Mssql
Prepared Target Report - Redacted report for a prepared SQL Server target.
- Mssql
Schema Diagnostic - DeltaFunnel-owned schema planning diagnostic entry.
- Mssql
Schema Diagnostic Field - Field context for a DeltaFunnel-owned schema planning diagnostic entry.
- Mssql
Schema Plan - Planned SQL Server schema mapping for one selected output.
- Mssql
Schema Plan Options - Planning options for Arrow-to-SQL Server conversion.
- Mssql
Table Name - SQL Server table name.
- Mssql
Target Config - Target configuration for writing one selected output to SQL Server.
- Mssql
Target Output Plan - Complete SQL Server target planning artifact for one selected output.
- Mssql
Target Resolution Context - Context defaults available while resolving one selected output target.
- Mssql
Target Summary - Redacted report for one resolved SQL Server target.
- Mssql
Target Table - SQL Server table identity before arrow-sql-server identifier validation.
- Mssql
Workflow Write Options - SQL Server multi-output workflow options.
- Mssql
Workflow Write Report - Structured report for a multi-output SQL Server write workflow.
- Mssql
Write Failure Context - Structured context for a one-output SQL Server write failure.
- Mssql
Write Failure Report - Structured report for the first failed SQL Server output.
- Mssql
Write Report - Redacted per-output SQL Server write report.
- Mssql
Write Skipped Report - Structured report for a skipped SQL Server output.
- Mssql
Write Stats - Per-output SQL Server write statistics.
- Output
Write Plan - Planned output write request before schema planning or execution.
- Phase
Timing Report - Timing evidence for one stable workflow phase.
- Planned
Mssql Output - Planned MSSQL output request for one selected lazy table.
- Preview
Failure Context - Structured diagnostics retained when a bounded preview fails.
- Preview
Options - Options for a bounded lazy-table preview.
- Query
Execution Metric - One redacted metric attached to a query execution operator.
- Query
Execution Operator Profile - Immutable profile for one unique physical execution-plan node.
- Query
Execution Profile - Immutable execution profile for one Delta Funnel query scope.
- Query
Options - Query execution options applied before DataFusion planning and execution.
- Registered
Delta Source - One registered Delta source.
- Registered
Delta Sources - Registered Delta sources visible to a DataFusion session.
- Registered
Derived Table - Registered SQL-derived table alias tracked by a query-load session.
- Registered
Session Source - Registered Delta source tracked by a query-load session.
- Resolved
Mssql Target - Resolved SQL Server target for one selected output.
- Session
Options - Session-wide options for lazy query-load orchestration.
- Table
Preview - Rendered bounded preview of a lazy table.
- Validation
Options - Validation and scan-summary options checked before workflow side effects.
- Write
AllCache Alias Report - Selected registered derived alias cache metadata.
- Write
AllCache Candidate Skip - Registered derived alias skipped during cache selection.
- Write
AllCache Failure - Structured details retained when a cache-enabled
write_allcall fails. - Write
AllOptions - Execution options for one multi-output
write_allcall. - Write
AllReport - Report for one
write_allcall that reached the sequential workflow.
Enums§
- Batch
Handoff Error - Terminal failure from a query-output handoff.
- Batch
Pipeline Phase - Phase for batch pipeline setup and configuration failures.
- DryRun
Scan Summary Mode - Controls how much source scan metadata a dry-run report should collect.
- Execution
Profile Mode - Controls whether a query execution profile is collected.
- File
Count - File count evidence for a report field.
- File
Count Kind - Classification for a reported file count.
- Lazy
Table Kind - Kind of lazy table represented by a session handle.
- Load
Mode - SQL Server table lifecycle mode requested for one selected output.
- Mssql
Binary Policy - Binary conversion policy.
- Mssql
Connection Source - Where an effective SQL Server connection came from.
- Mssql
Date64 Policy - Date64 conversion policy.
- Mssql
Decimal256 Policy - Decimal256 conversion policy.
- Mssql
Decimal Policy - Decimal conversion policy.
- Mssql
DryRun SqlIdentity State - SQL identity state included in an MSSQL dry-run output report.
- Mssql
Float Policy - Floating-point conversion policy.
- Mssql
Lifecycle Execution Guardrail - An execution operation guarded by successful lifecycle planning.
- Mssql
Lifecycle Guardrail Policy - Whether guarded execution may proceed after lifecycle planning.
- Mssql
Nanosecond Policy - Nanosecond timestamp precision policy.
- Mssql
Output Write Status - Final write status for one selected SQL Server output.
- Mssql
Prepared Target Action - Side effect completed while preparing a SQL Server target for loading.
- Mssql
String Policy - String conversion policy.
- Mssql
Target Cleanup Status - Cleanup reporting state for a SQL Server target owned by create-and-load.
- Mssql
Target Table State - Expected live state of the target table before loading starts.
- Mssql
Timestamp Policy - Timezone-free timestamp target policy.
- Mssql
Timezone Policy - Timezone-aware timestamp conversion policy.
- MssqlU
Int64 Policy - Unsigned 64-bit integer conversion policy.
- Mssql
Write Backend - SQL Server write backend selection.
- Mssql
Write Phase - Phase of one-output SQL Server write execution.
- Mssql
Write Skipped Reason - Reason one selected SQL Server output was skipped.
- Output
Status - Output-level workflow status.
- Output
Status Kind - Classification for an output-level workflow status.
- Phase
Status - Status for a workflow phase such as planning, loading, writing, or validation.
- Phase
Status Kind - Classification for a workflow phase status.
- Query
Execution Metric Category - Stability category assigned to a DataFusion execution metric.
- Query
Execution Metric Value - Typed value captured for one DataFusion execution metric.
- Query
Execution Outcome - Describes how query execution reached its terminal state.
- Query
Execution Scope - Identifies why Delta Funnel executed a query plan.
- Report
Reason Code - Stable reason codes for skipped, unavailable, and not-executed report states.
- RowCount
- Row count evidence for a report field.
- RowCount
Kind - Classification for a reported row count.
- RunMode
- Query-load action mode requested by a caller.
- Source
Usage Status - Conservative source usage status for a workflow report.
- Target
Validation Mode - Controls whether target-side validation should run when a workflow supports it.
- Validation
Status - Target-side validation status for a report scope.
- Validation
Status Kind - Classification for target-side validation status.
- Workflow
Status - Workflow-level status for a report.
- Workflow
Status Kind - Classification for a workflow-level status.
- Write
AllCache Alias Status - Cache lifecycle status for one selected alias in a
write_allreport. - Write
AllCache Candidate Skip Reason - Reason a cache candidate was skipped during
write_allcache planning. - Write
AllCache Mode - Cache policy for one multi-output
write_allcall. - Write
AllCache Report - Cache metadata for one
write_allcall. - Write
AllNo Cache Reason - Conservative reason no cache alias was selected for
write_all.
Constants§
- VERSION
- Current crate version.
Traits§
- Record
Batch Consumer - Downstream consumer for one query-output
RecordBatch.
Functions§
- connect_
mssql_ client_ from_ ado_ string - Connects to SQL Server from an ADO-style connection string.
- datafusion_
query_ output_ stream - Executes one selected DataFusion query output as a single merged stream.
- datafusion_
session_ config - Builds a DataFusion session config from DeltaFunnel query options.
- datafusion_
session_ context - Builds a DataFusion session context from DeltaFunnel query options.
- default_
mssql_ write_ backend - Returns Delta Funnel’s default SQL Server write backend.
- duration_
to_ micros_ saturating - Saturates a
Durationinto the public microsecond timing report shape. - handoff_
datafusion_ query_ output - Executes one selected DataFusion query output and hands it to a consumer.
- handoff_
record_ batch_ stream - Hands one DataFusion
RecordBatchstream to one downstream consumer. - mssql_
schema_ diagnostic_ reports - Converts arrow-sql-server diagnostics into DeltaFunnel-owned report entries.
- mssql_
write_ backend_ for_ output_ plan - Builds a write backend from a planned SQL Server output target.
- plan_
mssql_ create_ table_ ddl - Plans optional create-table DDL for one selected output schema plan.
- plan_
mssql_ lifecycle - Plans lifecycle behavior for one selected output.
- plan_
mssql_ output_ schema - Plans one selected output Arrow schema for the resolved SQL Server target.
- plan_
mssql_ target_ for_ output - Plans one selected output schema for SQL Server writing.
- plan_
mssql_ target_ for_ resolved_ output - Plans one selected output schema for an already resolved SQL Server target.
- plan_
mssql_ target_ output - Builds a complete target output plan from an existing schema plan.
- register_
delta_ sources - Registers loaded Delta sources into a DataFusion session.
- register_
delta_ sources_ with_ scan_ execution_ options - Registers loaded Delta sources with explicit reader execution bounds.
- sanitize_
uri_ for_ display - Sanitizes a URI for display in logs, errors, and reports.
- u128_
to_ u64_ saturating - Saturates a wide count into the public
u64report shape. - usize_
to_ u64_ saturating - Saturates a platform-sized count into the public
u64report shape. - validate_
mssql_ output_ record_ batch - Validates a runtime
RecordBatchschema against a planned SQL Server output. - validate_
mssql_ output_ schema - Validates a runtime Arrow schema against a planned SQL Server output.
- version
- Returns the current crate version.
- write_
mssql_ outputs_ to_ mssql - Writes multiple SQL Server outputs sequentially.
- write_
output_ batches_ to_ mssql - Writes one resolved output to SQL Server from an Arrow record batch stream.
Type Aliases§
- Mssql
Output Batch Stream - Lazy stream produced only when a SQL Server output is attempted.
- Mssql
Output Batch Stream Factory - Async factory that constructs a direct batch stream for one attempted output.