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