LOCATE (Lakehouse v1)
La première syntaxe renvoie la position de la première occurrence de la sous-chaîne substr dans la chaîne str. La seconde syntaxe renvoie la position de la première occurrence de la sous-chaîne substr dans la chaîne str, en commençant à la position pos. Renvoie 0 si substr ne figure pas dans str. Renvoie NULL si l’un des arguments est NULL.
Syntaxe Analyze
Section intitulée « Syntaxe Analyze »func.locate(<substr>, <str>, <pos>)Exemples Analyze
Section intitulée « Exemples Analyze »func.locate('bar', 'foobarbar')┌────────────────────────────────────┐│ func.locate('bar', 'foobarbar') │├────────────────────────────────────┤│ 5 │└────────────────────────────────────┘func.locate('bar', 'foobarbar', 5)┌────────────────────────────────────┐│ func.locate('bar', 'foobarbar', 5) │├────────────────────────────────────┤│ 7 │└────────────────────────────────────┘Syntaxe SQL
Section intitulée « Syntaxe SQL »LOCATE(<substr>, <str>)LOCATE(<substr>, <str>, <pos>)Arguments
Section intitulée « Arguments »| Arguments | Description |
|---|---|
<substr> |
La sous-chaîne. |
<str> |
La chaîne. |
<pos> |
La position. |
Type de retour
Section intitulée « Type de retour »BIGINT
Exemples SQL
Section intitulée « Exemples SQL »SELECT LOCATE('bar', 'foobarbar')┌────────────────────────────┐│ LOCATE('bar', 'foobarbar') │├────────────────────────────┤│ 4 │└────────────────────────────┘
SELECT LOCATE('xbar', 'foobar')┌──────────────────────────┐│ LOCATE('xbar', 'foobar') │├──────────────────────────┤│ 0 │└──────────────────────────┘
SELECT LOCATE('bar', 'foobarbar', 5)┌───────────────────────────────┐│ LOCATE('bar', 'foobarbar', 5) │├───────────────────────────────┤│ 7 │└───────────────────────────────┘