use std::fmt;
use std::path::PathBuf;
use serde::Serialize;
use super::*;
use crate::types::DataType;
use crate::v1::binder::statement::copy::FileFormat;
#[derive(Debug, Clone, Serialize)]
pub struct LogicalCopyFromFile {
path: PathBuf,
format: FileFormat,
column_types: Vec<DataType>,
schema: Vec<ColumnDesc>,
}
impl LogicalCopyFromFile {
pub fn new(
path: PathBuf,
format: FileFormat,
column_types: Vec<DataType>,
schema: Vec<ColumnDesc>,
) -> Self {
Self {
path,
format,
column_types,
schema,
}
}
pub fn format(&self) -> &FileFormat {
&self.format
}
pub fn column_types(&self) -> &[DataType] {
self.column_types.as_ref()
}
pub fn path(&self) -> &PathBuf {
&self.path
}
}
impl PlanTreeNodeLeaf for LogicalCopyFromFile {}
impl_plan_tree_node_for_leaf!(LogicalCopyFromFile);
impl PlanNode for LogicalCopyFromFile {
fn schema(&self) -> Vec<ColumnDesc> {
self.schema.clone()
}
}
impl fmt::Display for LogicalCopyFromFile {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(
f,
"LogicalCopyFromFile: path: {:?}, format: {:?}",
self.path, self.format,
)
}
}