MyLanPangzi commented on a change in pull request #2904:
URL: https://github.com/apache/hudi/pull/2904#discussion_r627092281



##########
File path: 
hudi-flink/src/main/java/org/apache/hudi/table/HoodieTableFactory.java
##########
@@ -98,6 +102,33 @@ public String factoryIdentifier() {
   //  Utilities
   // -------------------------------------------------------------------------
 
+  /** Validate required options. e.g record key and pre combine key.
+   *
+   * @param conf The table options
+   * @param schema The table schema
+   */
+  private void validateRequiredOptions(Configuration conf, TableSchema schema) 
{
+    List<String> fields = 
Arrays.stream(schema.getFieldNames()).collect(Collectors.toList());
+
+    // validate record key in pk absence.
+    if (!schema.getPrimaryKey().isPresent()) {
+      Arrays.stream(conf.get(FlinkOptions.RECORD_KEY_FIELD).split(","))
+              .filter(field -> !fields.contains(field))
+              .findAny()
+              .ifPresent(e -> {
+                throw new ValidationException("The " + e + " field not exists 
in table schema."
+                        + "Please define primary key or modify 
hoodie.datasource.write.recordkey.field option.");
+              });
+    }
+
+    // validate pre combine key

Review comment:
       oh, i will add ut for this.
   but the spark test seems occur error.




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