risingwave_stream/from_proto/
dml.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 itertools::Itertools;
16use risingwave_pb::stream_plan::DmlNode;
17use risingwave_storage::StateStore;
18
19use super::ExecutorBuilder;
20use crate::error::StreamResult;
21use crate::executor::Executor;
22use crate::executor::dml::DmlExecutor;
23use crate::task::ExecutorParams;
24
25pub struct DmlExecutorBuilder;
26
27impl ExecutorBuilder for DmlExecutorBuilder {
28    type Node = DmlNode;
29
30    async fn new_boxed_executor(
31        params: ExecutorParams,
32        node: &Self::Node,
33        _store: impl StateStore,
34    ) -> StreamResult<Executor> {
35        let [upstream]: [_; 1] = params.input.try_into().unwrap();
36        let table_id = node.table_id;
37        let column_descs = node.column_descs.iter().map(Into::into).collect_vec();
38
39        let exec = DmlExecutor::new(
40            params.actor_context.clone(),
41            upstream,
42            params.env.dml_manager_ref(),
43            table_id,
44            node.table_version_id,
45            column_descs,
46            params.config.developer.chunk_size,
47            node.rate_limit.into(),
48        );
49        Ok((params.info, exec).into())
50    }
51}