# Split\_part not working as expected

**URL:** <https://community.dremio.com/t/split-part-not-working-as-expected/8206>\
**Category:** Uncategorized\
**Created:** [October 27, 2021, 1:59pm UTC](https://community.dremio.com/t/split-part-not-working-as-expected/8206 "2021-10-27T13:59:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcosllama](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/marcosllama/32/2697_2.png) [@marcosllama](https://community.dremio.com/u/marcosllama)\
**Post date:** [October 27, 2021, 1:59pm UTC](https://community.dremio.com/t/split-part-not-working-as-expected/8206/1 "2021-10-27T13:59:12Z")

</div>

Hello,

According to Dremio documentation in [https://docs.dremio.com/sql-reference/sql-functions/functions/SPLIT\_PART/?parent=all-functions](https://docs.dremio.com/sql-reference/sql-functions/functions/SPLIT_PART/?parent=all-functions) , if part\_number is negative, the parts are counted backwards from the end of the string. However, if I run split\_part(A.A.A,’.’,-1)

I get the following error:

`GandivaException: Index in split_part must be positive, value provided was -1.`

Am I missing something?

Thank you,  
Marcos

---

<div class="post-metadata">

**Author:** ![lenoyjacob](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/lenoyjacob/32/3474_2.png) [@lenoyjacob](https://community.dremio.com/u/lenoyjacob)\
**Post date:** [October 27, 2021, 9:29pm UTC](https://community.dremio.com/t/split-part-not-working-as-expected/8206/2 "2021-10-27T21:29:47Z")

</div>

Sounds like a bug in the documentation? Guessing by the source history at [dremio-oss/StringFunctions.java at master · dremio/dremio-oss · GitHub](https://github.com/dremio/dremio-oss/blob/master/sabot/kernel/src/main/java/com/dremio/exec/expr/fn/impl/StringFunctions.java), the check for the negative integers was present since v1.0.8

A workaround could be to use `REVERSE()`; so something like

```auto
SELECT REVERSE(SPLIT_PART(REVERSE('ab.cd.de'),'.',1));

```

---

<div class="post-metadata">

**Author:** ![Albert\_Vernon](https://sea2.discourse-cdn.com/flex020/user_avatar/community.dremio.com/albert_vernon/32/3744_2.png) [@Albert\_Vernon](https://community.dremio.com/u/Albert_Vernon)\
**Post date:** [November 18, 2021, 11:14pm UTC](https://community.dremio.com/t/split-part-not-working-as-expected/8206/3 "2021-11-18T23:14:49Z")

</div>

Thanks for letting us know. The documentation will be corrected shortly.
