wuchong commented on a change in pull request #12885:
URL: https://github.com/apache/flink/pull/12885#discussion_r453632099



##########
File path: 
flink-connectors/flink-connector-elasticsearch6/src/test/java/org/apache/flink/streaming/connectors/elasticsearch/table/Elasticsearch6DynamicSinkITCase.java
##########
@@ -247,6 +247,45 @@ public void testWritingDocumentsNoPrimaryKey() throws 
Exception {
                assertThat(result, equalTo(expectedMap));
        }
 
+       @Test
+       public void testWritingDocumentsWithDynamicIndex() throws Exception {
+               TableSchema schema = TableSchema.builder()
+                       .field("a", DataTypes.BIGINT().notNull())
+                       .field("b", DataTypes.TIMESTAMP().notNull())
+                       .primaryKey("a")
+                       .build();
+               GenericRowData rowData = GenericRowData.of(
+                       1L,
+                       
TimestampData.fromLocalDateTime(LocalDateTime.parse("2012-12-12T12:12:12")));
+
+               String index = "dynamic-index-{b|yyyy-MM-dd}";
+               String myType = "MyType";
+               Elasticsearch6DynamicSinkFactory sinkFactory = new 
Elasticsearch6DynamicSinkFactory();
+
+               SinkFunctionProvider sinkRuntimeProvider = 
(SinkFunctionProvider) sinkFactory.createDynamicTableSink(
+                       context()
+                               .withSchema(schema)
+                               
.withOption(ElasticsearchOptions.INDEX_OPTION.key(), index)
+                               
.withOption(ElasticsearchOptions.DOCUMENT_TYPE_OPTION.key(), myType)
+                               
.withOption(ElasticsearchOptions.HOSTS_OPTION.key(), "http://127.0.0.1:9200";)
+                               
.withOption(ElasticsearchOptions.FLUSH_ON_CHECKPOINT_OPTION.key(), "false")
+                               .build()
+               ).getSinkRuntimeProvider(new MockContext());
+
+               SinkFunction<RowData> sinkFunction = 
sinkRuntimeProvider.createSinkFunction();

Review comment:
       Use DDL for IT case. 




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to