跳转到内容

为字符串生成 Soundex 编码。

  • Soundex 编码由一个字母加三位数字组成。PlaidCloud Lakehouse 的实现返回的数字多于 4 位,但可以对结果使用 SUBSTR 来获得标准 Soundex 编码。
  • 字符串中的所有非字母字符都会被忽略。
  • A-Z 范围之外的所有国际字母字符都会被忽略,除非它们是首字母。

另请参阅:SOUNDS LIKE

func.soundex(<str>)
func.soundex('PlaidCloud Lakehouse')
┌──────────────────────────────────────┐
│ func.soundex('PlaidCloud Lakehouse') │
├──────────────────────────────────────┤
│ D153 │
└──────────────────────────────────────┘
SOUNDEX(<str>)
参数 说明
str 字符串。

返回 VARCHAR 类型的编码或 NULL 值。

SELECT SOUNDEX('PlaidCloud Lakehouse');
---
D153
-- All non-alphabetic characters in the string are ignored.
SELECT SOUNDEX('PlaidCloud Lakehouse!');
---
D153
-- All international alphabetic characters outside the A-Z range are ignored unless they're the first letter.
SELECT SOUNDEX('PlaidCloud Lakehouse,你好');
---
D153
SELECT SOUNDEX('你好,PlaidCloud Lakehouse');
---
你3153
-- SUBSTR the result to get a standard Soundex code.
SELECT SOUNDEX('databend cloud'),SUBSTR(SOUNDEX('databend cloud'),1,4);
soundex('databend cloud')|substring(soundex('databend cloud') from 1 for 4)|
-------------------------+-------------------------------------------------+
D153243 |D153 |
SELECT SOUNDEX(NULL);
┌─────────────────────────────────────┐
│ `SOUNDEX(NULL)` │
├─────────────────────────────────────┤
│ <null> │
└─────────────────────────────────────┘