nsivabalan commented on a change in pull request #3306:
URL: https://github.com/apache/hudi/pull/3306#discussion_r675265397



##########
File path: 
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/action/commit/BaseSparkCommitActionExecutor.java
##########
@@ -94,6 +101,18 @@ public BaseSparkCommitActionExecutor(HoodieEngineContext 
context,
                                        WriteOperationType operationType,
                                        Option extraMetadata) {
     super(context, config, table, instantTime, operationType, extraMetadata);
+    initKeyGenIfNeeded();
+  }
+
+  private void initKeyGenIfNeeded() {
+    this.populateMetaFields = config.populateMetaFields();
+    if (!populateMetaFields) {
+      try {
+        keyGeneratorOpt = Option.of((BaseKeyGenerator) 
HoodieSparkKeyGeneratorFactory.createKeyGenerator(new 
TypedProperties(config.getProps())));
+      } catch (IOException e) {
+        throw new HoodieIOException("Only BaseKeyGenerators are supported when 
meta columns are disabled ", e);

Review comment:
       not very sure on this. Did you mean to suggest to move this to the 
caller of this method or within 
HoodieSparkKeyGeneratorFactory.createKeyGenerator. 
   Bcoz, we have two constructors and to avoid duplicate code, I am doing this 
in private method. 
   Also, we can't move it within 
HoodieSparkKeyGeneratorFactory.createKeyGenerator, bcoz, here we are casting it 
to BaseKeyGenerator since, if meta fields are disabled, we have some 
constraints around keygens. 




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