use std::future::Future;
use std::pin::Pin;
#[derive(Debug, Clone, Default)]
pub struct StatementResult {
pub columns: Vec<(String, String)>,
pub rows: Vec<Vec<Option<String>>>,
pub error: Option<String>,
}
pub trait RedshiftQueryBackend: Send + Sync {
fn execute_statement(
&self,
sql: String,
) -> Pin<Box<dyn Future<Output = StatementResult> + Send>>;
fn batch_execute(
&self,
sqls: Vec<String>,
) -> Pin<Box<dyn Future<Output = StatementResult> + Send>>;
}
pub struct InMemoryRedshiftQueryBackend;
impl RedshiftQueryBackend for InMemoryRedshiftQueryBackend {
fn execute_statement(
&self,
_sql: String,
) -> Pin<Box<dyn Future<Output = StatementResult> + Send>> {
Box::pin(async move {
StatementResult {
columns: vec![
("Number".to_string(), "integer".to_string()),
("Street".to_string(), "varchar".to_string()),
("City".to_string(), "varchar".to_string()),
],
rows: vec![
vec![
Some("10".to_string()),
Some("Alpha st".to_string()),
Some("Portland".to_string()),
],
vec![
Some("20".to_string()),
Some("Beta st".to_string()),
Some("Bellevue".to_string()),
],
vec![
Some("30".to_string()),
Some("Gamma st".to_string()),
Some("Seattle".to_string()),
],
],
error: None,
}
})
}
fn batch_execute(
&self,
_sqls: Vec<String>,
) -> Pin<Box<dyn Future<Output = StatementResult> + Send>> {
Box::pin(async move { StatementResult::default() })
}
}