use adbc_core::{
error::Result,
options::{OptionStatement, OptionValue},
Optionable, PartitionedResult,
};
use adbc_driver_manager::ManagedStatement;
use arrow_array::{RecordBatch, RecordBatchReader};
use arrow_schema::Schema;
pub struct Statement(pub(crate) ManagedStatement);
impl Optionable for Statement {
type Option = OptionStatement;
fn set_option(&mut self, key: Self::Option, value: OptionValue) -> Result<()> {
self.0.set_option(key, value)
}
fn get_option_string(&self, key: Self::Option) -> Result<String> {
self.0.get_option_string(key)
}
fn get_option_bytes(&self, key: Self::Option) -> Result<Vec<u8>> {
self.0.get_option_bytes(key)
}
fn get_option_int(&self, key: Self::Option) -> Result<i64> {
self.0.get_option_int(key)
}
fn get_option_double(&self, key: Self::Option) -> Result<f64> {
self.0.get_option_double(key)
}
}
impl adbc_core::Statement for Statement {
fn bind(&mut self, batch: RecordBatch) -> Result<()> {
self.0.bind(batch)
}
fn bind_stream(&mut self, reader: Box<dyn RecordBatchReader + Send>) -> Result<()> {
self.0.bind_stream(reader)
}
fn execute(&mut self) -> Result<Box<dyn RecordBatchReader + Send + 'static>> {
self.0.execute()
}
fn execute_update(&mut self) -> Result<Option<i64>> {
self.0.execute_update()
}
fn execute_schema(&mut self) -> Result<Schema> {
self.0.execute_schema()
}
fn execute_partitions(&mut self) -> Result<PartitionedResult> {
self.0.execute_partitions()
}
fn get_parameter_schema(&self) -> Result<Schema> {
self.0.get_parameter_schema()
}
fn prepare(&mut self) -> Result<()> {
self.0.prepare()
}
fn set_sql_query(&mut self, query: impl AsRef<str>) -> Result<()> {
self.0.set_sql_query(query)
}
fn set_substrait_plan(&mut self, plan: impl AsRef<[u8]>) -> Result<()> {
self.0.set_substrait_plan(plan)
}
fn cancel(&mut self) -> Result<()> {
self.0.cancel()
}
}