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


##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/BaseHoodieWriteClient.java:
##########
@@ -1348,21 +1347,22 @@ public void 
validateAgainstTableProperties(HoodieTableConfig tableConfig, Hoodie
       throw new HoodieException(HoodieTableConfig.POPULATE_META_FIELDS.key() + 
" already disabled for the table. Can't be re-enabled back");
     }
 
-    // Meta fields can be disabled only when either {@code 
SimpleKeyGenerator}, {@code ComplexKeyGenerator},
-    // {@code NonpartitionedKeyGenerator} is used
+    // Meta fields can be disabled only when the number of record key fields 
must be exactly one
     if (!tableConfig.populateMetaFields()) {
-      String keyGenClass = KeyGeneratorType.getKeyGeneratorClassName(new 
HoodieConfig(properties));
-      if (StringUtils.isNullOrEmpty(keyGenClass)) {
-        keyGenClass = "org.apache.hudi.keygen.SimpleKeyGenerator";
+      if (KeyGenUtils.getRecordKeyFields(writeConfig.getProps()).size() >= 2) {
+        throw new HoodieException("When meta fields are not populated, the 
number of record key fields must be exactly one");
       }
-      if (!keyGenClass.equals("org.apache.hudi.keygen.SimpleKeyGenerator")
-          && 
!keyGenClass.equals("org.apache.hudi.keygen.NonpartitionedKeyGenerator")
-          && 
!keyGenClass.equals("org.apache.hudi.keygen.ComplexKeyGenerator")) {
-        throw new HoodieException("Only simple, non-partitioned or complex key 
generator are supported when meta-fields are disabled. Used: " + keyGenClass);
+    }
+
+    // Check if operation metadata fields are allowed
+    if (writeConfig.allowOperationMetadataField()) {
+      if (!writeConfig.populateMetaFields()) {
+        throw new HoodieException("Operation metadata fields are allowed, but 
populateMetaFields is not enabled. "

Review Comment:
   The operation field is introduced to mark the row-level operation type, for 
the use cases where metadata fields are disabled (pure inserts), I think it 
makes sense to also disable the operation field because all the operation types 
should be `I` (insert).



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