Skip to main content

risingwave_connector/source/cdc/
oracle.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 std::collections::BTreeMap;
16
17use anyhow::anyhow;
18use risingwave_common::bail;
19use risingwave_common::license::{Feature, FeatureNotAvailable};
20use risingwave_pb::secret::PbSecretRef;
21
22use crate::error::ConnectorResult;
23use crate::source::cdc::{
24    CdcSourceDdlValidator, CdcSourceExternalTableIdentifier, CdcSourceRuntimeFlags,
25    CdcSourceTypeTrait, HEARTBEAT_TABLE_AUTO_INITIALIZE_KEY, Oracle,
26    check_alter_with_options_inner, check_common_with_options,
27};
28
29// ------- Runtime flags -------
30
31impl CdcSourceRuntimeFlags for Oracle {
32    const CAN_AUTO_INITIALIZE_HEARTBEAT_TABLE: bool = true;
33    const CAN_BACKFILL: bool = true;
34    const NEEDS_NON_EMPTY_INITIAL_OFFSET: bool = true;
35    const NEEDS_PARSING_NUMBER_IN_DEBEZIUM_EVENT_AS_STRING: bool = true;
36}
37
38// ------- DDL validation -------
39
40impl CdcSourceDdlValidator for Oracle {
41    fn check_and_fill_create_with_options(
42        props: &mut BTreeMap<String, String>,
43        secret_refs: &BTreeMap<String, PbSecretRef>,
44    ) -> ConnectorResult<()> {
45        check_common_with_options::<Self>(props, secret_refs)?;
46        if let Some(value) = props.get(HEARTBEAT_TABLE_AUTO_INITIALIZE_KEY)
47            && value.parse::<bool>().map_err(|_| {
48                anyhow!("'{HEARTBEAT_TABLE_AUTO_INITIALIZE_KEY}' must be 'true' or 'false'")
49            })?
50            && !props
51                .get("heartbeat.table.name")
52                .is_some_and(|value| !value.trim().is_empty())
53        {
54            bail!("'{HEARTBEAT_TABLE_AUTO_INITIALIZE_KEY}' requires 'heartbeat.table.name'");
55        }
56        Ok(())
57    }
58
59    fn check_license() -> Result<(), FeatureNotAvailable> {
60        Feature::OracleCdcSource.check_available()
61    }
62
63    fn check_alter_with_options(
64        props: &BTreeMap<String, String>,
65        secret_refs: &BTreeMap<String, PbSecretRef>,
66    ) -> ConnectorResult<()> {
67        check_common_with_options::<Self>(props, secret_refs)?;
68        check_alter_with_options_inner(
69            Self::CDC_CONNECTOR_NAME,
70            props,
71            secret_refs,
72            &[
73                "cdc.source.wait.streaming.start.timeout",
74                "debezium.max.queue.size",
75                "debezium.queue.memory.ratio",
76                "debezium.heartbeat.interval.ms",
77                "heartbeat.table.name",
78                "hostname",
79                "port",
80                "password",
81            ],
82        )
83    }
84}
85
86// ------- External table identifier -------
87
88impl CdcSourceExternalTableIdentifier for Oracle {}