nsivabalan commented on code in PR #8107:
URL: https://github.com/apache/hudi/pull/8107#discussion_r1185674744
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java:
##########
@@ -61,10 +61,11 @@ public class KeyGenUtils {
*/
public static KeyGeneratorType inferKeyGeneratorType(
String recordsKeyFields, String partitionFields) {
+ boolean autoGenerateRecordKeys = recordsKeyFields == null;
if (!StringUtils.isNullOrEmpty(partitionFields)) {
int numPartFields = partitionFields.split(",").length;
- int numRecordKeyFields = recordsKeyFields.split(",").length;
- if (numPartFields == 1 && numRecordKeyFields == 1) {
+ int numRecordKeyFields = autoGenerateRecordKeys ? 0 :
recordsKeyFields.split(",").length;
Review Comment:
yet to address this.
##########
hudi-client/hudi-spark-client/src/main/scala/org/apache/hudi/HoodieDatasetBulkInsertHelper.scala:
##########
@@ -83,8 +87,19 @@ object HoodieDatasetBulkInsertHelper
ReflectionUtils.loadClass(keyGeneratorClassName, new
TypedProperties(config.getProps))
.asInstanceOf[SparkKeyGeneratorInterface]
+ val partitionId = TaskContext.getPartitionId()
+ var rowId = 0
+
iter.map { row =>
- val recordKey = keyGenerator.getRecordKey(row, schema)
+ // auto generate record keys if needed
+ val recordKey = if (autoGenerateRecordKeys) {
+ val recKey = HoodieRecord.generateSequenceId(instantTime,
partitionId, rowId)
+ rowId += 1
+ UTF8String.fromString(recKey)
+ }
+ else { // else use key generator to fetch record key
Review Comment:
yet to fix this
--
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]