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_r358044466
 
 

 ##########
 File path: 
flink-table/flink-table-api-java-bridge/src/main/java/org/apache/flink/table/descriptors/SchemaValidator.java
 ##########
 @@ -118,6 +128,33 @@ else if (proctimeFound) {
                                properties.validateExclusion(proctime);
                        }
                }
+
+               validateWatermark(properties);
+       }
+
+       /**
+        * Validate watermarks if exists.
+        */
+       private void validateWatermark(DescriptorProperties properties) {
+               final String schemaWatermarkKey = SCHEMA + "." + WATERMARK;
+               int watermarkRowtimeKeys = 
properties.getIndexedProperty(schemaWatermarkKey, WATERMARK_ROWTIME).size();
+               int watermarkStrategyKeys = 
properties.getIndexedProperty(schemaWatermarkKey, 
WATERMARK_STRATEGY_EXPR).size();
+               int watermarkStrategyDataTypeKeys = 
properties.getIndexedProperty(schemaWatermarkKey, 
WATERMARK_STRATEGY_DATA_TYPE).size();
+
+               if (watermarkRowtimeKeys == 1 && watermarkStrategyKeys == 1 && 
watermarkStrategyDataTypeKeys == 1) {
+                       String watermarkRowtime = schemaWatermarkKey + "." + 0 
+ "." + WATERMARK_ROWTIME;
+                       String watermarkStrategy = schemaWatermarkKey + "." + 0 
+ "." + WATERMARK_STRATEGY_EXPR;
+                       String watermarkStrategyDataType = schemaWatermarkKey + 
"." + 0 + "." + WATERMARK_STRATEGY_DATA_TYPE;
+                       properties.validateString(watermarkRowtime, false, 1);
+                       properties.validateString(watermarkStrategy, false, 1);
+                       properties.validateString(watermarkStrategyDataType, 
false, 1);
+               } else if (watermarkRowtimeKeys == 0 && watermarkStrategyKeys 
== 0 && watermarkStrategyDataTypeKeys == 0) {
+
 
 Review comment:
   Add a comment on the empty code block, e.g. 
   
   ```
   // do nothing if watermark is not defined
   ```

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


With regards,
Apache Git Services

Reply via email to