diff --git a/docs/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md b/docs/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md new file mode 100644 index 0000000000000..d3cc1f5029787 --- /dev/null +++ b/docs/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md @@ -0,0 +1,33 @@ +--- +title: HAMMING_DISTANCE +--- + +## Description +The `HAMMING_DISTANCE` function returns the number of positions at which two strings of equal length differ. + +This function counts characters in UTF-8. + +## Syntax +```sql +HAMMING_DISTANCE(, ) +``` + +## Parameters +| Parameter | Description | +| -- | -- | +| `` | First string | +| `` | Second string | + +## Return Value +Returns a BIGINT value. + +## Examples +```sql +SELECT hamming_distance('karolin', 'kathrin'); -- 3 +SELECT hamming_distance('数据库', '数据仓'); -- 1 +``` + +## Notes +- The two strings must have the same length. Otherwise, an error is returned. +- Supports UTF-8 characters. +- NULL input returns NULL. diff --git a/docs/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md b/docs/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md new file mode 100644 index 0000000000000..9c161ed4c043b --- /dev/null +++ b/docs/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md @@ -0,0 +1,33 @@ +--- +title: LEVENSHTEIN +--- + +## Description +The `LEVENSHTEIN` function returns the Levenshtein edit distance between two strings. +The distance is the minimum number of single-character insertions, deletions, or substitutions required to transform one string into the other. + +This function counts characters in UTF-8. + +## Syntax +```sql +LEVENSHTEIN(, ) +``` + +## Parameters +| Parameter | Description | +| -- | -- | +| `` | First string | +| `` | Second string | + +## Return Value +Returns an INT value. + +## Examples +```sql +SELECT levenshtein('kitten', 'sitting'); -- 3 +SELECT levenshtein('数据库', '数据'); -- 1 +``` + +## Notes +- Supports UTF-8 characters. +- NULL input returns NULL. diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md new file mode 100644 index 0000000000000..64a2136352df1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md @@ -0,0 +1,33 @@ +--- +title: HAMMING_DISTANCE +--- + +## 描述 +`HAMMING_DISTANCE` 函数用于计算两个**等长字符串**在对应位置上不同字符的个数。 + +该函数按 UTF-8 字符计数。 + +## 语法 +```sql +HAMMING_DISTANCE(, ) +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 第一个字符串 | +| `` | 第二个字符串 | + +## 返回值 +返回 BIGINT。 + +## 示例 +```sql +SELECT hamming_distance('karolin', 'kathrin'); -- 3 +SELECT hamming_distance('数据库', '数据仓'); -- 1 +``` + +## 说明 +- 两个字符串必须长度一致,否则会报错。 +- 支持 UTF-8 字符。 +- 任意参数为 NULL 时返回 NULL。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md new file mode 100644 index 0000000000000..bbd1eb5d93fd1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md @@ -0,0 +1,33 @@ +--- +title: LEVENSHTEIN +--- + +## 描述 +`LEVENSHTEIN` 函数用于计算两个字符串之间的编辑距离。 +编辑距离是把一个字符串变成另一个字符串所需的最少单字符插入、删除或替换次数。 + +该函数按 UTF-8 字符计数。 + +## 语法 +```sql +LEVENSHTEIN(, ) +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 第一个字符串 | +| `` | 第二个字符串 | + +## 返回值 +返回 INT。 + +## 示例 +```sql +SELECT levenshtein('kitten', 'sitting'); -- 3 +SELECT levenshtein('数据库', '数据'); -- 1 +``` + +## 说明 +- 支持 UTF-8 字符。 +- 任意参数为 NULL 时返回 NULL。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md new file mode 100644 index 0000000000000..64a2136352df1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md @@ -0,0 +1,33 @@ +--- +title: HAMMING_DISTANCE +--- + +## 描述 +`HAMMING_DISTANCE` 函数用于计算两个**等长字符串**在对应位置上不同字符的个数。 + +该函数按 UTF-8 字符计数。 + +## 语法 +```sql +HAMMING_DISTANCE(, ) +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 第一个字符串 | +| `` | 第二个字符串 | + +## 返回值 +返回 BIGINT。 + +## 示例 +```sql +SELECT hamming_distance('karolin', 'kathrin'); -- 3 +SELECT hamming_distance('数据库', '数据仓'); -- 1 +``` + +## 说明 +- 两个字符串必须长度一致,否则会报错。 +- 支持 UTF-8 字符。 +- 任意参数为 NULL 时返回 NULL。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md new file mode 100644 index 0000000000000..bbd1eb5d93fd1 --- /dev/null +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md @@ -0,0 +1,33 @@ +--- +title: LEVENSHTEIN +--- + +## 描述 +`LEVENSHTEIN` 函数用于计算两个字符串之间的编辑距离。 +编辑距离是把一个字符串变成另一个字符串所需的最少单字符插入、删除或替换次数。 + +该函数按 UTF-8 字符计数。 + +## 语法 +```sql +LEVENSHTEIN(, ) +``` + +## 参数 +| 参数 | 说明 | +| -- | -- | +| `` | 第一个字符串 | +| `` | 第二个字符串 | + +## 返回值 +返回 INT。 + +## 示例 +```sql +SELECT levenshtein('kitten', 'sitting'); -- 3 +SELECT levenshtein('数据库', '数据'); -- 1 +``` + +## 说明 +- 支持 UTF-8 字符。 +- 任意参数为 NULL 时返回 NULL。 diff --git a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md new file mode 100644 index 0000000000000..d3cc1f5029787 --- /dev/null +++ b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance.md @@ -0,0 +1,33 @@ +--- +title: HAMMING_DISTANCE +--- + +## Description +The `HAMMING_DISTANCE` function returns the number of positions at which two strings of equal length differ. + +This function counts characters in UTF-8. + +## Syntax +```sql +HAMMING_DISTANCE(, ) +``` + +## Parameters +| Parameter | Description | +| -- | -- | +| `` | First string | +| `` | Second string | + +## Return Value +Returns a BIGINT value. + +## Examples +```sql +SELECT hamming_distance('karolin', 'kathrin'); -- 3 +SELECT hamming_distance('数据库', '数据仓'); -- 1 +``` + +## Notes +- The two strings must have the same length. Otherwise, an error is returned. +- Supports UTF-8 characters. +- NULL input returns NULL. diff --git a/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md new file mode 100644 index 0000000000000..9c161ed4c043b --- /dev/null +++ b/versioned_docs/version-4.x/sql-manual/sql-functions/scalar-functions/string-functions/levenshtein.md @@ -0,0 +1,33 @@ +--- +title: LEVENSHTEIN +--- + +## Description +The `LEVENSHTEIN` function returns the Levenshtein edit distance between two strings. +The distance is the minimum number of single-character insertions, deletions, or substitutions required to transform one string into the other. + +This function counts characters in UTF-8. + +## Syntax +```sql +LEVENSHTEIN(, ) +``` + +## Parameters +| Parameter | Description | +| -- | -- | +| `` | First string | +| `` | Second string | + +## Return Value +Returns an INT value. + +## Examples +```sql +SELECT levenshtein('kitten', 'sitting'); -- 3 +SELECT levenshtein('数据库', '数据'); -- 1 +``` + +## Notes +- Supports UTF-8 characters. +- NULL input returns NULL. diff --git a/versioned_sidebars/version-4.x-sidebars.json b/versioned_sidebars/version-4.x-sidebars.json index 33f6c724640a7..b6a7d79456e80 100644 --- a/versioned_sidebars/version-4.x-sidebars.json +++ b/versioned_sidebars/version-4.x-sidebars.json @@ -1330,6 +1330,7 @@ "sql-manual/sql-functions/scalar-functions/string-functions/first-significant-subdomain", "sql-manual/sql-functions/scalar-functions/string-functions/format", "sql-manual/sql-functions/scalar-functions/string-functions/format-number", + "sql-manual/sql-functions/scalar-functions/string-functions/hamming_distance", "sql-manual/sql-functions/scalar-functions/string-functions/hex", "sql-manual/sql-functions/scalar-functions/string-functions/initcap", "sql-manual/sql-functions/scalar-functions/string-functions/instr", @@ -1337,6 +1338,7 @@ "sql-manual/sql-functions/scalar-functions/string-functions/is-uuid", "sql-manual/sql-functions/scalar-functions/string-functions/lcase", "sql-manual/sql-functions/scalar-functions/string-functions/length", + "sql-manual/sql-functions/scalar-functions/string-functions/levenshtein", "sql-manual/sql-functions/scalar-functions/string-functions/locate", "sql-manual/sql-functions/scalar-functions/string-functions/lpad", "sql-manual/sql-functions/scalar-functions/string-functions/ltrim",