athena_rs 3.11.0

Hyper performant polyglot Database driver
Documentation
use serde_json::Value;

use crate::drivers::scylla::client::ScyllaConnectionInfo;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AthenaEngine {
    Postgres,
    Scylla,
    S3,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum AthenaClientLifecycle {
    Active,
    Frozen,
    Inactive,
}

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct AthenaCapabilities {
    pub gateway_query: bool,
    pub raw_sql: bool,
    pub raw_cql: bool,
    pub schema_read: bool,
    pub migrations_read: bool,
    pub provisioning: bool,
    pub deferred_query: bool,
    pub cdc: bool,
    pub object_read: bool,
    pub object_write: bool,
}

impl AthenaCapabilities {
    pub fn for_engine(engine: AthenaEngine) -> Self {
        match engine {
            AthenaEngine::Postgres => Self {
                gateway_query: true,
                raw_sql: true,
                raw_cql: false,
                schema_read: true,
                migrations_read: true,
                provisioning: true,
                deferred_query: true,
                cdc: true,
                object_read: false,
                object_write: false,
            },
            AthenaEngine::Scylla => Self {
                gateway_query: true,
                raw_sql: false,
                raw_cql: true,
                schema_read: false,
                migrations_read: false,
                provisioning: false,
                deferred_query: false,
                cdc: false,
                object_read: false,
                object_write: false,
            },
            AthenaEngine::S3 => Self {
                gateway_query: false,
                raw_sql: false,
                raw_cql: false,
                schema_read: false,
                migrations_read: false,
                provisioning: false,
                deferred_query: false,
                cdc: false,
                object_read: true,
                object_write: true,
            },
        }
    }
}

#[derive(Debug, Clone)]
pub struct AthenaPostgresConnection {
    pub pg_uri: Option<String>,
    pub pg_uri_env_var: Option<String>,
    pub config_uri_template: Option<String>,
}

#[derive(Debug, Clone, Default)]
pub struct AthenaS3Connection;

#[derive(Debug, Clone)]
pub enum AthenaConnection {
    Postgres(AthenaPostgresConnection),
    Scylla(ScyllaConnectionInfo),
    S3(AthenaS3Connection),
}

#[derive(Debug, Clone)]
pub struct AthenaClientDefinition {
    pub client_name: String,
    pub description: Option<String>,
    pub source: String,
    pub engine: AthenaEngine,
    pub lifecycle: AthenaClientLifecycle,
    pub capabilities: AthenaCapabilities,
    pub connection: AthenaConnection,
    pub metadata: Value,
}