This is an automated email from the ASF dual-hosted git repository.

leaves12138 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/paimon-cpp.git


The following commit(s) were added to refs/heads/main by this push:
     new e595f72  fix(types): make RowKind short string parsing 
case-insensitive (#15)
e595f72 is described below

commit e595f728f0f877725f0f553e740e42a18a114a86
Author: slfan1989 <[email protected]>
AuthorDate: Mon Jun 1 11:28:39 2026 +0800

    fix(types): make RowKind short string parsing case-insensitive (#15)
    
    * fix(types): make RowKind short string parsing case-insensitive
    
    * fix(types): make RowKind short string parsing case-insensitive
---
 src/paimon/common/types/row_kind.cpp      | 19 +++++++++++++++++++
 src/paimon/common/types/row_kind.h        | 14 +-------------
 src/paimon/common/types/row_kind_test.cpp | 12 ++++++++++++
 3 files changed, 32 insertions(+), 13 deletions(-)

diff --git a/src/paimon/common/types/row_kind.cpp 
b/src/paimon/common/types/row_kind.cpp
index 380d219..01b7ee3 100644
--- a/src/paimon/common/types/row_kind.cpp
+++ b/src/paimon/common/types/row_kind.cpp
@@ -21,6 +21,10 @@
 
 #include <cstdint>
 
+#include "fmt/format.h"
+#include "paimon/common/utils/string_utils.h"
+#include "paimon/status.h"
+
 namespace paimon {
 
 const RowKind* RowKind::Insert() {
@@ -43,4 +47,19 @@ const RowKind* RowKind::Delete() {
     return &kDelete;
 }
 
+Result<const RowKind*> RowKind::FromShortString(const std::string& value) {
+    std::string upper_value = StringUtils::ToUpperCase(value);
+    if (upper_value == "+I") {
+        return Insert();
+    } else if (upper_value == "-U") {
+        return UpdateBefore();
+    } else if (upper_value == "+U") {
+        return UpdateAfter();
+    } else if (upper_value == "-D") {
+        return Delete();
+    } else {
+        return Status::Invalid(fmt::format("Unsupported short string {} for 
row kind.", value));
+    }
+}
+
 }  // namespace paimon
diff --git a/src/paimon/common/types/row_kind.h 
b/src/paimon/common/types/row_kind.h
index 48616e2..f6a0cbf 100644
--- a/src/paimon/common/types/row_kind.h
+++ b/src/paimon/common/types/row_kind.h
@@ -121,19 +121,7 @@ class RowKind {
     /// Creates a `RowKind` from the given short string.
     ///
     /// @see #shortString() for mapping of string and `RowKind`.
-    static Result<const RowKind*> FromShortString(const std::string& value) {
-        if (value == "+I") {
-            return Insert();
-        } else if (value == "-U") {
-            return UpdateBefore();
-        } else if (value == "+U") {
-            return UpdateAfter();
-        } else if (value == "-D") {
-            return Delete();
-        } else {
-            return Status::Invalid(fmt::format("Unsupported short string {} 
for row kind.", value));
-        }
-    }
+    static Result<const RowKind*> FromShortString(const std::string& value);
 
  private:
     /// Creates a `RowKind` with the given short string and byte value 
representation
diff --git a/src/paimon/common/types/row_kind_test.cpp 
b/src/paimon/common/types/row_kind_test.cpp
index b0ab0bb..b53dd8d 100644
--- a/src/paimon/common/types/row_kind_test.cpp
+++ b/src/paimon/common/types/row_kind_test.cpp
@@ -43,4 +43,16 @@ TEST(RowKindTest, TestSimple) {
     ASSERT_FALSE(*insert == *delete_kind);
 }
 
+TEST(RowKindTest, TestFromShortStringIgnoresCase) {
+    ASSERT_OK_AND_ASSIGN(const RowKind* insert, 
RowKind::FromShortString("+i"));
+    ASSERT_OK_AND_ASSIGN(const RowKind* update_before, 
RowKind::FromShortString("-u"));
+    ASSERT_OK_AND_ASSIGN(const RowKind* update_after, 
RowKind::FromShortString("+u"));
+    ASSERT_OK_AND_ASSIGN(const RowKind* delete_kind, 
RowKind::FromShortString("-d"));
+
+    ASSERT_EQ(insert, RowKind::Insert());
+    ASSERT_EQ(update_before, RowKind::UpdateBefore());
+    ASSERT_EQ(update_after, RowKind::UpdateAfter());
+    ASSERT_EQ(delete_kind, RowKind::Delete());
+}
+
 }  // namespace paimon::test

Reply via email to