wuchong commented on a change in pull request #10536: [FLINK-15191][connectors 
/ kafka]Fix can't create table source for Kafka if watermark or computed column 
is defined.
URL: https://github.com/apache/flink/pull/10536#discussion_r358625904
 
 

 ##########
 File path: 
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/descriptors/SchemaValidatorTest.scala
 ##########
 @@ -163,4 +164,59 @@ class SchemaValidatorTest {
     assertTrue(extractor.equals(new CustomExtractor("f3")))
     
assertTrue(rowtime.getWatermarkStrategy.isInstanceOf[BoundedOutOfOrderTimestamps])
   }
+
+  @Test
+  def testSchemaWithGeneratedColumnAndWatermark(): Unit = {
+    val descriptor = new Schema()
+      .field("f1", DataTypes.STRING)
+      .field("f2", DataTypes.INT)
+      .field("f3", DataTypes.TIMESTAMP(3))
+
+    val properties = new DescriptorProperties()
+    properties.putProperties(descriptor.toProperties)
+    properties.putString("schema.3.name", "generated-column")
+    properties.putString("schema.3.data-type", DataTypes.INT.toString)
+    properties.putString("schema.3.expr", "f2 + 1")
+    properties.putString("schema.watermark.0.rowtime", "f3")
+    properties.putString("schema.watermark.0.strategy.expr", "f3 - INTERVAL 
'5' SECOND")
+    properties.putString("schema.watermark.0.strategy.data-type", 
DataTypes.TIMESTAMP(3).toString)
+
+    new SchemaValidator(true, true, false).validate(properties)
+    val expectd = TableSchema.builder()
+      .field("f1", DataTypes.STRING)
+      .field("f2", DataTypes.INT)
+      .field("f3", DataTypes.TIMESTAMP(3))
+      .build()
+    val schema = SchemaValidator.deriveTableSinkSchema(properties)
+    assertEquals(expectd, schema)
+   }
+
+  @Test(expected = classOf[IllegalStateException])
+  def testSchemaWithMultiWatermark(): Unit = {
 
 Review comment:
   I think we can remove this test, because multiple watermark validatation has 
been covered by the framework (i.e. TableSchema). 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to