[improvement](jdbc) add default jdbc driver's dir (#15346)
Add a new config "jdbc_drivers_dir" for both FE and BE. User can put jdbc drivers' jar file in this dir, and only specify file name in "driver_url" properties when creating jdbc resource. And Doris will find jar files in this dir. Also modify the logic so that when the jdbc resource is modified, the corresponding jdbc table will get the latest properties.
This commit is contained in:
@ -327,9 +327,11 @@ Status UserFunctionCache::_download_lib(const std::string& url, UserFunctionCach
|
||||
return Status::InternalError("fail to open file");
|
||||
}
|
||||
|
||||
std::string real_url = _get_real_url(url);
|
||||
|
||||
Md5Digest digest;
|
||||
HttpClient client;
|
||||
RETURN_IF_ERROR(client.init(url));
|
||||
RETURN_IF_ERROR(client.init(real_url));
|
||||
Status status;
|
||||
auto download_cb = [&status, &tmp_file, &fp, &digest](const void* data, size_t length) {
|
||||
digest.update(data, length);
|
||||
@ -367,6 +369,13 @@ Status UserFunctionCache::_download_lib(const std::string& url, UserFunctionCach
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
std::string UserFunctionCache::_get_real_url(const std::string& url) {
|
||||
if (url.find(":/") == std::string::npos) {
|
||||
return "file://" + config::jdbc_drivers_dir + "/" + url;
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
// entry's lock must be held
|
||||
Status UserFunctionCache::_load_cache_entry_internal(UserFunctionCacheEntry* entry) {
|
||||
RETURN_IF_ERROR(dynamic_open(entry->lib_file.c_str(), &entry->lib_handle));
|
||||
|
||||
Reference in New Issue
Block a user