Skip to main content

risingwave_stream/from_proto/iceberg_with_pk_index/
position_delete_merger.rs

1// Copyright 2026 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 anyhow::anyhow;
16use risingwave_common::secret::LocalSecretManager;
17use risingwave_connector::sink::iceberg::IcebergConfig;
18use risingwave_pb::id::SinkId;
19use risingwave_pb::stream_plan::IcebergWithPkIndexPositionDeleteMergerNode;
20use risingwave_storage::StateStore;
21
22use crate::error::StreamResult;
23use crate::executor::{
24    Executor, PositionDeleteHandlerImpl, PositionDeleteMergerExecutor, StreamExecutorError,
25};
26use crate::from_proto::ExecutorBuilder;
27use crate::task::ExecutorParams;
28
29pub struct IcebergWithPkIndexPositionDeleteMergerExecutorBuilder;
30
31impl_stream_node_body!(IcebergWithPkIndexPositionDeleteMerger(IcebergWithPkIndexPositionDeleteMergerNode) => IcebergWithPkIndexPositionDeleteMergerExecutorBuilder);
32
33impl ExecutorBuilder for IcebergWithPkIndexPositionDeleteMergerExecutorBuilder {
34    type Node = IcebergWithPkIndexPositionDeleteMergerNode;
35
36    async fn new_boxed_executor(
37        params: ExecutorParams,
38        node: &Self::Node,
39        _store: impl StateStore,
40    ) -> StreamResult<Executor> {
41        let [input]: [_; 1] = params.input.try_into().unwrap();
42
43        let sink_desc = node.sink_desc.as_ref().unwrap();
44        let sink_id: SinkId = sink_desc.get_id();
45
46        let properties_with_secret = LocalSecretManager::global().fill_secrets(
47            sink_desc.get_properties().clone(),
48            sink_desc.get_secret_refs().clone(),
49        )?;
50        let config = IcebergConfig::from_btreemap(properties_with_secret)
51            .map_err(|err| StreamExecutorError::sink_error(err, sink_id))?;
52        let meta_client = params.env.meta_client().ok_or_else(|| {
53            anyhow!("meta client is required for iceberg pk-index position-delete merger")
54        })?;
55
56        let handler = PositionDeleteHandlerImpl::new(
57            config,
58            params.actor_context.id,
59            params.vnode_bitmap.clone(),
60            sink_id,
61            meta_client,
62        );
63
64        let exec = PositionDeleteMergerExecutor::new(
65            params.actor_context.id,
66            sink_id,
67            params.local_barrier_manager.clone(),
68            input,
69            handler,
70        );
71        Ok((params.info, exec).into())
72    }
73}