Skip to main content

hdbconnect_arrow/
lib.rs

1//! Apache Arrow integration for hdbconnect SAP HANA driver.
2//!
3//! This crate provides zero-copy conversion from HANA `ResultSets` to Apache Arrow
4//! `RecordBatches`, enabling efficient data transfer to Python via `PyO3`.
5//!
6//! # Features
7//!
8//! - Type-safe HANA to Arrow type mapping
9//! - Streaming `RecordBatch` iteration for large result sets
10//! - Sealed traits for API stability
11//! - Generic Associated Types (GATs) for lending iterators
12//!
13//! # Example
14//!
15//! ```rust,ignore
16//! use hdbconnect_arrow::{Result, BatchConfig, HanaBatchProcessor};
17//!
18//! // Configure batch processing
19//! let config = BatchConfig::default();
20//! let schema = /* Arrow schema */;
21//! let mut processor = HanaBatchProcessor::new(schema, config);
22//!
23//! // Process rows
24//! for row in result_set {
25//!     if let Some(batch) = processor.process_row(&row)? {
26//!         // Handle batch
27//!     }
28//! }
29//!
30//! // Flush remaining rows
31//! if let Some(batch) = processor.flush()? {
32//!     // Handle final batch
33//! }
34//! ```
35#![warn(missing_docs)]
36#![warn(clippy::all)]
37#![warn(clippy::pedantic)]
38
39// Profiling support: dhat heap allocator (enabled via `--features profiling`)
40#[cfg(feature = "profiling")]
41#[global_allocator]
42static ALLOC: dhat::Alloc = dhat::Alloc;
43
44pub mod builders;
45pub mod conversion;
46pub mod error;
47#[cfg(feature = "profiling")]
48pub mod profiling;
49pub mod schema;
50#[cfg(test)]
51pub mod test_utils;
52pub mod traits;
53pub mod types;
54
55// Re-export main types for convenience
56pub use builders::factory::BuilderFactory;
57pub use conversion::{HanaBatchProcessor, rows_to_record_batch};
58pub use error::{ArrowConversionError, Result};
59pub use schema::mapping::SchemaMapper;
60pub use traits::builder::HanaCompatibleBuilder;
61pub use traits::row::RowLike;
62#[cfg(any(test, feature = "test-utils"))]
63pub use traits::row::{MockRow, MockRowBuilder};
64pub use traits::sealed::FromHanaValue;
65pub use traits::streaming::{BatchConfig, BatchProcessor, LendingBatchIterator};
66#[cfg(feature = "async")]
67pub use types::arrow::FieldMetadataExtAsync;
68pub use types::arrow::{FieldMetadataExt, hana_field_to_arrow, hana_type_to_arrow};
69pub use types::conversion::TypeCategory;
70pub use types::hana::{
71    Binary, Decimal, DecimalPrecision, DecimalScale, HanaTypeCategory, Lob, Numeric, Spatial,
72    StringType, Temporal, TypedColumn,
73};