Expand description
High-performance Apache Arrow RecordBatch bulk writes for Microsoft SQL Server.
Arrow SQL Server plans Arrow schemas, generates SQL Server DDL, validates
target tables, and streams RecordBatch values through a SQL Server bulk
writer. The production path uses TDS directly and does not require an ODBC
driver.
§Start With a Schema
Plan an Arrow schema and render matching CREATE TABLE SQL:
use arrow_schema::{DataType, Field, Schema};
use arrow_sql_server::{
CompatibilityLevel, MssqlProfile, MssqlVersion, PlanOptions, TableName,
create_table_sql_from_mappings,
};
let schema = Schema::new(vec![
Field::new("id", DataType::Int64, false),
Field::new("name", DataType::Utf8, true),
]);
let profile = MssqlProfile::new(
MssqlVersion::SqlServer2022,
CompatibilityLevel::SQL_SERVER_2022,
)?;
let planned = profile
.plan_arrow_schema(&schema, PlanOptions::default())?
.into_value();
let table = TableName::new("dbo", "people")?;
let ddl = create_table_sql_from_mappings(&table, &planned);
assert!(ddl.contains("CREATE TABLE [dbo].[people]"));Follow the Getting Started tutorial for a complete connection, table creation, write, and row-count verification flow.
§Core API
MssqlProfileandPlanOptionsplan Arrow fields for a specific SQL Server version and compatibility level.create_table_sql_from_mappingsrenders deterministic SQL Server DDL.connect_mssql_client_from_ado_stringcreates a compatible asynchronous SQL Server connection.ConnectedMssqlClient::bulk_writercreates a writer for an existing target table.WriteOptions::defaultselectsWriteBackend::Auto, which currently resolves to the optimized direct raw TDS backend.Error::safe_error_infoexposes sanitized, structured failure details for user-facing reports.
§Current Scope
This crate owns reusable Arrow-to-SQL Server planning and writing. It does not provide SQL Server-to-Arrow reads, connection pooling, retries, job orchestration, migrations, or multi-table publishing workflows.
BulkWriter validates target metadata before writing. It does not create
or replace tables automatically.
§Connection Compatibility
Prefer connect_mssql_client_from_ado_string and
ConnectedMssqlClient in downstream applications. They hide the exact
tiberius-raw-bulk client and transport types that the writer requires.
§Guides and Reference
Re-exports§
pub use arrow::ArrowFieldRef;pub use connection::ConnectedBulkWriter;pub use connection::ConnectedMssqlClient;pub use connection::SqlExecutionOutcome;pub use connection::connect_mssql_client_from_ado_string;pub use diagnostic::Diagnostic;pub use diagnostic::DiagnosticCode;pub use diagnostic::DiagnosticSet;pub use diagnostic::DiagnosticSeverity;pub use diagnostic::FieldRef;pub use diagnostic::PlanOutcome;pub use error::Error;pub use error::ErrorInfo;pub use error::Result;pub use mssql::CompatibilityLevel;pub use mssql::CreateTableOptions;pub use mssql::Identifier;pub use mssql::IdentifierPolicy;pub use mssql::MssqlColumn;pub use mssql::MssqlProfile;pub use mssql::MssqlTimePrecision;pub use mssql::MssqlType;pub use mssql::MssqlTypeLength;pub use mssql::MssqlVersion;pub use mssql::TableName;pub use mssql::create_table_sql;pub use schema::PlannedSchema;pub use schema::SchemaMapping;pub use schema::create_table_sql_from_mappings;pub use schema::mssql_columns_from_mappings;pub use schema::plan_arrow_schema_to_mssql_schema;pub use write::BinaryPolicy;pub use write::BulkWriter;pub use write::Date64Policy;pub use write::Decimal256Policy;pub use write::DecimalPolicy;pub use write::FloatPolicy;pub use write::NanosecondPolicy;pub use write::PlanOptions;pub use write::SchemaCheck;pub use write::StringPolicy;pub use write::TimestampPolicy;pub use write::TimezonePolicy;pub use write::UInt64Policy;pub use write::WriteBackend;pub use write::WriteOptions;pub use write::WritePhase;pub use write::WriteStats;pub use write::validate_arrow_schema_against_mappings;pub use write::validate_record_batch_schema_against_mappings;
Modules§
- arrow
- Arrow-side schema metadata. Arrow-side schema metadata.
- connection
- SQL Server connection helpers. SQL Server connection helpers.
- diagnostic
- Structured diagnostics for planning and writing. Structured diagnostics for planning and writing.
- error
- Error types for Arrow SQL Server. Error types for Arrow SQL Server.
- mssql
- MSSQL-side schema metadata, identifiers, profiles, types, and DDL helpers. MSSQL-side schema metadata, identifiers, profile, and DDL helpers.
- schema
- Bidirectional Arrow/MSSQL schema mapping. Bidirectional Arrow/MSSQL schema mapping.
- write
- Write-path options and conversion policies. Write-path options and policies.