> ## Documentation Index
> Fetch the complete documentation index at: https://docs.firebolt.io/llms.txt
> Use this file to discover all available pages before exploring further.

# String functions

> Spark string functions supported in SparkSQL and Databricks compatibility modes.

Preview

Spark [string](https://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#string-functions) and [URL](https://spark.apache.org/docs/latest/sql-ref-functions-builtin.html#url-functions) functions in [SparkSQL and Databricks compatibility modes](https://docs.firebolt.io/reference-sql/spark/overview.md). Both modes share these functions. Support is one of: Supported, With limitations, or Not supported. Supported means every example in the Spark reference returns what Spark returns; a note under With limitations quotes a call that differs.

## String functions

| Function | Support | Notes |
| :- | :- | :- |
| [`BASE64`](https://spark.apache.org/docs/4.1.0/api/sql/#base64) | Supported | |
| [`BIT_LENGTH`](https://spark.apache.org/docs/4.1.0/api/sql/#bit_length) | Supported | |
| [`ELT`](https://spark.apache.org/docs/4.1.0/api/sql/#elt) | Supported | |
| [`INSTR`](https://spark.apache.org/docs/4.1.0/api/sql/#instr) | Supported | |
| [`LCASE`](https://spark.apache.org/docs/4.1.0/api/sql/#lcase) | Supported | |
| [`LEN`](https://spark.apache.org/docs/4.1.0/api/sql/#len) | Supported | |
| [`LENGTH`](https://spark.apache.org/docs/4.1.0/api/sql/#length) | Supported | |
| [`LOWER`](https://spark.apache.org/docs/4.1.0/api/sql/#lower) | Supported | |
| [`LTRIM`](https://spark.apache.org/docs/4.1.0/api/sql/#ltrim) | Supported | |
| [`OCTET_LENGTH`](https://spark.apache.org/docs/4.1.0/api/sql/#octet_length) | Supported | |
| [`REGEXP_COUNT`](https://spark.apache.org/docs/4.1.0/api/sql/#regexp_count) | Supported | |
| [`REGEXP_SUBSTR`](https://spark.apache.org/docs/4.1.0/api/sql/#regexp_substr) | Supported | |
| [`REPEAT`](https://spark.apache.org/docs/4.1.0/api/sql/#repeat) | Supported | |
| [`REPLACE`](https://spark.apache.org/docs/4.1.0/api/sql/#replace) | Supported | |
| [`RIGHT`](https://spark.apache.org/docs/4.1.0/api/sql/#right) | Supported | |
| [`RTRIM`](https://spark.apache.org/docs/4.1.0/api/sql/#rtrim) | Supported | |
| [`SOUNDEX`](https://spark.apache.org/docs/4.1.0/api/sql/#soundex) | Supported | |
| [`SPACE`](https://spark.apache.org/docs/4.1.0/api/sql/#space) | Supported | |
| [`SPLIT_PART`](https://spark.apache.org/docs/4.1.0/api/sql/#split_part) | Supported | |
| [`TO_BINARY`](https://spark.apache.org/docs/4.1.0/api/sql/#to_binary) | Supported | |
| [`UCASE`](https://spark.apache.org/docs/4.1.0/api/sql/#ucase) | Supported | |
| [`UNBASE64`](https://spark.apache.org/docs/4.1.0/api/sql/#unbase64) | Supported | |
| [`UPPER`](https://spark.apache.org/docs/4.1.0/api/sql/#upper) | Supported | |
| [`ASCII`](https://spark.apache.org/docs/4.1.0/api/sql/#ascii) | With limitations | `ascii(2)` is not supported. |
| [`BTRIM`](https://spark.apache.org/docs/4.1.0/api/sql/#btrim) | With limitations | `btrim(encode(' SparkSQL ', 'utf-8'))` raises an error, where Spark returns `'SparkSQL'`. |
| [`CHAR_LENGTH`](https://spark.apache.org/docs/4.1.0/api/sql/#char_length) | With limitations | `char_length(x'537061726b2053514c')` is not supported. |
| [`CHARACTER_LENGTH`](https://spark.apache.org/docs/4.1.0/api/sql/#character_length) | With limitations | `character_length(x'537061726b2053514c')` is not supported. |
| [`CONCAT_WS`](https://spark.apache.org/docs/4.1.0/api/sql/#concat_ws) | With limitations | `concat_ws('s')` raises an error, where Spark returns `''`. |
| [`ENDSWITH`](https://spark.apache.org/docs/4.1.0/api/sql/#endswith) | With limitations | `endswith(x'537061726b2053514c', x'537061726b')` is not supported. |
| [`LEFT`](https://spark.apache.org/docs/4.1.0/api/sql/#left) | With limitations | `left(encode('Spark SQL', 'utf-8'), 3)` raises an error, where Spark returns `'\x537061'`. |
| [`LOCATE`](https://spark.apache.org/docs/4.1.0/api/sql/#locate) | With limitations | `locate('bar', 'foobarbar', 5)` is not supported. |
| [`LPAD`](https://spark.apache.org/docs/4.1.0/api/sql/#lpad) | With limitations | `hex(lpad(unhex('aabb'), 5))` is not supported. |
| [`POSITION`](https://spark.apache.org/docs/4.1.0/api/sql/#position) | With limitations | `position('bar', 'foobarbar', 5)` is not supported. |
| [`REGEXP_EXTRACT`](https://spark.apache.org/docs/4.1.0/api/sql/#regexp_extract) | With limitations | The group-index argument is not supported: `regexp_extract(s, pattern)` returns the whole match. |
| [`REGEXP_EXTRACT_ALL`](https://spark.apache.org/docs/4.1.0/api/sql/#regexp_extract_all) | With limitations | The group-index argument is not supported: `regexp_extract_all(s, pattern)` returns the whole matches. |
| [`REGEXP_REPLACE`](https://spark.apache.org/docs/4.1.0/api/sql/#regexp_replace) | With limitations | A position other than 1, or a replacement that is not a constant, is not supported. |
| [`RPAD`](https://spark.apache.org/docs/4.1.0/api/sql/#rpad) | With limitations | `hex(rpad(unhex('aabb'), 5))` is not supported. |
| [`SPLIT`](https://spark.apache.org/docs/4.1.0/api/sql/#split) | With limitations | `split('oneAtwoBthreeC', '[ABC]')` is not supported. |
| [`STARTSWITH`](https://spark.apache.org/docs/4.1.0/api/sql/#startswith) | With limitations | `startswith(x'537061726b2053514c', x'537061726b')` is not supported. |
| [`SUBSTR`](https://spark.apache.org/docs/4.1.0/api/sql/#substr) | With limitations | `substr('Spark SQL', -3)` returns `'Spark SQL'`, where Spark returns `'SQL'`. |
| [`SUBSTRING`](https://spark.apache.org/docs/4.1.0/api/sql/#substring) | With limitations | `substring('Spark SQL', -3)` returns `'Spark SQL'`, where Spark returns `'SQL'`. |
| [`TO_CHAR`](https://spark.apache.org/docs/4.1.0/api/sql/#to_char) | With limitations | `to_char(454, '999')` is not supported. |
| [`TRIM`](https://spark.apache.org/docs/4.1.0/api/sql/#trim) | With limitations | `trim(BOTH FROM s)`, `trim(LEADING FROM s)`, and `trim(TRAILING FROM s)` without a trim string are not supported. |
| `CHAR`, `CHR`, `COLLATE`, `COLLATION`, `CONTAINS`, `DECODE`, `ENCODE`, `FIND_IN_SET`, `FORMAT_NUMBER`, `FORMAT_STRING`, `INITCAP`, `IS_VALID_UTF8`, `LEVENSHTEIN`, `LUHN_CHECK`, `MAKE_VALID_UTF8`, `MASK`, `OVERLAY`, `PRINTF`, `QUOTE`, `RANDSTR`, `REGEXP_INSTR`, `SENTENCES`, `SUBSTRING_INDEX`, `TO_NUMBER`, `TO_VARCHAR`, `TRANSLATE`, `TRY_TO_BINARY`, `TRY_TO_NUMBER`, `TRY_VALIDATE_UTF8`, `VALIDATE_UTF8` | Not supported | |

## URL functions

| Function | Support | Notes |
| :- | :- | :- |
| [`URL_DECODE`](https://spark.apache.org/docs/4.1.0/api/sql/#url_decode) | Supported | |
| [`URL_ENCODE`](https://spark.apache.org/docs/4.1.0/api/sql/#url_encode) | Supported | |
| `PARSE_URL`, `TRY_PARSE_URL`, `TRY_URL_DECODE` | Not supported | |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.