danny0405 commented on code in PR #12225:
URL: https://github.com/apache/hudi/pull/12225#discussion_r1835870185


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/catalog/HoodieHiveCatalog.java:
##########
@@ -978,6 +983,34 @@ private Map<String, String> supplementOptions(
     }
   }
 
+  public void validateParameter(CatalogBaseTable table) {
+    Map<String, String> properties = new HashMap<>(table.getOptions());
+
+    //check pk
+    if (table.getUnresolvedSchema().getPrimaryKey().isPresent()
+        && properties.containsKey(FlinkOptions.RECORD_KEY_FIELD.key())) {
+      List<String> pks = 
table.getUnresolvedSchema().getPrimaryKey().get().getColumnNames();
+      String[] primaryKeyFromParameter = 
properties.get(FlinkOptions.RECORD_KEY_FIELD.key()).split(",");
+      for (String field : primaryKeyFromParameter) {
+        if (!pks.contains(field)) {
+          throw new HoodieValidationException("Failed to create table, please 
check primary key statement and parameter " + 
FlinkOptions.RECORD_KEY_FIELD.key());

Review Comment:
   Can we report it as "Primary key fields definition has inconsistency between 
pk statement and option '$option_name'".
   
   What about the case when a field in included in option but not the pk 
statement?



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