You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by yi...@apache.org on 2022/09/17 22:57:18 UTC
[hudi] branch master updated: [HUDI-4828] Fix the extraction of record keys which may be cut out (#6650)
This is an automated email from the ASF dual-hosted git repository.
yihua pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hudi.git
The following commit(s) were added to refs/heads/master by this push:
new 8dfdd15f89 [HUDI-4828] Fix the extraction of record keys which may be cut out (#6650)
8dfdd15f89 is described below
commit 8dfdd15f89729cca1f3e1c12baa81bf8863fd6b4
Author: y0908105023 <28...@qq.com>
AuthorDate: Sun Sep 18 06:57:12 2022 +0800
[HUDI-4828] Fix the extraction of record keys which may be cut out (#6650)
Co-authored-by: yangshuo3 <ya...@kingsoft.com>
Co-authored-by: Y Ethan Guo <et...@gmail.com>
---
.../src/main/java/org/apache/hudi/keygen/KeyGenUtils.java | 2 +-
.../test/java/org/apache/hudi/keygen/TestKeyGenUtils.java | 13 ++++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java
index fa3c212ee0..d28263574b 100644
--- a/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java
+++ b/hudi-client/hudi-client-common/src/main/java/org/apache/hudi/keygen/KeyGenUtils.java
@@ -74,7 +74,7 @@ public class KeyGenUtils {
public static String[] extractRecordKeys(String recordKey) {
String[] fieldKV = recordKey.split(",");
return Arrays.stream(fieldKV).map(kv -> {
- final String[] kvArray = kv.split(":");
+ final String[] kvArray = kv.split(":", 2);
if (kvArray.length == 1) {
return kvArray[0];
} else if (kvArray[1].equals(NULL_RECORDKEY_PLACEHOLDER)) {
diff --git a/hudi-client/hudi-client-common/src/test/java/org/apache/hudi/keygen/TestKeyGenUtils.java b/hudi-client/hudi-client-common/src/test/java/org/apache/hudi/keygen/TestKeyGenUtils.java
index 82ea37e90b..43f5952e49 100644
--- a/hudi-client/hudi-client-common/src/test/java/org/apache/hudi/keygen/TestKeyGenUtils.java
+++ b/hudi-client/hudi-client-common/src/test/java/org/apache/hudi/keygen/TestKeyGenUtils.java
@@ -27,16 +27,19 @@ public class TestKeyGenUtils {
public void testExtractRecordKeys() {
// test complex key form: field1:val1,field2:val2,...
String[] s1 = KeyGenUtils.extractRecordKeys("id:1");
- Assertions.assertArrayEquals(new String[]{"1"}, s1);
+ Assertions.assertArrayEquals(new String[] {"1"}, s1);
String[] s2 = KeyGenUtils.extractRecordKeys("id:1,id:2");
- Assertions.assertArrayEquals(new String[]{"1", "2"}, s2);
+ Assertions.assertArrayEquals(new String[] {"1", "2"}, s2);
String[] s3 = KeyGenUtils.extractRecordKeys("id:1,id2:__null__,id3:__empty__");
- Assertions.assertArrayEquals(new String[]{"1", null, ""}, s3);
+ Assertions.assertArrayEquals(new String[] {"1", null, ""}, s3);
+
+ String[] s4 = KeyGenUtils.extractRecordKeys("id:ab:cd,id2:ef");
+ Assertions.assertArrayEquals(new String[] {"ab:cd", "ef"}, s4);
// test simple key form: val1
- String[] s4 = KeyGenUtils.extractRecordKeys("1");
- Assertions.assertArrayEquals(new String[]{"1"}, s4);
+ String[] s5 = KeyGenUtils.extractRecordKeys("1");
+ Assertions.assertArrayEquals(new String[] {"1"}, s5);
}
}