Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](jni_connector) fix that be core when jni_connector open fails #37697

Merged
merged 2 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion be/src/vec/exec/jni_connector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ Status JniConnector::get_table_schema(std::string& table_schema_str) {

std::map<std::string, std::string> JniConnector::get_statistics(JNIEnv* env) {
jobject metrics = env->CallObjectMethod(_jni_scanner_obj, _jni_scanner_get_statistics);
jthrowable exc = (env)->ExceptionOccurred();
if (exc != nullptr) {
LOG(WARNING) << "get_statistics has error: "
<< JniUtil::GetJniExceptionMsg(env).to_string();
env->DeleteLocalRef(metrics);
return std::map<std::string, std::string> {};
}
std::map<std::string, std::string> result = JniUtil::convert_to_cpp_map(env, metrics);
env->DeleteLocalRef(metrics);
return result;
Expand All @@ -163,7 +170,7 @@ Status JniConnector::close() {
if (!_closed) {
JNIEnv* env = nullptr;
RETURN_IF_ERROR(JniUtil::GetJNIEnv(&env));
if (_scanner_opened) {
if (_scanner_opened && _jni_scanner_obj != nullptr) {
// _fill_block may be failed and returned, we should release table in close.
// org.apache.doris.common.jni.JniScanner#releaseTable is idempotent
env->CallVoidMethod(_jni_scanner_obj, _jni_scanner_release_table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ public TrinoConnectorJniScanner(int batchSize, Map<String, String> params) {
catalogNameString = params.get("catalog_name");
super.batchSize = batchSize;
super.fields = params.get("required_fields").split(",");
appendDataTimeNs = new long[fields.length];

connectorSplitString = params.get("trino_connector_split");
connectorTableHandleString = params.get("trino_connector_table_handle");
Expand Down
Loading