use polars::prelude::DataFrame;
use crate::errors::RunError;
use crate::io::format::AcceptedMergeMetrics;
use crate::io::storage::Target;
use crate::{config, FloeResult};
pub(crate) mod scd1;
pub(crate) mod scd2;
pub(crate) mod shared;
pub(crate) struct MergeExecutionContext<'a> {
pub(crate) runtime: &'a tokio::runtime::Runtime,
pub(crate) target: &'a Target,
pub(crate) resolver: &'a config::StorageResolver,
pub(crate) entity: &'a config::EntityConfig,
pub(crate) partition_by: Option<Vec<String>>,
pub(crate) target_file_size_bytes: Option<usize>,
}
pub(crate) trait MergeBackend {
fn execute_scd1(
&self,
source_df: &mut DataFrame,
ctx: &MergeExecutionContext<'_>,
) -> FloeResult<(
i64,
AcceptedMergeMetrics,
crate::io::format::AcceptedSchemaEvolution,
shared::DeltaMergePerfBreakdown,
)>;
fn execute_scd2(
&self,
_source_df: &mut DataFrame,
_ctx: &MergeExecutionContext<'_>,
) -> FloeResult<(
i64,
AcceptedMergeMetrics,
crate::io::format::AcceptedSchemaEvolution,
shared::DeltaMergePerfBreakdown,
)> {
Err(Box::new(RunError(
"write_mode=merge_scd2 is not implemented for this backend".to_string(),
)))
}
}