You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by GitBox <gi...@apache.org> on 2022/08/16 02:45:12 UTC

[GitHub] [inlong] yunqingmoswu commented on a diff in pull request #5503: [INLONG-5041][Sort] Add Apache Doris load node for Sort

yunqingmoswu commented on code in PR #5503:
URL: https://github.com/apache/inlong/pull/5503#discussion_r946288077


##########
inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/node/extract/DorisExtractNode.java:
##########
@@ -0,0 +1,101 @@
+/*
+ * 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.inlong.sort.protocol.node.extract;
+
+import com.google.common.base.Preconditions;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.constant.DorisConstant;
+import org.apache.inlong.sort.protocol.node.ExtractNode;
+import org.apache.inlong.sort.protocol.transformation.WatermarkField;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * doris extract node using doris flink-doris-connector-1.13.5_2.12
+ */
+@EqualsAndHashCode(callSuper = true)
+@JsonTypeName("dorisExtract")
+@Data
+public class DorisExtractNode extends ExtractNode implements Serializable {
+
+    private static final long serialVersionUID = -1369223293553991653L;
+
+    @JsonProperty("fenodes")
+    @Nonnull
+    private String feNodes;
+
+    @JsonProperty("username")
+    @Nonnull
+    private String userName;
+
+    @JsonProperty("password")
+    @Nonnull
+    private String password;
+
+    @JsonProperty("table.identifier")
+    @Nonnull
+    private String tableIdentifier;
+
+    @JsonCreator
+    public DorisExtractNode(@JsonProperty("id") String id,
+                            @JsonProperty("name") String name,
+                            @JsonProperty("fields") List<FieldInfo> fields,
+                            @Nullable @JsonProperty("watermarkField") WatermarkField waterMarkField,
+                            @JsonProperty("properties") Map<String, String> properties,
+                            @JsonProperty("fenodes") @Nonnull String feNodes,
+                            @JsonProperty("username") String userName,
+                            @JsonProperty("password") String password,
+                            @JsonProperty("table.identifier") String tableIdentifier) {
+        super(id, name, fields, waterMarkField, properties);
+        this.feNodes = Preconditions.checkNotNull(feNodes, "fenodes is null");
+        this.userName = Preconditions.checkNotNull(userName, "username is null");
+        this.password = Preconditions.checkNotNull(password, "password is null");
+        this.tableIdentifier = Preconditions.checkNotNull(tableIdentifier, "table.identifier is null");
+    }
+
+    @Override
+    public Map<String, String> tableOptions() {
+        Map<String, String> options = super.tableOptions();
+        options.put(DorisConstant.CONNECTOR, "doris");
+        options.put(DorisConstant.FE_NODES, feNodes);
+        options.put(DorisConstant.USERNAME, userName);
+        options.put(DorisConstant.PASSWORD, password);
+        options.put(DorisConstant.TABLE_IDENTIFIER, tableIdentifier);
+
+        return options;
+    }
+
+    @Override
+    public String genTableName() {
+        return String.format("table_%s", super.getId());
+    }
+
+    @Override
+    public List<FieldInfo> getPartitionFields() {

Review Comment:
   It is recommend to remove it because of no change between it and the supper class.



##########
inlong-sort/sort-core/src/test/java/org/apache/inlong/sort/parser/DorisExtractToMySqlLoadTest.java:
##########
@@ -0,0 +1,142 @@
+/*
+ *  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.inlong.sort.parser;
+
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.api.EnvironmentSettings;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.test.util.AbstractTestBase;
+import org.apache.inlong.sort.formats.common.DecimalFormatInfo;
+import org.apache.inlong.sort.formats.common.DoubleFormatInfo;
+import org.apache.inlong.sort.formats.common.IntFormatInfo;
+import org.apache.inlong.sort.formats.common.StringFormatInfo;
+import org.apache.inlong.sort.parser.impl.FlinkSqlParser;
+import org.apache.inlong.sort.parser.result.ParseResult;
+import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.GroupInfo;
+import org.apache.inlong.sort.protocol.StreamInfo;
+import org.apache.inlong.sort.protocol.node.Node;
+import org.apache.inlong.sort.protocol.node.extract.DorisExtractNode;
+import org.apache.inlong.sort.protocol.node.load.MySqlLoadNode;
+import org.apache.inlong.sort.protocol.transformation.FieldRelation;
+import org.apache.inlong.sort.protocol.transformation.FilterFunction;
+import org.apache.inlong.sort.protocol.transformation.relation.NodeRelation;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * Test for {@link DorisExtractNode}

Review Comment:
   DorisExtractNode -> DorisLoadNode



##########
inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/node/load/DorisLoadNode.java:
##########
@@ -0,0 +1,118 @@
+/*
+ *  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.inlong.sort.protocol.node.load;
+
+import com.google.common.base.Preconditions;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.constant.DorisConstant;
+import org.apache.inlong.sort.protocol.enums.FilterStrategy;
+import org.apache.inlong.sort.protocol.node.LoadNode;
+import org.apache.inlong.sort.protocol.transformation.FieldRelation;
+import org.apache.inlong.sort.protocol.transformation.FilterFunction;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * doris load node using doris flink-doris-connector-1.13.5_2.11
+ */
+@EqualsAndHashCode(callSuper = true)
+@JsonTypeName("dorisLoadNode")
+@Data
+@NoArgsConstructor
+public class DorisLoadNode extends LoadNode implements Serializable {
+
+    private static final long serialVersionUID = -8002903269814211382L;
+
+    @JsonProperty("fenodes")
+    @Nonnull
+    private String feNodes;
+
+    @JsonProperty("username")
+    @Nonnull
+    private String userName;
+
+    @JsonProperty("password")
+    @Nonnull
+    private String password;
+
+    @JsonProperty("table.identifier")
+    @Nonnull
+    private String tableIdentifier;
+
+    @JsonProperty("primaryKey")
+    private String primaryKey;
+
+    @JsonCreator
+    public DorisLoadNode(@JsonProperty("id") String id,
+                         @JsonProperty("name") String name,
+                         @JsonProperty("fields") List<FieldInfo> fields,
+                         @JsonProperty("fieldRelations") List<FieldRelation> fieldRelations,
+                         @JsonProperty("filters") List<FilterFunction> filters,
+                         @JsonProperty("filterStrategy") FilterStrategy filterStrategy,
+                         @Nullable @JsonProperty("sinkParallelism") Integer sinkParallelism,
+                         @JsonProperty("properties") Map<String, String> properties,
+                         @Nonnull @JsonProperty("fenodes") String feNodes,
+                         @Nonnull @JsonProperty("username") String userName,
+                         @Nonnull @JsonProperty("password") String password,
+                         @Nonnull @JsonProperty("table.identifier") String tableIdentifier,
+                         @JsonProperty("primaryKey") String primaryKey) {
+        super(id, name, fields, fieldRelations, filters, filterStrategy, sinkParallelism, properties);
+        this.feNodes = Preconditions.checkNotNull(feNodes, "fe nodes is null");
+        this.userName = Preconditions.checkNotNull(userName, "username is null");
+        this.password = Preconditions.checkNotNull(password, "password is null");
+        this.tableIdentifier = Preconditions.checkNotNull(tableIdentifier, "table.identifier is null");
+        this.primaryKey = primaryKey;
+    }
+
+    @Override
+    public Map<String, String> tableOptions() {
+        Map<String, String> options = super.tableOptions();
+        options.put(DorisConstant.CONNECTOR, "doris");
+        options.put(DorisConstant.FE_NODES, feNodes);
+        options.put(DorisConstant.USERNAME, userName);
+        options.put(DorisConstant.PASSWORD, password);
+        options.put(DorisConstant.TABLE_IDENTIFIER, tableIdentifier);
+        return options;
+    }
+
+    @Override
+    public String genTableName() {
+        return String.format("table_%s", super.getId());
+    }
+
+    @Override
+    public String getPrimaryKey() {

Review Comment:
   It is recommend to remove it because of no change between it and the supper class.



##########
inlong-sort/sort-common/src/main/java/org/apache/inlong/sort/protocol/node/load/DorisLoadNode.java:
##########
@@ -0,0 +1,118 @@
+/*
+ *  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.inlong.sort.protocol.node.load;
+
+import com.google.common.base.Preconditions;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonCreator;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonProperty;
+import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.constant.DorisConstant;
+import org.apache.inlong.sort.protocol.enums.FilterStrategy;
+import org.apache.inlong.sort.protocol.node.LoadNode;
+import org.apache.inlong.sort.protocol.transformation.FieldRelation;
+import org.apache.inlong.sort.protocol.transformation.FilterFunction;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * doris load node using doris flink-doris-connector-1.13.5_2.11
+ */
+@EqualsAndHashCode(callSuper = true)
+@JsonTypeName("dorisLoadNode")
+@Data
+@NoArgsConstructor
+public class DorisLoadNode extends LoadNode implements Serializable {
+
+    private static final long serialVersionUID = -8002903269814211382L;
+
+    @JsonProperty("fenodes")
+    @Nonnull
+    private String feNodes;
+
+    @JsonProperty("username")
+    @Nonnull
+    private String userName;
+
+    @JsonProperty("password")
+    @Nonnull
+    private String password;
+
+    @JsonProperty("table.identifier")
+    @Nonnull
+    private String tableIdentifier;
+
+    @JsonProperty("primaryKey")
+    private String primaryKey;
+
+    @JsonCreator
+    public DorisLoadNode(@JsonProperty("id") String id,
+                         @JsonProperty("name") String name,
+                         @JsonProperty("fields") List<FieldInfo> fields,
+                         @JsonProperty("fieldRelations") List<FieldRelation> fieldRelations,
+                         @JsonProperty("filters") List<FilterFunction> filters,
+                         @JsonProperty("filterStrategy") FilterStrategy filterStrategy,
+                         @Nullable @JsonProperty("sinkParallelism") Integer sinkParallelism,
+                         @JsonProperty("properties") Map<String, String> properties,
+                         @Nonnull @JsonProperty("fenodes") String feNodes,
+                         @Nonnull @JsonProperty("username") String userName,
+                         @Nonnull @JsonProperty("password") String password,
+                         @Nonnull @JsonProperty("table.identifier") String tableIdentifier,
+                         @JsonProperty("primaryKey") String primaryKey) {
+        super(id, name, fields, fieldRelations, filters, filterStrategy, sinkParallelism, properties);
+        this.feNodes = Preconditions.checkNotNull(feNodes, "fe nodes is null");
+        this.userName = Preconditions.checkNotNull(userName, "username is null");
+        this.password = Preconditions.checkNotNull(password, "password is null");
+        this.tableIdentifier = Preconditions.checkNotNull(tableIdentifier, "table.identifier is null");
+        this.primaryKey = primaryKey;
+    }
+
+    @Override
+    public Map<String, String> tableOptions() {
+        Map<String, String> options = super.tableOptions();
+        options.put(DorisConstant.CONNECTOR, "doris");
+        options.put(DorisConstant.FE_NODES, feNodes);
+        options.put(DorisConstant.USERNAME, userName);
+        options.put(DorisConstant.PASSWORD, password);
+        options.put(DorisConstant.TABLE_IDENTIFIER, tableIdentifier);
+        return options;
+    }
+
+    @Override
+    public String genTableName() {
+        return String.format("table_%s", super.getId());
+    }
+
+    @Override
+    public String getPrimaryKey() {
+        return super.getPrimaryKey();
+    }
+
+    @Override
+    public List<FieldInfo> getPartitionFields() {

Review Comment:
   It is recommend to remove it  because of no change between it and the supper class.



##########
inlong-sort/sort-core/src/test/java/org/apache/inlong/sort/parser/DorisExtractToDorisLoadTest.java:
##########
@@ -0,0 +1,147 @@
+/*
+ *  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.inlong.sort.parser;
+
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.api.EnvironmentSettings;
+import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
+import org.apache.flink.test.util.AbstractTestBase;
+import org.apache.inlong.sort.formats.common.DecimalFormatInfo;
+import org.apache.inlong.sort.formats.common.DoubleFormatInfo;
+import org.apache.inlong.sort.formats.common.IntFormatInfo;
+import org.apache.inlong.sort.formats.common.StringFormatInfo;
+import org.apache.inlong.sort.parser.impl.FlinkSqlParser;
+import org.apache.inlong.sort.parser.result.ParseResult;
+import org.apache.inlong.sort.protocol.FieldInfo;
+import org.apache.inlong.sort.protocol.GroupInfo;
+import org.apache.inlong.sort.protocol.StreamInfo;
+import org.apache.inlong.sort.protocol.enums.FilterStrategy;
+import org.apache.inlong.sort.protocol.node.Node;
+import org.apache.inlong.sort.protocol.node.extract.DorisExtractNode;
+import org.apache.inlong.sort.protocol.node.load.DorisLoadNode;
+import org.apache.inlong.sort.protocol.transformation.FieldRelation;
+import org.apache.inlong.sort.protocol.transformation.FilterFunction;
+import org.apache.inlong.sort.protocol.transformation.relation.NodeRelation;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Collections;
+import java.util.stream.Collectors;
+
+/**
+ * Test for {@link DorisExtractNode}

Review Comment:
   DorisExtractNode -> DorisLoadNode



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org