// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied.  See the License for the
// specific language governing permissions and limitations
// under the License.

//! Apache Paimon DataFusion Integration.
//!
//! Register a Paimon table as a DataFusion table provider to query it with SQL or DataFrame API.
//!
//! # Example
//!
//! ```ignore
//! use std::sync::Arc;
//! use datafusion::prelude::SessionContext;
//! use paimon_datafusion::PaimonTableProvider;
//!
//! // Obtain a Paimon Table (e.g. from your catalog), then:
//! let provider = PaimonTableProvider::try_new(table)?;
//! let ctx = SessionContext::new();
//! ctx.register_table("my_table", Arc::new(provider))?;
//! let df = ctx.sql("SELECT * FROM my_table").await?;
//! ```
//!
//! This version supports partition predicate pushdown by extracting
//! translatable partition-only conjuncts from DataFusion filters.

mod blob_descriptor_functions;
mod blob_reader;
mod blob_view;
mod catalog;
mod delete;
mod error;
mod filter_pushdown;
#[cfg(feature = "fulltext")]
mod full_text_search;
mod hybrid_search;
mod lateral_vector_search;
mod merge_into;
mod physical_plan;
mod procedures;
mod relation_planner;
pub mod runtime;
mod sql_context;
mod sql_function;
mod system_tables;
mod table;
mod table_function_args;
mod table_loader;
mod update;
mod variant_functions;
mod variant_pushdown;
mod vector_search;

use std::collections::HashMap;
use std::sync::{Arc, RwLock};

/// Session-scoped dynamic options set via `SET 'paimon.key' = 'value'`.
///
/// Shared internally across [`SQLContext`] and [`PaimonCatalogProvider`]
/// so that SET/RESET mutations are visible to subsequent table scans.
pub(crate) type DynamicOptions = Arc<RwLock<HashMap<String, String>>>;

pub use blob_reader::BlobReaderRegistry;
pub use blob_view::register_blob_view;
pub use catalog::{PaimonCatalogProvider, PaimonSchemaProvider};
pub use error::to_datafusion_error;
#[cfg(feature = "fulltext")]
pub use full_text_search::{register_full_text_search, FullTextSearchFunction};
pub use hybrid_search::{register_hybrid_search, HybridSearchFunction};
pub use physical_plan::PaimonTableScan;
pub use relation_planner::PaimonRelationPlanner;
pub use sql_context::SQLContext;
pub use table::PaimonTableProvider;
pub use variant_functions::register_variant_functions;
pub use vector_search::{register_vector_search, VectorSearchFunction};
