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


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/table/catalog/HoodieCatalog.java:
##########
@@ -303,6 +306,21 @@ public void createTable(ObjectPath tablePath, 
CatalogBaseTable catalogTable, boo
     options.put(TableOptionProperties.PK_CONSTRAINT_NAME, 
resolvedSchema.getPrimaryKey().get().getName());
     options.put(TableOptionProperties.PK_COLUMNS, pkColumns);
 
+    // check preCombine
+    final String preCombineField = 
conf.getString(FlinkOptions.PRECOMBINE_FIELD);
+    if (!resolvedSchema.getColumnNames().contains(preCombineField)) {
+      if (OptionsResolver.isDefaultHoodieRecordPayloadClazz(conf)) {
+        throw new HoodieValidationException("Option '" + 
FlinkOptions.PRECOMBINE_FIELD.key()
+            + "' is required for payload class: " + 
DefaultHoodieRecordPayload.class.getName());
+      }
+      if 
(preCombineField.equals(FlinkOptions.PRECOMBINE_FIELD.defaultValue())) {
+        conf.setString(FlinkOptions.PRECOMBINE_FIELD, 
FlinkOptions.NO_PRE_COMBINE);
+      } else if (!preCombineField.equals(FlinkOptions.NO_PRE_COMBINE)) {
+        throw new HoodieValidationException("Field " + preCombineField + " 
does not exist in the table schema."
+            + "Please check '" + FlinkOptions.PRECOMBINE_FIELD.key() + "' 
option.");
+      }

Review Comment:
   Found duplicate code snippet in `HoodieTableFactory`, let's see whether we 
can move that into a common utils. We can address that in another JIRA though ~



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