lvyanquan commented on code in PR #3723:
URL: https://github.com/apache/flink-cdc/pull/3723#discussion_r1920043814


##########
docs/content/docs/connectors/pipeline-connectors/elasticsearch.md:
##########
@@ -164,6 +164,13 @@ Pipeline Connector Options
       <td>Long</td>
       <td>The maximum size of a single record in bytes.</td>
     </tr>
+    <tr>
+      <td>sharding.suffix.key</td>
+      <td>optional</td>
+      <td style="word-wrap: break-word;">(none)</td>
+      <td>Long</td>
+      <td>Sharding suffix key for each table, allow setting sharding suffix 
key for multiTables.Default sink table name is test_table${suffix_key}.Tables 
are separated by ';'.For example, we can set sharding.suffix.key by 
'table1:col1;table2:col2'.</td>

Review Comment:
   Table and column are separated by  `:`.



##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-elasticsearch/src/test/java/org/apache/flink/cdc/connectors/elasticsearch/sink/ElasticsearchEventSerializerTest.java:
##########
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one或多个
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional信息 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或 implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.cdc.connectors.elasticsearch.sink;
+
+import org.apache.flink.api.connector.sink2.SinkWriter;
+import org.apache.flink.cdc.common.data.ZonedTimestampData;
+import org.apache.flink.cdc.common.data.binary.BinaryStringData;
+import org.apache.flink.cdc.common.event.CreateTableEvent;
+import org.apache.flink.cdc.common.event.DataChangeEvent;
+import org.apache.flink.cdc.common.event.TableId;
+import org.apache.flink.cdc.common.schema.Schema;
+import org.apache.flink.cdc.common.types.DataType;
+import org.apache.flink.cdc.common.types.DataTypes;
+import org.apache.flink.cdc.common.types.RowType;
+import 
org.apache.flink.cdc.connectors.elasticsearch.serializer.ElasticsearchEventSerializer;
+import org.apache.flink.cdc.runtime.typeutils.BinaryRecordDataGenerator;
+
+import org.junit.jupiter.api.Test;
+
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.util.HashMap;
+import java.util.Map;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+/** Tests for {@link ElasticsearchEventSerializer}. */
+public class ElasticsearchEventSerializerTest {
+    TableId tableId = TableId.tableId("test");
+
+    @Test
+    void testTableShardingWithString() {
+        HashMap<TableId, String> shardingKey = new HashMap<>();
+        shardingKey.put(tableId, "col1");
+        String index = getShardingString(shardingKey);
+        assertThat(index).isEqualTo("testc-10");
+    }
+
+    @Test
+    void testTableShardingWithInteger() {

Review Comment:
   Please add a test for date type.



##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-elasticsearch/src/main/java/org/apache/flink/cdc/connectors/elasticsearch/serializer/ElasticsearchEventSerializer.java:
##########
@@ -156,6 +164,14 @@ private BulkOperationVariant 
createBulkOperationVariant(DataChangeEvent event)
         }
     }
 
+    public String tableSharding(TableId tableId, Map<String, Object> valueMap) 
{
+        if (shardingKey.containsKey(tableId)) {

Review Comment:
   What about falling back to use the first partition column when partition 
columns was defined though `transform`



-- 
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]

Reply via email to