57 lines
1.4 KiB
Rust
57 lines
1.4 KiB
Rust
//! Transformation pipeline system with declarative specifications
|
|
//!
|
|
//! Provides comprehensive data transformation capabilities.
|
|
|
|
use crate::{DataRecord, Result};
|
|
use serde::{Deserialize, Serialize};
|
|
use std::collections::HashMap;
|
|
|
|
/// Transformation specification
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct Transformation {
|
|
pub id: String,
|
|
pub transform_type: TransformationType,
|
|
pub config: HashMap<String, String>,
|
|
}
|
|
|
|
/// Types of transformations
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub enum TransformationType {
|
|
Sql(String),
|
|
Map,
|
|
Filter,
|
|
CustomFunction(String),
|
|
}
|
|
|
|
/// Transformation builder
|
|
pub struct TransformationBuilder {
|
|
transformation: Transformation,
|
|
}
|
|
|
|
/// Function signature for transformations
|
|
pub type TransformFunction = fn(&DataRecord) -> Result<DataRecord>;
|
|
|
|
/// Transformation pipeline
|
|
#[derive(Debug, Default)]
|
|
pub struct TransformationPipeline {
|
|
pub steps: Vec<Transformation>,
|
|
}
|
|
|
|
/// SQL transformation
|
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
|
pub struct SqlTransformation {
|
|
pub query: String,
|
|
pub params: HashMap<String, String>,
|
|
}
|
|
|
|
impl Transformation {
|
|
#[must_use]
|
|
pub fn sql(query: &str) -> Self {
|
|
Self {
|
|
id: uuid::Uuid::new_v4().to_string(),
|
|
transform_type: TransformationType::Sql(query.to_string()),
|
|
config: HashMap::new(),
|
|
}
|
|
}
|
|
}
|