datafusion_table_providers/sql/db_connection_pool/
mod.rs1use async_trait::async_trait;
2use dbconnection::DbConnection;
3use std::sync::Arc;
4
5pub mod dbconnection;
6
7#[cfg(feature = "clickhouse")]
8pub mod clickhousepool;
9#[cfg(feature = "duckdb")]
10pub mod duckdbpool;
11#[cfg(feature = "mysql")]
12pub mod mysqlpool;
13#[cfg(feature = "odbc")]
14pub mod odbcpool;
15#[cfg(feature = "postgres")]
16pub mod postgrespool;
17pub mod runtime;
18#[cfg(feature = "sqlite")]
19pub mod sqlitepool;
20
21pub type Error = Box<dyn std::error::Error + Send + Sync>;
22type Result<T, E = Error> = std::result::Result<T, E>;
23
24#[derive(Clone, Debug, PartialEq, Eq)]
26pub enum JoinPushDown {
27 Disallow,
29 AllowedFor(String),
33}
34
35#[async_trait]
36pub trait DbConnectionPool<T, P: 'static> {
37 async fn connect(&self) -> Result<Box<dyn DbConnection<T, P>>>;
38
39 fn join_push_down(&self) -> JoinPushDown;
40}
41
42#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)]
43pub enum Mode {
44 #[default]
45 Memory,
46 File,
47}
48
49impl From<&str> for Mode {
50 fn from(m: &str) -> Self {
51 match m {
52 "file" => Mode::File,
53 "memory" => Mode::Memory,
54 _ => Mode::default(),
55 }
56 }
57}
58
59#[derive(Debug, Clone, PartialEq, Eq, Hash)]
61pub enum DbInstanceKey {
62 File(Arc<str>),
64 Memory,
66}
67
68impl DbInstanceKey {
69 pub fn memory() -> Self {
70 DbInstanceKey::Memory
71 }
72
73 pub fn file(path: Arc<str>) -> Self {
74 DbInstanceKey::File(path)
75 }
76}