From cc258ec4c29d8d9f737517b0d5f3d5bd668359dc Mon Sep 17 00:00:00 2001 From: slfan1989 Date: Tue, 26 May 2026 13:05:08 +0800 Subject: [PATCH] fix(types): make RowKind short string parsing case-insensitive --- src/paimon/common/types/row_kind.h | 8 ++++---- src/paimon/common/types/row_kind_test.cpp | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/paimon/common/types/row_kind.h b/src/paimon/common/types/row_kind.h index 48616e2..07c5857 100644 --- a/src/paimon/common/types/row_kind.h +++ b/src/paimon/common/types/row_kind.h @@ -122,13 +122,13 @@ class RowKind { /// /// @see #shortString() for mapping of string and `RowKind`. static Result FromShortString(const std::string& value) { - if (value == "+I") { + if (value == "+I" || value == "+i") { return Insert(); - } else if (value == "-U") { + } else if (value == "-U" || value == "-u") { return UpdateBefore(); - } else if (value == "+U") { + } else if (value == "+U" || value == "+u") { return UpdateAfter(); - } else if (value == "-D") { + } else if (value == "-D" || value == "-d") { return Delete(); } else { return Status::Invalid(fmt::format("Unsupported short string {} for row kind.", value)); 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