//! DataFusion SQL Query Engine Integration
//!
//! This module integrates Apache DataFusion as the unified SQL query engine
//! for AiFastDb. It leverages Arrow zero-copy interop with the Lance
//! columnar storage backend to provide full SQL capabilities:
//!
//! - **Standard SQL**: SELECT / WHERE / GROUP BY / ORDER BY / LIMIT / OFFSET
//! - **Aggregations**: COUNT, SUM, AVG, MIN, MAX
//! - **Joins**: INNER / LEFT / RIGHT / FULL OUTER / CROSS
//! - **Subqueries**: IN, EXISTS, scalar subqueries
//! - **Window Functions**: ROW_NUMBER, RANK, DENSE_RANK, LAG, LEAD
//! - **Custom UDFs**: vector_distance(), semantic_project(), etc.
//!
//! # Architecture
//!
//! ```text
//! SQL String
//!     │
//!     ▼
//! SqlQueryEngine::execute_sql()
//!     │
//!     ▼
//! DataFusion SessionContext
//!     ├── LanceTableProvider (TableProvider trait)
//!     │   ├── Arrow Schema from Lance
//!     │   ├── Projection push-down
//!     │   └── Filter push-down
//!     ├── Custom UDFs (vector_distance, etc.)
//!     └── Custom UDAFs (vector aggregations)
//!     │
//!     ▼
//! Arrow RecordBatch results
//! ```

pub mod context;
pub mod table_provider;
pub mod udf;
pub mod engine;

#[cfg(feature = "candle")]
pub mod gpt_udf;

pub use context::AifastDbSessionContext;
pub use table_provider::LanceTableProvider;
pub use engine::SqlQueryEngine;
pub use udf::{register_all_udfs, VectorDistanceUdf};

#[cfg(feature = "candle")]
pub use gpt_udf::register_gpt_udfs;

#[cfg(test)]
mod tests;

