use std::path::{Path, PathBuf};
use arrow_array::RecordBatch;
use arrow_schema::SchemaRef;
use crate::python_sources::errors::ReadError;
use crate::python_sources::models::{PythonSource, TableRead, TransformCall};
#[derive(Debug)]
pub enum Streamed {
Batch(RecordBatch),
State(String),
}
pub trait BatchStream: Send + std::fmt::Debug {
fn next_batch(&mut self) -> Option<Result<Streamed, ReadError>>;
fn crossed_dicts(&self) -> bool {
false
}
}
pub trait PythonHost: Send + Sync + std::fmt::Debug {
fn discover(&self, root: &Path, python_paths: &[PathBuf]) -> Result<Vec<PythonSource>, String>;
fn read_table(&self, request: &TableRead) -> Result<Box<dyn BatchStream>, String>;
fn table_state(&self, table: &str) -> Result<Option<String>, String>;
fn transform_version(&self, name: &str) -> Result<String, String>;
fn transform(
&self,
call: &TransformCall,
rows: Vec<RecordBatch>,
schema: SchemaRef,
) -> Result<Box<dyn BatchStream>, String>;
fn rename(&self, name: &str, columns: Option<&str>, context: &str) -> Result<String, String>;
fn finish(&self);
}