# splitPart

Splits the input string by a delimiter and returns one element from the result.

Pinot supports both `splitPart(str, delimiter, index)` and `splitPart(str, delimiter, limit, index)`. The snake-case alias `split_part(...)` is also accepted. The index is 0-based. Negative indices count from the end of the split result.

## Signature

```sql
splitPart(str, delimiter, index)
splitPart(str, delimiter, limit, index)
```

## Parameters

* `str`: Input string to split.
* `delimiter`: Delimiter used to split the string.
* `index`: 0-based element index. Negative values count from the end.
* `limit`: Optional split limit applied before selecting the element.

## Returns

Returns the selected string element. If the index is out of bounds, Pinot returns the string literal `"null"`.

## Usage examples

These examples are derived from `StringFunctionsTest`.

```sql
SELECT splitPart('org.apache.pinot.common.function', '.', 2) AS value
```

Returns:

```
pinot
```

```sql
SELECT splitPart('org.apache.pinot.common.function', '.', -1) AS value
```

Returns:

```
function
```

```sql
SELECT splitPart('org.apache.pinot.common.function', '.', 3, -3) AS value
```

Returns:

```
org
```

## Notes

* The 4-argument form applies the split limit first and then looks up the requested index.
* Multi-character delimiters are supported.
* Empty input strings return `"null"` when the delimiter is non-empty.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pinot.apache.org/functions/string/splitpart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
