• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 4124646176

pending completion
4124646176

Pull #811

github

GitHub
Merge c6bc261de into f4fe30c14
Pull Request #811: chore: integrating sql planner

737 of 737 new or added lines in 23 files covered. (100.0%)

23321 of 35114 relevant lines covered (66.42%)

35990.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.43
/dozer-sql/src/pipeline/projection/processor.rs
1
use crate::pipeline::expression::execution::{Expression, ExpressionExecutor};
2

3
use dozer_core::channels::ProcessorChannelForwarder;
4
use dozer_core::epoch::Epoch;
5
use dozer_core::errors::ExecutionError;
6
use dozer_core::errors::ExecutionError::InternalError;
7
use dozer_core::node::{PortHandle, Processor};
8
use dozer_core::record_store::RecordReader;
9
use dozer_core::storage::lmdb_storage::{LmdbEnvironmentManager, SharedTransaction};
10
use dozer_core::DEFAULT_PORT_HANDLE;
11
use dozer_types::types::{Operation, Record, Schema};
12
use std::collections::HashMap;
13

14
#[derive(Debug)]
×
15
pub struct ProjectionProcessor {
16
    expressions: Vec<Expression>,
17
    input_schema: Schema,
18
}
19

20
impl ProjectionProcessor {
21
    pub fn new(input_schema: Schema, expressions: Vec<Expression>) -> Self {
127✔
22
        Self {
127✔
23
            input_schema,
127✔
24
            expressions,
127✔
25
        }
127✔
26
    }
127✔
27

28
    fn delete(&mut self, record: &Record) -> Result<Operation, ExecutionError> {
10,922✔
29
        let mut results = vec![];
10,922✔
30

31
        for expr in &self.expressions {
43,692✔
32
            results.push(
33
                expr.evaluate(record, &self.input_schema)
32,770✔
34
                    .map_err(|e| InternalError(Box::new(e)))?,
32,770✔
35
            );
×
36
        }
37
        Ok(Operation::Delete {
10,922✔
38
            old: Record::new(None, results, None),
10,922✔
39
        })
10,922✔
40
    }
10,922✔
41

×
42
    fn insert(&mut self, record: &Record) -> Result<Operation, ExecutionError> {
57,647✔
43
        let mut results = vec![];
57,647✔
44

×
45
        for expr in self.expressions.clone() {
151,793✔
46
            results.push(
×
47
                expr.evaluate(record, &self.input_schema)
151,793✔
48
                    .map_err(|e| InternalError(Box::new(e)))?,
151,793✔
49
            );
×
50
        }
×
51
        Ok(Operation::Insert {
57,647✔
52
            new: Record::new(None, results, None),
57,647✔
53
        })
57,647✔
54
    }
57,647✔
55

×
56
    fn update(&self, old: &Record, new: &Record) -> Result<Operation, ExecutionError> {
×
57
        let mut old_results = vec![];
×
58
        let mut new_results = vec![];
×
59

×
60
        for expr in &self.expressions {
×
61
            old_results.push(
62
                expr.evaluate(old, &self.input_schema)
×
63
                    .map_err(|e| InternalError(Box::new(e)))?,
×
64
            );
×
65
            new_results.push(
×
66
                expr.evaluate(new, &self.input_schema)
×
67
                    .map_err(|e| InternalError(Box::new(e)))?,
×
68
            );
69
        }
×
70

×
71
        Ok(Operation::Update {
×
72
            old: Record::new(None, old_results, None),
×
73
            new: Record::new(None, new_results, None),
×
74
        })
×
75
    }
×
76
}
×
77

×
78
impl Processor for ProjectionProcessor {
×
79
    fn init(&mut self, _env: &mut LmdbEnvironmentManager) -> Result<(), ExecutionError> {
127✔
80
        Ok(())
127✔
81
    }
127✔
82

83
    fn process(
68,569✔
84
        &mut self,
68,569✔
85
        _from_port: PortHandle,
68,569✔
86
        op: Operation,
68,569✔
87
        fw: &mut dyn ProcessorChannelForwarder,
68,569✔
88
        _tx: &SharedTransaction,
68,569✔
89
        _reader: &HashMap<PortHandle, Box<dyn RecordReader>>,
68,569✔
90
    ) -> Result<(), ExecutionError> {
68,569✔
91
        let _ = match op {
68,569✔
92
            Operation::Delete { ref old } => fw.send(self.delete(old)?, DEFAULT_PORT_HANDLE),
10,922✔
93
            Operation::Insert { ref new } => fw.send(self.insert(new)?, DEFAULT_PORT_HANDLE),
57,647✔
94
            Operation::Update { ref old, ref new } => {
×
95
                fw.send(self.update(old, new)?, DEFAULT_PORT_HANDLE)
×
96
            }
×
97
        };
×
98
        Ok(())
68,569✔
99
    }
68,569✔
100

101
    fn commit(&self, _epoch: &Epoch, _tx: &SharedTransaction) -> Result<(), ExecutionError> {
122✔
102
        Ok(())
122✔
103
    }
122✔
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc