Skip to main content

oxisql_datafusion/
lib.rs

1#![forbid(unsafe_code)]
2#![warn(missing_docs)]
3
4//! `oxisql-datafusion` — Apache DataFusion `TableProvider` over an OxiSQL
5//! [`Connection`](oxisql_core::Connection).
6//!
7//! This crate exposes oxisql-backed tables to Apache DataFusion so that OLAP
8//! SQL queries can be planned and executed against oxisql data using the full
9//! DataFusion query engine.
10//!
11//! # Quick start
12//!
13//! ```rust
14//! use std::sync::Arc;
15//! use arrow::datatypes::{DataType, Field, Schema};
16//! use oxisql_core::{Row, Value};
17//! use oxisql_datafusion::OxiSqlTableProvider;
18//!
19//! let schema = Arc::new(Schema::new(vec![
20//!     Field::new("id",    DataType::Int64,   false),
21//!     Field::new("name",  DataType::Utf8,    false),
22//!     Field::new("score", DataType::Float64, false),
23//! ]));
24//!
25//! let rows = vec![
26//!     Row::new(
27//!         vec!["id".into(), "name".into(), "score".into()],
28//!         vec![Value::I64(1), Value::Text("Alice".into()), Value::F64(95.5)],
29//!     ),
30//! ];
31//!
32//! let provider = OxiSqlTableProvider::from_rows(rows, schema);
33//! ```
34
35pub mod context;
36pub mod error;
37pub mod provider;
38pub mod stream;
39pub mod types;
40
41#[cfg(feature = "columnar")]
42pub mod parquet;
43
44pub use context::{register_embedded_table, register_oxisql_table, OxiSqlContext};
45pub use error::OxiSqlFusionError;
46pub use provider::OxiSqlTableProvider;
47pub use stream::{OxiSqlStreamProvider, SortOrder};
48
49#[cfg(feature = "columnar")]
50pub use parquet::ParquetTableProvider;
51
52/// Bridge utilities for converting `oxisql_parse::LogicalPlan` to DataFusion
53/// `LogicalPlan`.  Enabled by the `parse` feature flag.
54#[cfg(feature = "parse")]
55pub mod plan_bridge;
56
57#[cfg(feature = "parse")]
58pub use plan_bridge::{sql_to_datafusion_plan, to_datafusion_plan};