xushiyan commented on code in PR #5205:
URL: https://github.com/apache/hudi/pull/5205#discussion_r845087195


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/HoodieWriterUtils.scala:
##########
@@ -173,6 +175,29 @@ object HoodieWriterUtils {
     }
   }
 
+  /**
+   * Detects conflicts between datasourceKeyGen and existing table 
configuration keyGen
+   */
+  def validateKeyGeneratorConfig(datasourceKeyGen: String, tableConfig: 
HoodieConfig): Unit = {
+    val diffConfigs = StringBuilder.newBuilder
+
+    if (null != tableConfig) {
+      val tableConfigKeyGen = 
tableConfig.getString(HoodieTableConfig.KEY_GENERATOR_CLASS_NAME)
+      if (null != tableConfigKeyGen && null != datasourceKeyGen) {
+        val nonPartitionedTableConfig = 
tableConfigKeyGen.equals(classOf[NonpartitionedKeyGenerator].getCanonicalName)
+        val simpleKeyDataSourceConfig = 
datasourceKeyGen.equals(classOf[SimpleKeyGenerator].getCanonicalName)
+        if (nonPartitionedTableConfig && simpleKeyDataSourceConfig) {
+          
diffConfigs.append(s"KeyGenerator:\t$datasourceKeyGen\t$tableConfigKeyGen\n")

Review Comment:
   i wonder if there are more case we need to catch here, as this check is very 
specific. What about the cases where users subclassed the built-in keygen ? Is 
there any generic way to prevent discrepancy.



-- 
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: commits-unsubscr...@hudi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to