Skip to main content

risingwave_stream/from_proto/
dml.rs

1// Copyright 2022 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_stream_node_body!(Dml(DmlNode) => DmlExecutorBuilder);
28
29impl ExecutorBuilder for DmlExecutorBuilder {
30    type Node = DmlNode;
31
32    async fn new_boxed_executor(
33        params: ExecutorParams,
34        node: &Self::Node,
35        store: impl StateStore,
36    ) -> StreamResult<Executor> {
37        let [upstream]: [_; 1] = params.input.try_into().unwrap();
38        let table_id = node.table_id;
39        let column_descs = node.column_descs.iter().map(Into::into).collect_vec();
40
41        let exec = DmlExecutor::new(
42            params.actor_context.clone(),
43            upstream,
44            params.env.dml_manager_ref(),
45            table_id,
46            node.table_version_id,
47            column_descs,
48            params.config.developer.chunk_size,
49            node.rate_limit.into(),
50            store,
51        );
52        Ok((params.info, exec).into())
53    }
54}