kwondw commented on a change in pull request #1500: [HUDI-772] Make 
UserDefinedBulkInsertPartitioner configurable for DataSource
URL: https://github.com/apache/incubator-hudi/pull/1500#discussion_r407777746
 
 

 ##########
 File path: hudi-spark/src/main/java/org/apache/hudi/DataSourceUtils.java
 ##########
 @@ -152,6 +154,24 @@ public static KeyGenerator 
createKeyGenerator(TypedProperties props) throws IOEx
     }
   }
 
+  /**
+   * Create a UserDefinedBulkInsertPartitioner class via reflection,
+   * <br>
+   * if the class name of UserDefinedBulkInsertPartitioner is configured 
through the HoodieWriteConfig.
+   * @see HoodieWriteConfig#getUserDefinedBulkInsertPartitionerClass()
+   */
+  private static Option<UserDefinedBulkInsertPartitioner> 
createUserDefinedBulkInsertPartitioner(HoodieWriteConfig config)
+          throws IOException {
+    String bulkInsertPartitionerClass = 
config.getUserDefinedBulkInsertPartitionerClass();
+    try {
+      return bulkInsertPartitionerClass == null || 
bulkInsertPartitionerClass.isEmpty()
+              ? Option.empty() :
+              Option.of((UserDefinedBulkInsertPartitioner) 
ReflectionUtils.loadClass(bulkInsertPartitionerClass));
+    } catch (Throwable e) {
+      throw new IOException("Could not create UserDefinedBulkInsertPartitioner 
class " + bulkInsertPartitionerClass, e);
 
 Review comment:
   While I was reading the code of 
[DataSourceUtils](https://github.com/apache/incubator-hudi/blob/master/hudi-spark/src/main/java/org/apache/hudi/DataSourceUtils.java#L58),
 I had the impression that it tries to throw IOException as a configuration 
issue of user's while Hoodie*Exception would means as more toward some sort of 
Hudi internal error.
   
   For example, failed to load of 
```hoodie.datasource.write.keygenerator.class``` class throws as IOException 
from 
[createKeyGenerator](https://github.com/apache/incubator-hudi/blob/master/hudi-spark/src/main/java/org/apache/hudi/DataSourceUtils.java#L151),
 and ```hoodie.datasource.write.payload.class``` too from 
[createPayload](https://github.com/apache/incubator-hudi/blob/master/hudi-spark/src/main/java/org/apache/hudi/DataSourceUtils.java#L164),
 so question is when a user mis-configure as class name, should it be 
considered as "hoodie" error? or general configuration error as user mistake?
   I hope there is specific user configuration exception separately, but I 
wasn't sure the intention of IOException from other configurations, so I 
followed existing ways.
   
   Please let me know if you think this should be HoodieException, I can update 
it.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to