-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
141929: sql: add substring_index built-in function r=spilchen a=spilchen This commit introduces the `substring_index` built-in function, mirroring MySQL's behavior. `substring_index` returns a substring of `input` before `count` occurrences of `delim`. If `count` is positive, the leftmost part is returned. If `count` is negative, the rightmost part is returned. ``` [email protected]:26257/demoapp/db> SELECT substring_index('www.cockroachlabs.com', '.', 2); substring_index --------------------- www.cockroachlabs (1 row) Time: 3ms total (execution 3ms / network 0ms) [email protected]:26257/demoapp/db> SELECT substring_index('www.cockroachlabs.com', '.', -2); substring_index --------------------- cockroachlabs.com (1 row) Time: 1ms total (execution 1ms / network 0ms) ``` [TREQ-900](https://cockroachlabs.atlassian.net/browse/TREQ-900) Epic: none Release note (sql change): Added the `substring_index` built-in function, which extracts a portion of a string based on a specified delimiter and occurrence count, following MySQL behavior. Co-authored-by: Matt Spilchen <[email protected]>
- Loading branch information
Showing
4 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters