use url::Url;
use crate::actions::deletion_vector::DeletionVectorPath;
use crate::expressions::{ColumnName, ExpressionRef};
use crate::schema::SchemaRef;
use crate::table_features::ColumnMappingMode;
pub struct WriteContext {
target_dir: Url,
logical_schema: SchemaRef,
physical_schema: SchemaRef,
logical_to_physical: ExpressionRef,
column_mapping_mode: ColumnMappingMode,
stats_columns: Vec<ColumnName>,
}
impl WriteContext {
pub(crate) fn new(
target_dir: Url,
logical_schema: SchemaRef,
physical_schema: SchemaRef,
logical_to_physical: ExpressionRef,
column_mapping_mode: ColumnMappingMode,
stats_columns: Vec<ColumnName>,
) -> Self {
WriteContext {
target_dir,
logical_schema,
physical_schema,
logical_to_physical,
column_mapping_mode,
stats_columns,
}
}
pub fn target_dir(&self) -> &Url {
&self.target_dir
}
pub fn logical_schema(&self) -> &SchemaRef {
&self.logical_schema
}
pub fn physical_schema(&self) -> &SchemaRef {
&self.physical_schema
}
pub fn logical_to_physical(&self) -> ExpressionRef {
self.logical_to_physical.clone()
}
pub fn column_mapping_mode(&self) -> ColumnMappingMode {
self.column_mapping_mode
}
pub fn stats_columns(&self) -> &[ColumnName] {
&self.stats_columns
}
pub fn new_deletion_vector_path(&self, random_prefix: String) -> DeletionVectorPath {
DeletionVectorPath::new(self.target_dir.clone(), random_prefix)
}
}