Unverified Commit 029d6b33 authored by Billy Xing's avatar Billy Xing Committed by GitHub

Add new sink connector 'datastream-doris-ext' for CDCSOURCE (#1242)

* Add new sink connector 'datastream-doris-ext', add 'sink.additional-columns' for CDCSOURCE doris sink, support meta column and fix value column. meta: op_ts,database_name,schema_name,table_name; fix value column type: BOOLEAN,INT,TINYINT,BIGINT,DECIMAL,FLOAT,DATE,TIMESTAMP,CHAR,VARCHAR,STRING. eg. 'sink.connector' = 'datastream-doris-ext', 'sink.timezone' = 'Asia/Shanghai', 'sink.additional-columns' = 'database_name:meta@database_name,table_name:meta@table_name,schema_name:meta@schema_name,op_ts:meta@op_ts,SiteCode:VARCHAR@SOME_FIX_TEXT', * Add new sink connector 'datastream-doris-ext' for dlink-client-1.15 Co-authored-by: 's avatarbillyxing <billyxing@ciicsh.com>
parent 9c315b5c
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package com.dlink.cdc; package com.dlink.cdc;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.cdc.doris.DorisExtendSinkBuilder;
import com.dlink.cdc.doris.DorisSinkBuilder; import com.dlink.cdc.doris.DorisSinkBuilder;
import com.dlink.cdc.kafka.KafkaSinkBuilder; import com.dlink.cdc.kafka.KafkaSinkBuilder;
import com.dlink.cdc.kafka.KafkaSinkJsonBuilder; import com.dlink.cdc.kafka.KafkaSinkJsonBuilder;
...@@ -37,11 +38,12 @@ import com.dlink.model.FlinkCDCConfig; ...@@ -37,11 +38,12 @@ import com.dlink.model.FlinkCDCConfig;
public class SinkBuilderFactory { public class SinkBuilderFactory {
private static SinkBuilder[] sinkBuilders = { private static SinkBuilder[] sinkBuilders = {
new KafkaSinkBuilder(), new KafkaSinkBuilder(),
new KafkaSinkJsonBuilder(), new KafkaSinkJsonBuilder(),
new DorisSinkBuilder(), new DorisSinkBuilder(),
new StarrocksSinkBuilder(), new StarrocksSinkBuilder(),
new SQLSinkBuilder() new SQLSinkBuilder(),
new DorisExtendSinkBuilder()
}; };
public static SinkBuilder buildSinkBuilder(FlinkCDCConfig config) { public static SinkBuilder buildSinkBuilder(FlinkCDCConfig config) {
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.dlink.cdc.doris;
import java.io.Serializable;
import java.util.Map;
/**
* @author BillyXing
* @since 2022/11/10 19:37
*/
public class AdditionalColumnEntry<K, V> implements Map.Entry<K, V>, Serializable {
private static final long serialVersionUID = 45678994131L;
private final K k;
private final V v;
private AdditionalColumnEntry(K k, V v) {
this.k = k;
this.v = v;
}
public static <K, V> AdditionalColumnEntry<K, V> of(K k, V v) {
return new AdditionalColumnEntry<K, V>(k, v);
}
@Override
public K getKey() {
return k;
}
@Override
public V getValue() {
return v;
}
@Override
public V setValue(V value) {
throw new UnsupportedOperationException();
}
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.dlink.cdc.doris;
import org.apache.flink.configuration.ConfigOption;
import org.apache.flink.configuration.ConfigOptions;
/**
* @author BillyXing
* @since 2022/11/10 19:37
*/
public class DorisExtendSinkOptions extends DorisSinkOptions {
public static final ConfigOption<String> AdditionalColumns = ConfigOptions.key("additional-columns").stringType()
.noDefaultValue()
.withDescription("Additional columns for sink, support meta column and fix value column."
+ "(meta: op_ts,database_name,schema_name,table_name; "
+ "fix value column type:BOOLEAN,INT,TINYINT,BIGINT,DECIMAL,FLOAT,DATE,TIMESTAMP,CHAR,VARCHAR,STRING)");
}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
package com.dlink.cdc; package com.dlink.cdc;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.cdc.doris.DorisExtendSinkBuilder;
import com.dlink.cdc.doris.DorisSinkBuilder; import com.dlink.cdc.doris.DorisSinkBuilder;
import com.dlink.cdc.kafka.KafkaSinkBuilder; import com.dlink.cdc.kafka.KafkaSinkBuilder;
import com.dlink.cdc.kafka.KafkaSinkJsonBuilder; import com.dlink.cdc.kafka.KafkaSinkJsonBuilder;
...@@ -36,10 +37,11 @@ import com.dlink.model.FlinkCDCConfig; ...@@ -36,10 +37,11 @@ import com.dlink.model.FlinkCDCConfig;
public class SinkBuilderFactory { public class SinkBuilderFactory {
private static SinkBuilder[] sinkBuilders = { private static SinkBuilder[] sinkBuilders = {
new KafkaSinkBuilder(), new KafkaSinkBuilder(),
new KafkaSinkJsonBuilder(), new KafkaSinkJsonBuilder(),
new DorisSinkBuilder(), new DorisSinkBuilder(),
new SQLSinkBuilder() new SQLSinkBuilder(),
new DorisExtendSinkBuilder()
}; };
public static SinkBuilder buildSinkBuilder(FlinkCDCConfig config) { public static SinkBuilder buildSinkBuilder(FlinkCDCConfig config) {
......
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.dlink.cdc.doris;
import java.io.Serializable;
import java.util.Map;
/**
* @author BillyXing
* @since 2022/11/10 19:37
*/
public class AdditionalColumnEntry<K, V> implements Map.Entry<K, V>, Serializable {
private static final long serialVersionUID = 45678994131L;
private final K k;
private final V v;
private AdditionalColumnEntry(K k, V v) {
this.k = k;
this.v = v;
}
public static <K, V> AdditionalColumnEntry<K, V> of(K k, V v) {
return new AdditionalColumnEntry<K, V>(k, v);
}
@Override
public K getKey() {
return k;
}
@Override
public V getValue() {
return v;
}
@Override
public V setValue(V value) {
throw new UnsupportedOperationException();
}
}
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.dlink.cdc.doris;
import org.apache.flink.configuration.ConfigOption;
import org.apache.flink.configuration.ConfigOptions;
/**
* @author BillyXing
* @since 2022/11/10 19:37
*/
public class DorisExtendSinkOptions extends DorisSinkOptions {
public static final ConfigOption<String> AdditionalColumns = ConfigOptions.key("additional-columns").stringType()
.noDefaultValue()
.withDescription("Additional columns for sink, support meta column and fix value column."
+ "(meta: op_ts,database_name,schema_name,table_name; "
+ "fix value column type:BOOLEAN,INT,TINYINT,BIGINT,DECIMAL,FLOAT,DATE,TIMESTAMP,CHAR,VARCHAR,STRING)");
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment