llkv_sql/
lib.rs

1//! SQL interface for LLKV.
2//!
3//! This crate provides the [`SqlEngine`], which parses SQL statements and executes
4//! them using the LLKV runtime. It serves as the primary user-facing interface for
5//! interacting with LLKV databases.
6//!
7//! ```text
8//! SQL String → sqlparser → AST → Plan → Runtime → Storage
9//! ```
10//!
11//! The SQL engine:
12//! 1. Parses SQL using [`sqlparser`]
13//! 2. Converts AST to execution plans
14//! 3. Delegates to `llkv-runtime` for execution
15//! 4. Returns results as Arrow `RecordBatch` instances or row counts
16//!
17//! # Transactions
18//!
19//! By default, each statement executes in its own auto-commit transaction. Use
20//! explicit transaction control for multi-statement transactions:
21//!
22//! # Type System
23//!
24//! SQL types are mapped to Arrow data types (the following is a non-exhaustive list):
25//! - `INT`, `INTEGER`, `BIGINT` → `Int64`
26//! - `FLOAT`, `DOUBLE`, `REAL` → `Float64`
27//! - `TEXT`, `VARCHAR` → `Utf8`
28//! - `DATE` → `Date32`
29pub type SqlResult<T> = llkv_result::Result<T>;
30
31mod sql_engine;
32pub use sql_engine::{
33    PreparedStatement, SqlEngine, SqlParamValue, StatementExpectation,
34    clear_pending_statement_expectations, register_statement_expectation,
35};
36
37mod sql_value;
38use sql_value::SqlValue;
39
40pub use llkv_runtime::{RuntimeStatementResult, SelectExecution};
41pub use llkv_transaction::TransactionKind;