YannByron commented on a change in pull request #3936:
URL: https://github.com/apache/hudi/pull/3936#discussion_r747937610
##########
File path:
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/HoodieSparkSqlWriter.scala
##########
@@ -141,7 +145,7 @@ object HoodieSparkSqlWriter {
.setPartitionFields(partitionColumns)
.setPopulateMetaFields(populateMetaFields)
.setRecordKeyFields(hoodieConfig.getString(RECORDKEY_FIELD))
-
.setKeyGeneratorClassProp(hoodieConfig.getString(KEYGENERATOR_CLASS_NAME))
+
.setKeyGeneratorClassProp(HoodieWriterUtils.getRealKeyGenerator(hoodieConfig))
Review comment:
For Spark-SQL, we assign `SqlKeyGenerator` to
`hoodie.datasource.write.keygenerator.class`, and use
`hoodie.sql.origin.keygen.class` to point the real user-defined key generator,
for example `ComplexKeyGenerator`. When persist it to hoodie.properties, we
need to convert to the `real`one in spark-sql scene.
##########
File path:
hudi-spark-datasource/hudi-spark/src/main/scala/org/apache/hudi/HoodieWriterUtils.scala
##########
@@ -102,4 +106,75 @@ object HoodieWriterUtils {
properties.putAll(mapAsJavaMap(parameters))
new HoodieConfig(properties)
}
+
+ def getRealKeyGenerator(hoodieConfig: HoodieConfig): String = {
+ val kg = hoodieConfig.getString(KEYGENERATOR_CLASS_NAME.key())
+ if (classOf[SqlKeyGenerator].getCanonicalName == kg) {
Review comment:
ok
--
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]