From 098e20d9b9bb68ec0281ac1f1a423c1823f972af Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Tue, 5 Nov 2024 11:26:17 +0800 Subject: [PATCH 01/10] translate support second arg longer than the third --- .../functions/string-replace-functions.md | 2 +- src/Functions/translate.cpp | 86 ++++++++++++++----- .../0_stateless/02353_translate.reference | 4 + tests/queries/0_stateless/02353_translate.sql | 7 +- 4 files changed, 74 insertions(+), 25 deletions(-) diff --git a/docs/en/sql-reference/functions/string-replace-functions.md b/docs/en/sql-reference/functions/string-replace-functions.md index 3f50cd24f93..9e2f063dfd7 100644 --- a/docs/en/sql-reference/functions/string-replace-functions.md +++ b/docs/en/sql-reference/functions/string-replace-functions.md @@ -253,7 +253,7 @@ SELECT format('{} {}', 'Hello', 'World') ## translate -Replaces characters in the string `s` using a one-to-one character mapping defined by `from` and `to` strings. `from` and `to` must be constant ASCII strings of the same size. Non-ASCII characters in the original string are not modified. +Replaces characters in the string `s` using a one-to-one character mapping defined by `from` and `to` strings. `from` and `to` must be constant ASCII strings. Non-ASCII characters in the original string are not modified. **Syntax** diff --git a/src/Functions/translate.cpp b/src/Functions/translate.cpp index f7077f99629..97e16020869 100644 --- a/src/Functions/translate.cpp +++ b/src/Functions/translate.cpp @@ -32,18 +32,25 @@ struct TranslateImpl const std::string & map_from, const std::string & map_to) { - if (map_from.size() != map_to.size()) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second and third arguments must be the same length"); + if (map_from.size() < map_to.size()) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second arguments must be equal or longer than the third"); iota(map.data(), map.size(), UInt8(0)); - for (size_t i = 0; i < map_from.size(); ++i) + for (size_t i = 0; i < map_to.size(); ++i) { if (!isASCII(map_from[i]) || !isASCII(map_to[i])) throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second and third arguments must be ASCII strings"); map[map_from[i]] = map_to[i]; } + for (size_t i = map_to.size(); i < map_from.size(); ++i) + { + if (!isASCII(map_from[i])) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second arguments must be ASCII strings"); + + map[map_from[i]] = ascii_upper_bound + 1; + } } static void vector( @@ -70,13 +77,18 @@ struct TranslateImpl while (src < src_end) { - if (*src <= ascii_upper_bound) + if (*src <= ascii_upper_bound && map[*src] != ascii_upper_bound + 1) + { *dst = map[*src]; - else + ++dst; + } + else if (*src > ascii_upper_bound) + { *dst = *src; + ++dst; + } ++src; - ++dst; } /// Technically '\0' can be mapped into other character, @@ -103,13 +115,18 @@ struct TranslateImpl while (src < src_end) { - if (*src <= ascii_upper_bound) + if (*src <= ascii_upper_bound && map[*src] != ascii_upper_bound + 1) + { *dst = map[*src]; - else + ++dst; + } + else if (*src > ascii_upper_bound) + { *dst = *src; + ++dst; + } ++src; - ++dst; } } @@ -131,8 +148,8 @@ struct TranslateUTF8Impl auto map_from_size = UTF8::countCodePoints(reinterpret_cast(map_from.data()), map_from.size()); auto map_to_size = UTF8::countCodePoints(reinterpret_cast(map_to.data()), map_to.size()); - if (map_from_size != map_to_size) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second and third arguments must be the same length"); + if (map_from_size < map_to_size) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second arguments must be equal or longer than third"); iota(map_ascii.data(), map_ascii.size(), UInt32(0)); @@ -141,32 +158,44 @@ struct TranslateUTF8Impl const UInt8 * map_to_ptr = reinterpret_cast(map_to.data()); const UInt8 * map_to_end = map_to_ptr + map_to.size(); - while (map_from_ptr < map_from_end && map_to_ptr < map_to_end) + while (map_from_ptr < map_from_end) { size_t len_from = UTF8::seqLength(*map_from_ptr); - size_t len_to = UTF8::seqLength(*map_to_ptr); std::optional res_from, res_to; if (map_from_ptr + len_from <= map_from_end) res_from = UTF8::convertUTF8ToCodePoint(map_from_ptr, len_from); - if (map_to_ptr + len_to <= map_to_end) - res_to = UTF8::convertUTF8ToCodePoint(map_to_ptr, len_to); - if (!res_from) throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second argument must be a valid UTF-8 string"); - if (!res_to) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Third argument must be a valid UTF-8 string"); + if (map_to_ptr < map_to_end) + { + size_t len_to = UTF8::seqLength(*map_to_ptr); - if (*map_from_ptr <= ascii_upper_bound) - map_ascii[*map_from_ptr] = *res_to; + if (map_to_ptr + len_to <= map_to_end) + res_to = UTF8::convertUTF8ToCodePoint(map_to_ptr, len_to); + + if (!res_to) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Third argument must be a valid UTF-8 string"); + + if (*map_from_ptr <= ascii_upper_bound) + map_ascii[*map_from_ptr] = *res_to; + else + map[*res_from] = *res_to; + + map_to_ptr += len_to; + } else - map[*res_from] = *res_to; + { + if (*map_from_ptr <= ascii_upper_bound) + map_ascii[*map_from_ptr] = max_uint32; + else + map[*res_from] = max_uint32; + } map_from_ptr += len_from; - map_to_ptr += len_to; } } @@ -205,6 +234,12 @@ struct TranslateUTF8Impl if (*src <= ascii_upper_bound) { + if (map_ascii[*src] == max_uint32) + { + src += 1; + continue; + } + size_t dst_len = UTF8::convertCodePointToUTF8(map_ascii[*src], dst, 4); assert(0 < dst_len && dst_len <= 4); @@ -226,6 +261,12 @@ struct TranslateUTF8Impl auto * it = map.find(*src_code_point); if (it != map.end()) { + if (it->getMapped() == max_uint32) + { + src += src_len; + continue; + } + size_t dst_len = UTF8::convertCodePointToUTF8(it->getMapped(), dst, 4); assert(0 < dst_len && dst_len <= 4); @@ -270,6 +311,7 @@ struct TranslateUTF8Impl private: static constexpr auto ascii_upper_bound = '\x7f'; + static constexpr auto max_uint32 = 0xffffffff; }; diff --git a/tests/queries/0_stateless/02353_translate.reference b/tests/queries/0_stateless/02353_translate.reference index 557b5182127..7c4d3c50db0 100644 --- a/tests/queries/0_stateless/02353_translate.reference +++ b/tests/queries/0_stateless/02353_translate.reference @@ -14,3 +14,7 @@ HotelGenev ¿йðՅনй abc abc +abc +abc +内码 +1A2BC diff --git a/tests/queries/0_stateless/02353_translate.sql b/tests/queries/0_stateless/02353_translate.sql index f6f40c4265d..5a261696ebc 100644 --- a/tests/queries/0_stateless/02353_translate.sql +++ b/tests/queries/0_stateless/02353_translate.sql @@ -9,5 +9,8 @@ SELECT translateUTF8(toString(number), '1234567890', 'ዩय𐑿𐐏নՅðй¿ SELECT translate('abc', '', ''); SELECT translateUTF8('abc', '', ''); -SELECT translate('abc', 'Ááéíóúôè', 'aaeiouoe'); -- { serverError BAD_ARGUMENTS } -SELECT translateUTF8('abc', 'efg', ''); -- { serverError BAD_ARGUMENTS } +SELECT translate('abc', 'Ááéíóúôè', 'aaeiouoe'); +SELECT translateUTF8('abc', 'efg', ''); + +SELECT translateUTF8('中文内码', '中文', ''); +SELECT translate('aAbBcC', 'abc', '12'); From e1011929e782c879851a63b6744a1da569cde025 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Thu, 7 Nov 2024 11:29:22 +0800 Subject: [PATCH 02/10] fix test failure --- tests/queries/0_stateless/02353_translate.reference | 1 - tests/queries/0_stateless/02353_translate.sql | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/queries/0_stateless/02353_translate.reference b/tests/queries/0_stateless/02353_translate.reference index 7c4d3c50db0..5c36a029b81 100644 --- a/tests/queries/0_stateless/02353_translate.reference +++ b/tests/queries/0_stateless/02353_translate.reference @@ -15,6 +15,5 @@ HotelGenev abc abc abc -abc 内码 1A2BC diff --git a/tests/queries/0_stateless/02353_translate.sql b/tests/queries/0_stateless/02353_translate.sql index 5a261696ebc..777cc873fd2 100644 --- a/tests/queries/0_stateless/02353_translate.sql +++ b/tests/queries/0_stateless/02353_translate.sql @@ -9,7 +9,7 @@ SELECT translateUTF8(toString(number), '1234567890', 'ዩय𐑿𐐏নՅðй¿ SELECT translate('abc', '', ''); SELECT translateUTF8('abc', '', ''); -SELECT translate('abc', 'Ááéíóúôè', 'aaeiouoe'); +SELECT translate('abc', 'Ááéíóúôè', 'aaeiouoe'); -- { serverError BAD_ARGUMENTS } SELECT translateUTF8('abc', 'efg', ''); SELECT translateUTF8('中文内码', '中文', ''); From ee152f8c534575369a50b93e53fc365747433b9e Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Thu, 7 Nov 2024 16:51:06 +0800 Subject: [PATCH 03/10] fix tests --- src/Functions/translate.cpp | 44 ++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/src/Functions/translate.cpp b/src/Functions/translate.cpp index 97e16020869..9524bd2b787 100644 --- a/src/Functions/translate.cpp +++ b/src/Functions/translate.cpp @@ -32,24 +32,25 @@ struct TranslateImpl const std::string & map_from, const std::string & map_to) { - if (map_from.size() < map_to.size()) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second arguments must be equal or longer than the third"); - iota(map.data(), map.size(), UInt8(0)); - for (size_t i = 0; i < map_to.size(); ++i) + for (size_t i = 0; i < map_from.size(); ++i) { - if (!isASCII(map_from[i]) || !isASCII(map_to[i])) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second and third arguments must be ASCII strings"); + if (i < map_to.size()) + { + if (!isASCII(map_from[i]) || !isASCII(map_to[i])) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second and third arguments must be ASCII strings"); - map[map_from[i]] = map_to[i]; + map[map_from[i]] = map_to[i]; + } + else + map[map_from[i]] = ascii_upper_bound + 1; } - for (size_t i = map_to.size(); i < map_from.size(); ++i) + + for (size_t i = map_from.size(); i < map_to.size(); ++i) { if (!isASCII(map_from[i])) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second arguments must be ASCII strings"); - - map[map_from[i]] = ascii_upper_bound + 1; + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Third arguments must be ASCII strings"); } } @@ -66,10 +67,11 @@ struct TranslateImpl fillMapWithValues(map, map_from, map_to); res_data.resize(data.size()); - res_offsets.assign(offsets); + res_offsets.resize(input_rows_count); UInt8 * dst = res_data.data(); + UInt64 data_size = 0; for (UInt64 i = 0; i < input_rows_count; ++i) { const UInt8 * src = data.data() + offsets[i - 1]; @@ -81,11 +83,13 @@ struct TranslateImpl { *dst = map[*src]; ++dst; + ++data_size; } else if (*src > ascii_upper_bound) { *dst = *src; ++dst; + ++data_size; } ++src; @@ -94,6 +98,8 @@ struct TranslateImpl /// Technically '\0' can be mapped into other character, /// so we need to process '\0' delimiter separately *dst++ = 0; + ++data_size; + res_offsets[i] = data_size; } } @@ -104,6 +110,9 @@ struct TranslateImpl const std::string & map_to, ColumnString::Chars & res_data) { + if (map_from.size() != map_to.size()) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second and third arguments must be the same length"); + std::array map; fillMapWithValues(map, map_from, map_to); @@ -115,18 +124,13 @@ struct TranslateImpl while (src < src_end) { - if (*src <= ascii_upper_bound && map[*src] != ascii_upper_bound + 1) - { + if (*src <= ascii_upper_bound) *dst = map[*src]; - ++dst; - } - else if (*src > ascii_upper_bound) - { + else *dst = *src; - ++dst; - } ++src; + ++dst; } } From be117a1da3caa68c91da6813fe117012e4963406 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Thu, 7 Nov 2024 17:25:31 +0800 Subject: [PATCH 04/10] fix confilic --- src/Functions/translate.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Functions/translate.cpp b/src/Functions/translate.cpp index 9524bd2b787..43236555e7d 100644 --- a/src/Functions/translate.cpp +++ b/src/Functions/translate.cpp @@ -149,12 +149,6 @@ struct TranslateUTF8Impl const std::string & map_from, const std::string & map_to) { - auto map_from_size = UTF8::countCodePoints(reinterpret_cast(map_from.data()), map_from.size()); - auto map_to_size = UTF8::countCodePoints(reinterpret_cast(map_to.data()), map_to.size()); - - if (map_from_size < map_to_size) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second arguments must be equal or longer than third"); - iota(map_ascii.data(), map_ascii.size(), UInt32(0)); const UInt8 * map_from_ptr = reinterpret_cast(map_from.data()); From eaa31d04c1f84eda89b5fa2222b6cb852dc2ea92 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Fri, 8 Nov 2024 11:10:06 +0800 Subject: [PATCH 05/10] fix test --- src/Functions/translate.cpp | 9 +++++++-- tests/queries/0_stateless/02353_translate.reference | 1 + tests/queries/0_stateless/02353_translate.sql | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Functions/translate.cpp b/src/Functions/translate.cpp index 43236555e7d..0d434acc840 100644 --- a/src/Functions/translate.cpp +++ b/src/Functions/translate.cpp @@ -44,13 +44,18 @@ struct TranslateImpl map[map_from[i]] = map_to[i]; } else + { + if (!isASCII(map_from[i])) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second argument must be ASCII strings"); + map[map_from[i]] = ascii_upper_bound + 1; + } } for (size_t i = map_from.size(); i < map_to.size(); ++i) { - if (!isASCII(map_from[i])) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Third arguments must be ASCII strings"); + if (!isASCII(map_to[i])) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Third argument must be ASCII strings"); } } diff --git a/tests/queries/0_stateless/02353_translate.reference b/tests/queries/0_stateless/02353_translate.reference index 5c36a029b81..4106bf9c077 100644 --- a/tests/queries/0_stateless/02353_translate.reference +++ b/tests/queries/0_stateless/02353_translate.reference @@ -17,3 +17,4 @@ abc abc 内码 1A2BC +1A2B3C diff --git a/tests/queries/0_stateless/02353_translate.sql b/tests/queries/0_stateless/02353_translate.sql index 777cc873fd2..99f50c777b0 100644 --- a/tests/queries/0_stateless/02353_translate.sql +++ b/tests/queries/0_stateless/02353_translate.sql @@ -14,3 +14,6 @@ SELECT translateUTF8('abc', 'efg', ''); SELECT translateUTF8('中文内码', '中文', ''); SELECT translate('aAbBcC', 'abc', '12'); + +SELECT translate('aAbBcC', 'abc', '1235'); +SELECT translate('aAbBcC', '中文内码', '12'); -- { serverError BAD_ARGUMENTS } From 39740d2ed95e9527c172452e7dd36af34fbf44d7 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Mon, 11 Nov 2024 10:15:27 +0800 Subject: [PATCH 06/10] some refines --- src/Functions/translate.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Functions/translate.cpp b/src/Functions/translate.cpp index 0d434acc840..5d8d3f52793 100644 --- a/src/Functions/translate.cpp +++ b/src/Functions/translate.cpp @@ -103,8 +103,7 @@ struct TranslateImpl /// Technically '\0' can be mapped into other character, /// so we need to process '\0' delimiter separately *dst++ = 0; - ++data_size; - res_offsets[i] = data_size; + res_offsets[i] = ++data_size; } } From d2b4448fb1f988fea99f69a92e1d702e8d0e1c55 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Fri, 22 Nov 2024 11:21:05 +0800 Subject: [PATCH 07/10] some refines --- .../functions/string-replace-functions.md | 2 +- src/Functions/translate.cpp | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/docs/en/sql-reference/functions/string-replace-functions.md b/docs/en/sql-reference/functions/string-replace-functions.md index 9e2f063dfd7..f8d46cacbdc 100644 --- a/docs/en/sql-reference/functions/string-replace-functions.md +++ b/docs/en/sql-reference/functions/string-replace-functions.md @@ -253,7 +253,7 @@ SELECT format('{} {}', 'Hello', 'World') ## translate -Replaces characters in the string `s` using a one-to-one character mapping defined by `from` and `to` strings. `from` and `to` must be constant ASCII strings. Non-ASCII characters in the original string are not modified. +Replaces characters in the string `s` using a one-to-one character mapping defined by `from` and `to` strings. `from` and `to` must be constant ASCII strings. Non-ASCII characters in the original string are not modified. If the number of characters in `from` list is larger than the `to` list, non overlapping characters will be deleted from the input string. **Syntax** diff --git a/src/Functions/translate.cpp b/src/Functions/translate.cpp index 5d8d3f52793..208232e0aca 100644 --- a/src/Functions/translate.cpp +++ b/src/Functions/translate.cpp @@ -45,10 +45,15 @@ struct TranslateImpl } else { - if (!isASCII(map_from[i])) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second argument must be ASCII strings"); + while (i < map_from.size()) + { + if (!isASCII(map_from[i])) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second argument must be ASCII strings"); - map[map_from[i]] = ascii_upper_bound + 1; + map[map_from[i]] = ascii_upper_bound + 1; + ++i; + } + return; } } From f201119575eef4041dc987d59ab244ec5b6b6e40 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Mon, 2 Dec 2024 12:23:00 +0800 Subject: [PATCH 08/10] refine codes --- src/Functions/translate.cpp | 49 ++++++++----------- .../0_stateless/02353_translate.reference | 1 + tests/queries/0_stateless/02353_translate.sql | 1 + 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/src/Functions/translate.cpp b/src/Functions/translate.cpp index 208232e0aca..1f4ff147a6a 100644 --- a/src/Functions/translate.cpp +++ b/src/Functions/translate.cpp @@ -34,30 +34,26 @@ struct TranslateImpl { iota(map.data(), map.size(), UInt8(0)); - for (size_t i = 0; i < map_from.size(); ++i) + size_t min_size = std::min(map_from.size(), map_to.size()); + + // Map characters from map_from to map_to for the overlapping range + for (size_t i = 0; i < min_size; ++i) { - if (i < map_to.size()) - { - if (!isASCII(map_from[i]) || !isASCII(map_to[i])) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second and third arguments must be ASCII strings"); - - map[map_from[i]] = map_to[i]; - } - else - { - while (i < map_from.size()) - { - if (!isASCII(map_from[i])) - throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second argument must be ASCII strings"); - - map[map_from[i]] = ascii_upper_bound + 1; - ++i; - } - return; - } + if (!isASCII(map_from[i]) || !isASCII(map_to[i])) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second and third arguments must be ASCII strings"); + map[static_cast(map_from[i])] = static_cast(map_to[i]); } - for (size_t i = map_from.size(); i < map_to.size(); ++i) + // Handle any remaining characters in map_from by assigning a default value + for (size_t i = min_size; i < map_from.size(); ++i) + { + if (!isASCII(map_from[i])) + throw Exception(ErrorCodes::BAD_ARGUMENTS, "Second argument must be ASCII strings"); + map[static_cast(map_from[i])] = ascii_upper_bound + 1; + } + + // Validate any extra characters in map_to to ensure they are ASCII + for (size_t i = min_size; i < map_to.size(); ++i) { if (!isASCII(map_to[i])) throw Exception(ErrorCodes::BAD_ARGUMENTS, "Third argument must be ASCII strings"); @@ -91,14 +87,12 @@ struct TranslateImpl { if (*src <= ascii_upper_bound && map[*src] != ascii_upper_bound + 1) { - *dst = map[*src]; - ++dst; + *dst++ = map[*src]; ++data_size; } else if (*src > ascii_upper_bound) { - *dst = *src; - ++dst; + *dst++ = *src; ++data_size; } @@ -268,16 +262,13 @@ struct TranslateUTF8Impl auto * it = map.find(*src_code_point); if (it != map.end()) { + src += src_len; if (it->getMapped() == max_uint32) - { - src += src_len; continue; - } size_t dst_len = UTF8::convertCodePointToUTF8(it->getMapped(), dst, 4); assert(0 < dst_len && dst_len <= 4); - src += src_len; dst += dst_len; data_size += dst_len; continue; diff --git a/tests/queries/0_stateless/02353_translate.reference b/tests/queries/0_stateless/02353_translate.reference index 4106bf9c077..3c448d59ea2 100644 --- a/tests/queries/0_stateless/02353_translate.reference +++ b/tests/queries/0_stateless/02353_translate.reference @@ -18,3 +18,4 @@ abc 内码 1A2BC 1A2B3C +ABC diff --git a/tests/queries/0_stateless/02353_translate.sql b/tests/queries/0_stateless/02353_translate.sql index 99f50c777b0..fd3f48f854d 100644 --- a/tests/queries/0_stateless/02353_translate.sql +++ b/tests/queries/0_stateless/02353_translate.sql @@ -16,4 +16,5 @@ SELECT translateUTF8('中文内码', '中文', ''); SELECT translate('aAbBcC', 'abc', '12'); SELECT translate('aAbBcC', 'abc', '1235'); +SELECT translate('aAbBcC', 'abc', ''); SELECT translate('aAbBcC', '中文内码', '12'); -- { serverError BAD_ARGUMENTS } From 5b8955c2ae249bbe800abe6070e63ae8500b66d2 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Tue, 3 Dec 2024 09:39:05 +0800 Subject: [PATCH 09/10] add a test --- tests/queries/0_stateless/02353_translate.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/queries/0_stateless/02353_translate.sql b/tests/queries/0_stateless/02353_translate.sql index fd3f48f854d..62a4eda0115 100644 --- a/tests/queries/0_stateless/02353_translate.sql +++ b/tests/queries/0_stateless/02353_translate.sql @@ -17,4 +17,5 @@ SELECT translate('aAbBcC', 'abc', '12'); SELECT translate('aAbBcC', 'abc', '1235'); SELECT translate('aAbBcC', 'abc', ''); +SELECT translate('abc', 'abc', ''); SELECT translate('aAbBcC', '中文内码', '12'); -- { serverError BAD_ARGUMENTS } From d735d0f8cd66ca01d8898e81bddf317e43e97651 Mon Sep 17 00:00:00 2001 From: shuai-xu Date: Tue, 3 Dec 2024 10:34:52 +0800 Subject: [PATCH 10/10] add a test --- tests/queries/0_stateless/02353_translate.reference | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/queries/0_stateless/02353_translate.reference b/tests/queries/0_stateless/02353_translate.reference index 3c448d59ea2..16bf6bc6015 100644 --- a/tests/queries/0_stateless/02353_translate.reference +++ b/tests/queries/0_stateless/02353_translate.reference @@ -19,3 +19,4 @@ abc 1A2BC 1A2B3C ABC +