[bugfix](dict) fix coredump of dict colum range predicate when there is null value (#11967)

This commit is contained in:
TengJianPing
2022-08-23 16:07:48 +08:00
committed by GitHub
parent 60fddd56e7
commit 55fdb555be
3 changed files with 61 additions and 2 deletions

View File

@ -296,7 +296,7 @@ public:
return -2; // -1 is null code
}
T get_null_code() { return -1; }
T get_null_code() const { return -1; }
inline StringValue& get_value(T code) {
return code >= _dict_data.size() ? _null_value : _dict_data[code];
@ -391,7 +391,12 @@ public:
}
}
T convert_code(const T& code) const { return _code_convert_table[code]; }
T convert_code(const T& code) const {
if (get_null_code() == code) {
return code;
}
return _code_convert_table[code];
}
size_t byte_size() { return _dict_data.size() * sizeof(_dict_data[0]); }

View File

@ -0,0 +1,7 @@
-- This file is automatically generated. You should know what you did if you want to edit this
-- !select_default --
4 d
-- !select_default --
1 a
3 c

View File

@ -0,0 +1,47 @@
// 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_dict_range_predicate") {
def tableName = "test_dict_range_predicate"
sql """ DROP TABLE IF EXISTS ${tableName} """
sql """
CREATE TABLE ${tableName} (
`a` int,
`b` char(10)
) ENGINE=OLAP
DUPLICATE KEY(`a`)
DISTRIBUTED BY HASH(`a`) BUCKETS 4
PROPERTIES (
"replication_allocation" = "tag.location.default: 1",
"in_memory" = "false",
"storage_format" = "V2"
);
"""
sql "insert into ${tableName} values (1, 'a'), (2, null), (3, 'c'), (4, 'd');"
qt_select_default """
select *
from ${tableName} WHERE b > 'c' order by a
"""
qt_select_default """
select *
from ${tableName} WHERE b <= 'c' order by a
"""
}