TyrantLucifer commented on code in PR #2586: URL: https://github.com/apache/incubator-seatunnel/pull/2586#discussion_r970351120
########## seatunnel-connectors-v2/connector-doris/src/main/java/org/apache/seatunnel/connectors/doris/sink/DorisWriter.java: ########## @@ -0,0 +1,98 @@ +/* + * 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 org.apache.seatunnel.connectors.doris.sink; + +import org.apache.seatunnel.api.sink.SinkWriter; +import org.apache.seatunnel.api.table.type.SeaTunnelRow; +import org.apache.seatunnel.api.table.type.SeaTunnelRowType; +import org.apache.seatunnel.common.utils.JsonUtils; +import org.apache.seatunnel.connectors.doris.common.DorisConstants; +import org.apache.seatunnel.connectors.doris.common.DorisOptions; +import org.apache.seatunnel.connectors.doris.sink.loader.DorisStreamLoader; +import org.apache.seatunnel.connectors.seatunnel.common.sink.AbstractSinkWriter; +import org.apache.seatunnel.format.json.JsonSerializationSchema; + +import org.apache.seatunnel.shade.com.typesafe.config.Config; + +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.commons.collections4.CollectionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.time.Instant; +import java.time.ZoneId; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +public class DorisWriter extends AbstractSinkWriter<SeaTunnelRow, Void> { + private static final Logger LOG = LoggerFactory.getLogger(DorisWriter.class); + + private static final String LABEL_TEMPLATE = "setunnel_sink_subtask_%s_%s_%s"; + + private final SeaTunnelRowType seaTunnelRowType; + private final DorisOptions options; + private final JsonSerializationSchema serializationSchema; + private final DorisLoader<String> loader; + + private final List<JsonNode> batch; + private final DateTimeFormatter formatter; + private final SinkWriter.Context context; + + public DorisWriter(Config dorisSinkConf, + SeaTunnelRowType seaTunnelRowType, + SinkWriter.Context context) { + this.seaTunnelRowType = seaTunnelRowType; + this.options = DorisOptions.fromPluginConfig(dorisSinkConf); + this.serializationSchema = new JsonSerializationSchema(seaTunnelRowType); + //now we only support stream load, maybe future broker load will implement in seatunnel. + this.loader = new DorisStreamLoader(options); + this.batch = new ArrayList<>(); + this.formatter = DateTimeFormatter.ofPattern(DorisConstants.DORIS_LABEL_PATTERN_VALUE) + .withZone(ZoneId.systemDefault()); Review Comment: How about making the time zone a configuration item? Some foreign customers may have a foreign time server, but acutally need to save China time in the database. ########## seatunnel-core/seatunnel-flink-starter/src/main/java/org/apache/seatunnel/core/starter/flink/execution/SinkExecuteProcessor.java: ########## @@ -75,7 +75,8 @@ public List<DataStream<Row>> execute(List<DataStream<Row>> upstreamDataStreams) SeaTunnelSink<SeaTunnelRow, Serializable, Serializable, Serializable> seaTunnelSink = plugins.get(i); DataStream<Row> stream = fromSourceTable(sinkConfig).orElse(input); seaTunnelSink.setTypeInfo((SeaTunnelRowType) TypeConverterUtils.convert(stream.getType())); - stream.sinkTo(new FlinkSink<>(seaTunnelSink)); + stream.sinkTo(new FlinkSink<>(seaTunnelSink)).name(seaTunnelSink.getPluginName()) Review Comment: The code is a good optimization point for the whole flink process, but I don't think it should appear in this pr, each pr should have a single responsibility, you should propose another pr to include these changes in it. ########## seatunnel-connectors-v2/connector-doris/pom.xml: ########## @@ -0,0 +1,95 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + + 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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>seatunnel-connectors-v2</artifactId> + <groupId>org.apache.seatunnel</groupId> + <version>${revision}</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>connector-doris</artifactId> + <properties> + <httpclient.version>4.5.13</httpclient.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.seatunnel</groupId> + <artifactId>connector-common</artifactId> + <version>${revision}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>org.apache.seatunnel</groupId> + <artifactId>seatunnel-format-json</artifactId> + <version>${revision}</version> + </dependency> + + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpclient</artifactId> + <version>${httpclient.version}</version> + </dependency> + </dependencies> + + <build> Review Comment: I see you had configured the shade plugin, but it is not actually used in the code, what is the point of doing so? ########## seatunnel-e2e/seatunnel-spark-connector-v2-e2e/connector-doris-spark-e2e/src/test/resources/doris/fakesource_to_doris.conf: ########## @@ -0,0 +1,71 @@ +# +# 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. +# +###### +###### This config file is a demonstration of streaming processing in seatunnel config +###### + +env { Review Comment: Please change the env parameter to spark related parameters. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
