> For the complete documentation index, see [llms.txt](https://docs.pinot.apache.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pinot.apache.org/functions/string/splitpart.md).

# splitPart

This section contains reference documentation for the splitPart function.

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. Empty fields from leading, consecutive, or trailing delimiters are discarded. If a split limit is reached, the final field contains the unsplit remainder, including any trailing delimiters.

## 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.
* For example, `splitPart('a,b,', ',', -1)` returns `b`, while `splitPart('a,b,', ',', 2, -1)` returns `b,`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
