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 blob_descriptor_functions;
40mod blob_reader;
41mod blob_view;
42mod catalog;
43mod delete;
44mod error;
45mod filter_pushdown;
46#[cfg(feature = "fulltext")]
47mod full_text_search;
48mod hybrid_search;
49mod lateral_vector_search;
50mod merge_into;
51mod physical_plan;
52mod procedures;
53mod relation_planner;
54pub mod runtime;
55mod sql_context;
56mod sql_function;
57mod system_tables;
58mod table;
59mod table_function_args;
60mod table_loader;
61mod update;
62mod variant_functions;
63mod variant_pushdown;
64mod vector_search;
65
66use std::collections::HashMap;
67use std::sync::{Arc, RwLock};
68
69/// Session-scoped dynamic options set via `SET 'paimon.key' = 'value'`.
70///
71/// Shared internally across [`SQLContext`] and [`PaimonCatalogProvider`]
72/// so that SET/RESET mutations are visible to subsequent table scans.
73pub(crate) type DynamicOptions = Arc<RwLock<HashMap<String, String>>>;
74
75pub use blob_reader::BlobReaderRegistry;
76pub use blob_view::register_blob_view;
77pub use catalog::{PaimonCatalogProvider, PaimonSchemaProvider};
78pub use error::to_datafusion_error;
79#[cfg(feature = "fulltext")]
80pub use full_text_search::{register_full_text_search, FullTextSearchFunction};
81pub use hybrid_search::{register_hybrid_search, HybridSearchFunction};
82pub use physical_plan::PaimonTableScan;
83pub use relation_planner::PaimonRelationPlanner;
84pub use sql_context::SQLContext;
85pub use table::PaimonTableProvider;
86pub use variant_functions::register_variant_functions;
87pub use vector_search::{register_vector_search, VectorSearchFunction};