This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-2.0 in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-2.0 by this push: new d33f1bfa3a0 [Fix](JNI) fix BE core when using JNI to query the empty `map` type value (#31502) (#31908) d33f1bfa3a0 is described below commit d33f1bfa3a090eb1a2db85e051b4487fbbfe752a Author: Tiewei Fang <43782773+bepppo...@users.noreply.github.com> AuthorDate: Thu Mar 7 14:04:40 2024 +0800 [Fix](JNI) fix BE core when using JNI to query the empty `map` type value (#31502) (#31908) backport: #31502 --- be/src/vec/exec/jni_connector.cpp | 10 ++- .../jdbc/test_jni_complex_type.out | 24 ++++++++ .../jdbc/test_jni_complex_type.groovy | 72 ++++++++++++++++++++++ 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/be/src/vec/exec/jni_connector.cpp b/be/src/vec/exec/jni_connector.cpp index 31c401d0dd1..73985b81c71 100644 --- a/be/src/vec/exec/jni_connector.cpp +++ b/be/src/vec/exec/jni_connector.cpp @@ -381,9 +381,6 @@ Status JniConnector::_fill_struct_column(MutableColumnPtr& doris_column, DataTyp } Status JniConnector::_fill_string_column(MutableColumnPtr& doris_column, size_t num_rows) { - if (num_rows == 0) { - return Status::OK(); - } auto& string_col = static_cast<const ColumnString&>(*doris_column); ColumnString::Chars& string_chars = const_cast<ColumnString::Chars&>(string_col.get_chars()); ColumnString::Offsets& string_offsets = @@ -391,6 +388,13 @@ Status JniConnector::_fill_string_column(MutableColumnPtr& doris_column, size_t int* offsets = reinterpret_cast<int*>(_next_meta_as_ptr()); char* chars = reinterpret_cast<char*>(_next_meta_as_ptr()); + // This judgment is necessary, otherwise the following statement `offsets[num_rows - 1]` out of bounds + // What's more, This judgment must be placed after `address.next_meta_as_ptr()` + // because `address.next_meta_as_ptr` will make `address._meta_index` plus 1 + if (num_rows == 0) { + return Status::OK(); + } + size_t origin_chars_size = string_chars.size(); string_chars.resize(origin_chars_size + offsets[num_rows - 1]); memcpy(string_chars.data() + origin_chars_size, chars, offsets[num_rows - 1]); diff --git a/regression-test/data/external_table_p0/jdbc/test_jni_complex_type.out b/regression-test/data/external_table_p0/jdbc/test_jni_complex_type.out new file mode 100644 index 00000000000..bd6c8ead93d --- /dev/null +++ b/regression-test/data/external_table_p0/jdbc/test_jni_complex_type.out @@ -0,0 +1,24 @@ +-- This file is automatically generated. You should know what you did if you want to edit this +-- !sql -- +internal + +-- !sql -- +internal + +-- !inner_tb -- +1 [] doris 18 +2 [] nereids 20 +3 [] yy 19 +4 [] xx 21 +5 [] \N \N + +-- !sql -- +doris_jdbc_catalog_test_jni + +-- !ex_tb1 -- +1 [] doris 18 +2 [] nereids 20 +3 [] yy 19 +4 [] xx 21 +5 [] \N \N + diff --git a/regression-test/suites/external_table_p0/jdbc/test_jni_complex_type.groovy b/regression-test/suites/external_table_p0/jdbc/test_jni_complex_type.groovy new file mode 100644 index 00000000000..977465ca044 --- /dev/null +++ b/regression-test/suites/external_table_p0/jdbc/test_jni_complex_type.groovy @@ -0,0 +1,72 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +suite("test_jni_complex_type", "p0,external,doris,external_docker,external_docker_doris") { + qt_sql """select current_catalog()""" + + String jdbcUrl = context.config.jdbcUrl + "&sessionVariables=return_object_data_as_binary=true" + String jdbcUser = context.config.jdbcUser + String jdbcPassword = context.config.jdbcPassword + String s3_endpoint = getS3Endpoint() + String bucket = getS3BucketName() + String driver_url = "https://${bucket}.${s3_endpoint}/regression/jdbc_driver/mysql-connector-java-8.0.25.jar" + String externalEnvIp = context.config.otherConfigs.get("externalEnvIp") + + + String resource_name = "jdbc_resource_catalog_doris" + String catalog_name = "doris_jdbc_catalog_test_jni"; + String internal_db_name = "regression_test_jdbc_catalog_p0"; + String doris_port = context.config.otherConfigs.get("doris_port"); + String inDorisTable = "test_jni_complex_type"; + String base_table = "base"; + + sql """create database if not exists ${internal_db_name}; """ + + sql """use ${internal_db_name}""" + sql """ drop table if exists ${internal_db_name}.${inDorisTable} """ + sql """ + CREATE TABLE ${internal_db_name}.${inDorisTable} ( + `id` int(11) NULL, + `arr_text` ARRAY<string> NOT NULL, + `name` string NULL, + `age` int(11) NULL + ) DISTRIBUTED BY HASH(id) BUCKETS 10 + PROPERTIES("replication_num" = "1"); + """ + sql """ insert into ${inDorisTable} values (1, [], 'doris', 18);""" + sql """ insert into ${inDorisTable} values (2, [], 'nereids', 20);""" + sql """ insert into ${inDorisTable} values (3, [], 'yy', 19);""" + sql """ insert into ${inDorisTable} values (4, [], 'xx', 21);""" + sql """ insert into ${inDorisTable} values (5, [], null, null);""" + + qt_sql """select current_catalog()""" + order_qt_inner_tb """ select * from internal.${internal_db_name}.${inDorisTable} order by id; """ + + sql """drop catalog if exists ${catalog_name} """ + sql """ CREATE CATALOG `${catalog_name}` PROPERTIES ( + "user" = "${jdbcUser}", + "type" = "jdbc", + "password" = "${jdbcPassword}", + "jdbc_url" = "${jdbcUrl}", + "driver_url" = "${driver_url}", + "driver_class" = "com.mysql.cj.jdbc.Driver" + )""" + sql "switch ${catalog_name}" + qt_sql """select current_catalog()""" + sql """ use ${internal_db_name}""" + order_qt_ex_tb1 """ select * from ${inDorisTable} order by id; """ +} \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org