paimon_datafusion/lib.rs
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18//! Apache Paimon DataFusion Integration.
19//!
20//! Register a Paimon table as a DataFusion table provider to query it with SQL or DataFrame API.
21//!
22//! # Example
23//!
24//! ```ignore
25//! use std::sync::Arc;
26//! use datafusion::prelude::SessionContext;
27//! use paimon_datafusion::PaimonTableProvider;
28//!
29//! // Obtain a Paimon Table (e.g. from your catalog), then:
30//! let provider = PaimonTableProvider::try_new(table)?;
31//! let ctx = SessionContext::new();
32//! ctx.register_table("my_table", Arc::new(provider))?;
33//! let df = ctx.sql("SELECT * FROM my_table").await?;
34//! ```
35//!
36//! This version supports partition predicate pushdown by extracting
37//! translatable partition-only conjuncts from DataFusion filters.
38
39mod catalog;
40mod delete;
41mod error;
42mod filter_pushdown;
43#[cfg(feature = "fulltext")]
44mod full_text_search;
45mod merge_into;
46mod physical_plan;
47mod procedures;
48mod relation_planner;
49pub mod runtime;
50mod sql_context;
51mod system_tables;
52mod table;
53mod table_function_args;
54mod update;
55mod vector_search;
56
57use std::collections::HashMap;
58use std::sync::{Arc, RwLock};
59
60/// Session-scoped dynamic options set via `SET 'paimon.key' = 'value'`.
61///
62/// Shared internally across [`SQLContext`] and [`PaimonCatalogProvider`]
63/// so that SET/RESET mutations are visible to subsequent table scans.
64pub(crate) type DynamicOptions = Arc<RwLock<HashMap<String, String>>>;
65
66pub use catalog::{PaimonCatalogProvider, PaimonSchemaProvider};
67pub use error::to_datafusion_error;
68#[cfg(feature = "fulltext")]
69pub use full_text_search::{register_full_text_search, FullTextSearchFunction};
70pub use physical_plan::PaimonTableScan;
71pub use relation_planner::PaimonRelationPlanner;
72pub use sql_context::SQLContext;
73pub use table::PaimonTableProvider;
74pub use vector_search::{register_vector_search, VectorSearchFunction};