Skip to content
Open
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
6 changes: 6 additions & 0 deletions be/src/olap/rowset/segment_v2/column_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ Status ColumnReader::next_batch_of_zone_map(size_t* n, vectorized::MutableColumn
} else {
if (is_string) {
auto sv = (StringRef*)max_value->cell_ptr();
if (type == FieldType::OLAP_FIELD_TYPE_CHAR) {
*sv = sv->trim_tail_padding_zero();
}
dst->insert_data(sv->data, sv->size);
} else {
dst->insert_many_fix_len_data(static_cast<const char*>(max_value->cell_ptr()), 1);
Expand All @@ -476,6 +479,9 @@ Status ColumnReader::next_batch_of_zone_map(size_t* n, vectorized::MutableColumn
} else {
if (is_string) {
auto sv = (StringRef*)min_value->cell_ptr();
if (type == FieldType::OLAP_FIELD_TYPE_CHAR) {
*sv = sv->trim_tail_padding_zero();
}
dst->insert_data_repeatedly(sv->data, sv->size, size);
} else {
// TODO: the work may cause performance problem, opt latter
Expand Down
4 changes: 2 additions & 2 deletions be/src/pipeline/exec/cache_source_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ class CacheSourceLocalState final : public PipelineXLocalState<DataQueueSharedSt
int64_t _version = 0;
std::vector<vectorized::BlockUPtr> _local_cache_blocks;
std::vector<int> _slot_orders;
size_t _current_query_cache_bytes = 0;
size_t _current_query_cache_rows = 0;
int64_t _current_query_cache_bytes = 0;
int64_t _current_query_cache_rows = 0;
bool _need_insert_cache = true;

QueryCacheHandle _query_cache_handle;
Expand Down
11 changes: 11 additions & 0 deletions be/src/vec/common/string_ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ StringRef StringRef::trim() const {
return StringRef(data + begin, end - begin + 1);
}

StringRef StringRef::trim_tail_padding_zero() const {
// Remove trailing padding zero.
int64_t end = size - 1;

while (end >= 0 && data[end] == '\0') {
--end;
}

return StringRef(data, end + 1);
}

StringRef StringRef::trim_whitespace() const {
// Remove leading and trailing whitespace.
int64_t begin = 0;
Expand Down
1 change: 1 addition & 0 deletions be/src/vec/common/string_ref.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ struct StringRef {

// Trims leading and trailing spaces.
StringRef trim() const;
StringRef trim_tail_padding_zero() const;
StringRef trim_whitespace() const;
StringRef trim_quote() const;

Expand Down
Binary file not shown.
Binary file modified regression-test/data/query_p0/aggregate/support_type/min/min.out
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ suite("min") {
qt_min_double """select min(col_double) from d_table;"""

qt_min_char """select min(col_char) from d_table;"""
// Test length(min(col_char)) with different disable_nereids_rules settings
sql "set disable_nereids_rules='';"
qt_min_char_length_default """select length(min(col_char)) from d_table;"""
qt_min_varchar """select min(col_varchar) from d_table;"""
qt_min_string """select min(col_string) from d_table;"""

Expand All @@ -110,4 +113,4 @@ suite("min") {

qt_min_ipv4 """select min(col_ipv4) from d_table;"""
qt_min_ipv6 """select min(col_ipv6) from d_table;"""
}
}
Loading