use bytes::Bytes;
use url::Url;
use crate::schema::SchemaRef;
use crate::{FileMeta, FileSlice, PredicateRef};
#[derive(Debug)]
pub enum Operation {
IoOperation(IoOperation),
QueryPlan(QueryPlan),
}
#[derive(Debug)]
pub enum IoOperation {
FileListing { url: Url },
ReadBytes { files: Vec<FileSlice> },
WriteBytes {
url: Url,
data: Bytes,
overwrite: bool,
},
HeadFile { url: Url },
AtomicCopy { source: Url, destination: Url },
ParquetFooter { file: FileMeta },
}
impl IoOperation {
pub fn file_listing(url: Url) -> Self {
Self::FileListing { url }
}
pub fn read_bytes(files: Vec<FileSlice>) -> Self {
Self::ReadBytes { files }
}
pub fn write_bytes(url: Url, data: Bytes, overwrite: bool) -> Self {
Self::WriteBytes {
url,
data,
overwrite,
}
}
pub fn head_file(url: Url) -> Self {
Self::HeadFile { url }
}
pub fn atomic_copy(source: Url, destination: Url) -> Self {
Self::AtomicCopy {
source,
destination,
}
}
pub fn parquet_footer(file: FileMeta) -> Self {
Self::ParquetFooter { file }
}
}
pub type QueryPlan = QueryPlanNode;
#[derive(Debug)]
pub enum QueryPlanNode {
ScanJson {
files: Vec<FileMeta>,
physical_schema: SchemaRef,
predicate: Option<PredicateRef>,
},
ScanParquet {
files: Vec<FileMeta>,
physical_schema: SchemaRef,
predicate: Option<PredicateRef>,
},
}