risingwave_stream/from_proto/
materialized_exprs.rs

1// Copyright 2025 RisingWave Labs
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::sync::Arc;
16
17use risingwave_expr::expr::build_non_strict_from_prost;
18use risingwave_pb::stream_plan::MaterializedExprsNode;
19
20use super::*;
21use crate::common::table::state_table::StateTableBuilder;
22use crate::executor::project::{MaterializedExprsArgs, MaterializedExprsExecutor};
23
24pub struct MaterializedExprsExecutorBuilder;
25
26impl ExecutorBuilder for MaterializedExprsExecutorBuilder {
27    type Node = MaterializedExprsNode;
28
29    async fn new_boxed_executor(
30        params: ExecutorParams,
31        node: &Self::Node,
32        store: impl StateStore,
33    ) -> StreamResult<Executor> {
34        let [input]: [_; 1] = params.input.try_into().unwrap();
35
36        let exprs: Vec<_> = node
37            .get_exprs()
38            .iter()
39            .map(|e| build_non_strict_from_prost(e, params.eval_error_report.clone()))
40            .try_collect()?;
41
42        let vnodes = params.vnode_bitmap.map(Arc::new);
43        let state_table = StateTableBuilder::new(node.get_state_table()?, store, vnodes)
44            .enable_preload_all_rows_by_config(&params.actor_context.streaming_config)
45            .build()
46            .await;
47
48        let exec = MaterializedExprsExecutor::new(MaterializedExprsArgs {
49            actor_ctx: params.actor_context,
50            input,
51            exprs,
52            state_table,
53            state_clean_col_idx: node.state_clean_col_idx.map(|i| i as _),
54            watermark_epoch: params.watermark_epoch,
55        });
56        Ok((params.info, exec).into())
57    }
58}