risingwave_stream/from_proto/
project_set.rs1use multimap::MultiMap;
16use risingwave_common::util::iter_util::ZipEqFast;
17use risingwave_pb::stream_plan::ProjectSetNode;
18
19use super::*;
20use crate::executor::project::{ProjectSetExecutor, ProjectSetSelectItem};
21
22pub struct ProjectSetExecutorBuilder;
23
24impl ExecutorBuilder for ProjectSetExecutorBuilder {
25 type Node = ProjectSetNode;
26
27 async fn new_boxed_executor(
28 params: ExecutorParams,
29 node: &Self::Node,
30 _store: impl StateStore,
31 ) -> StreamResult<Executor> {
32 let [input]: [_; 1] = params.input.try_into().unwrap();
33 let select_list: Vec<_> = node
34 .get_select_list()
35 .iter()
36 .map(|proto| {
37 ProjectSetSelectItem::from_prost(
38 proto,
39 params.eval_error_report.clone(),
40 params.env.config().developer.chunk_size,
41 )
42 })
43 .try_collect()?;
44 let watermark_derivations = MultiMap::from_iter(
45 node.get_watermark_input_cols()
46 .iter()
47 .map(|idx| *idx as usize)
48 .zip_eq_fast(
49 node.get_watermark_expr_indices()
50 .iter()
51 .map(|idx| *idx as usize),
52 ),
53 );
54 let nondecreasing_expr_indices = node
55 .get_nondecreasing_exprs()
56 .iter()
57 .map(|idx| *idx as usize)
58 .collect();
59
60 let chunk_size = params.env.config().developer.chunk_size;
61 let exec = ProjectSetExecutor::new(
62 params.actor_context,
63 input,
64 select_list,
65 chunk_size,
66 watermark_derivations,
67 nondecreasing_expr_indices,
68 params.eval_error_report,
69 );
70 Ok((params.info, exec).into())
71 }
72}