Skip to content

Commit

Permalink
split_part with empty delimiter behaves like postgres in FB 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Hespian authored and arushi-firebolt committed Jan 10, 2024
1 parent 6d4b23d commit a35df37
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions docs/sql_reference/functions-reference/string/split-part.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ great_grand_parent: SQL reference

# SPLIT_PART

Divides a string based on a specified delimiter into an array of substrings. The string in the specified index is returned, with `1` being the first index. If the string separator is empty, the string is divided into an array of single characters.
Divides a string based on a specified delimiter into an array of substrings. The string in the specified index is returned, with `1` being the first index. If the string separator is empty, the string is returned at index `1`.

## Syntax
{: .no_toc}
Expand All @@ -27,7 +27,7 @@ Please note that the order of the arguments is different than the [`SPLIT` funct
| Parameter | Description | Supported input types |
| :---------------| :--------------------------------|:---------------------------- |
| `<string>` | An expression evaluating to a string to be split. | `TEXT` |
| `<delimiter>` | Any character or substring within `<string>`. If `<delimiter>` is an empty string `''`, the `<string>` will be divided into single characters. | `TEXT` |
| `<delimiter>` | Any character or substring within `<string>`. If `<delimiter>` is an empty string `''`, the `<string>` will be returned at index `1`. | `TEXT` |
| `<index>` | The index from which to return the substring. | `INTEGER` |

## Return Type
Expand All @@ -50,9 +50,16 @@ SELECT

**Returns**: `test`

```sql
SELECT
SPLIT_PART('hello world', '', 1 ) AS res;
```

**Returns**: `hello world`

```sql
SELECT
SPLIT_PART('hello world', '', 7 ) AS res;
```

**Returns**: `w`
**Returns**: ``

0 comments on commit a35df37

Please sign in to comment.