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

zykkk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 3e4ee3c1e6 [fix](jdbc catalog) fix jdbc driver cache load error 
(#23656)
3e4ee3c1e6 is described below

commit 3e4ee3c1e67a7cfb99f0c16ab03fa6077328e363
Author: zy-kkk <zhongy...@gmail.com>
AuthorDate: Thu Aug 31 10:17:15 2023 +0800

    [fix](jdbc catalog) fix jdbc driver cache load error (#23656)
    
    log error:
    `W20230830 11:19:47.495721 3046231 status.h:363] meet error status: 
[INTERNAL_ERROR]user function's name should be 
function_id.checksum[.file_name].file_type, now the all split parts are by 
delimiter(.): 
7119053928154065546.20c8228267b6c9ce620fddb39467d3eb.postgresql-42.5.0.jar`
    
    When the jdbc driver had `.` in its name we failed to split it properly
---
 be/src/runtime/user_function_cache.cpp       | 25 ++++++++++++++++++++++++-
 be/src/runtime/user_function_cache.h         |  1 +
 be/test/runtime/user_function_cache_test.cpp | 28 ++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/be/src/runtime/user_function_cache.cpp 
b/be/src/runtime/user_function_cache.cpp
index 9edc4dbd46..39507ec222 100644
--- a/be/src/runtime/user_function_cache.cpp
+++ b/be/src/runtime/user_function_cache.cpp
@@ -151,7 +151,7 @@ Status UserFunctionCache::_load_entry_from_lib(const 
std::string& dir, const std
                 file);
     }
 
-    std::vector<std::string> split_parts = strings::Split(file, ".");
+    std::vector<std::string> split_parts = _split_string_by_checksum(file);
     if (split_parts.size() != 3 && split_parts.size() != 4) {
         return Status::InternalError(
                 "user function's name should be 
function_id.checksum[.file_name].file_type, now "
@@ -379,4 +379,27 @@ Status UserFunctionCache::get_jarpath(int64_t fid, const 
std::string& url,
     return Status::OK();
 }
 
+std::vector<std::string> UserFunctionCache::_split_string_by_checksum(const 
std::string& file) {
+    std::vector<std::string> result;
+
+    // Find the first dot from the start
+    size_t firstDot = file.find('.');
+    if (firstDot == std::string::npos) return {};
+
+    // Find the second dot starting from the first dot's position
+    size_t secondDot = file.find('.', firstDot + 1);
+    if (secondDot == std::string::npos) return {};
+
+    // Find the last dot from the end
+    size_t lastDot = file.rfind('.');
+    if (lastDot == std::string::npos || lastDot <= secondDot) return {};
+
+    // Split based on these dots
+    result.push_back(file.substr(0, firstDot));
+    result.push_back(file.substr(firstDot + 1, secondDot - firstDot - 1));
+    result.push_back(file.substr(secondDot + 1, lastDot - secondDot - 1));
+    result.push_back(file.substr(lastDot + 1));
+
+    return result;
+}
 } // namespace doris
diff --git a/be/src/runtime/user_function_cache.h 
b/be/src/runtime/user_function_cache.h
index e58f02294b..5d1bff8b86 100644
--- a/be/src/runtime/user_function_cache.h
+++ b/be/src/runtime/user_function_cache.h
@@ -74,6 +74,7 @@ private:
 
     std::string _get_real_url(const std::string& url);
     std::string _get_file_name_from_url(const std::string& url) const;
+    std::vector<std::string> _split_string_by_checksum(const std::string& 
file);
 
 private:
     std::string _lib_dir;
diff --git a/be/test/runtime/user_function_cache_test.cpp 
b/be/test/runtime/user_function_cache_test.cpp
index be1705ba9a..b9a4694982 100644
--- a/be/test/runtime/user_function_cache_test.cpp
+++ b/be/test/runtime/user_function_cache_test.cpp
@@ -16,3 +16,31 @@
 // under the License.
 
 #include "runtime/user_function_cache.h"
+
+#include <gtest/gtest-message.h>
+#include <gtest/gtest-test-part.h>
+
+#include <string>
+
+#include "gtest/gtest.h"
+
+namespace doris {
+
+class UserFunctionCacheTest : public ::testing::Test {
+protected:
+    UserFunctionCache ufc;
+};
+
+TEST_F(UserFunctionCacheTest, SplitStringByChecksumTest) {
+    // Test valid string format
+    std::string valid_str =
+            
"7119053928154065546.20c8228267b6c9ce620fddb39467d3eb.postgresql-42.5.0.jar";
+    auto result = ufc._split_string_by_checksum(valid_str);
+    ASSERT_EQ(result.size(), 4);
+    EXPECT_EQ(result[0], "7119053928154065546");
+    EXPECT_EQ(result[1], "20c8228267b6c9ce620fddb39467d3eb");
+    EXPECT_EQ(result[2], "postgresql-42.5.0");
+    EXPECT_EQ(result[3], "jar");
+}
+
+} // namespace doris


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to