geserdugarov commented on code in PR #17994:
URL: https://github.com/apache/hudi/pull/17994#discussion_r2726660888


##########
hudi-flink-datasource/hudi-flink/src/main/java/org/apache/hudi/configuration/OptionsResolver.java:
##########
@@ -151,13 +152,28 @@ public static boolean 
isDefaultHoodieRecordPayloadClazz(Configuration conf) {
     return 
conf.get(FlinkOptions.PAYLOAD_CLASS_NAME).contains(DefaultHoodieRecordPayload.class.getSimpleName());
   }
 
+  /**
+   * Return value of {@link FlinkOptions#RECORD_KEY_FIELD} if it was set,
+   * or throw exception otherwise.
+   */
+  public static String getRecordKeyStrOrFail(Configuration conf) {
+    final String recordKeyStr = conf.get(FlinkOptions.RECORD_KEY_FIELD);
+    if (null == recordKeyStr) {
+      throw new HoodieValidationException("Primary key definition is required, 
"
+          + "use either PRIMARY KEY syntax or option '" + 
FlinkOptions.RECORD_KEY_FIELD.key() + "' to specify.");
+    }
+    return recordKeyStr;
+  }
+
   /**
    * Returns the ordering fields as comma separated string
    * or null if the value is set as {@link FlinkOptions#NO_PRE_COMBINE}.
    */
   public static String getOrderingFieldsStr(Configuration conf) {
     final String orderingFields = conf.get(FlinkOptions.ORDERING_FIELDS);
-    return orderingFields.equals(FlinkOptions.NO_PRE_COMBINE) ? null : 
orderingFields;
+    return null == orderingFields || 
orderingFields.equals(FlinkOptions.NO_PRE_COMBINE)

Review Comment:
   Agree with you, reverted this change.



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