Skip to main content

SPLIT_PART

Functions › Text › Take part of a string

Splits a string on a delimiter and returns one part.

Syntax​

SPLIT_PART( <string>, <delimiter>, <part> )

Arguments​

ArgumentDescription
<string>The text to split.
<delimiter>The text to split on. The whole delimiter is one separator, even when it is several characters.
<part>Which part to return, counting from 1. A negative number counts from the end: -1 is the last part.

Returns​

Text. An empty string when <part> is past the last part. NULL when any argument is NULL.

Usage notes​

  • <part> cannot be 0.
  • On large tables the engine runs it in the data store when <delimiter> and <part> are literals and <part> is positive; otherwise it runs after the rows are read.

Examples​

SELECT f.path,
SPLIT_PART(f.path, '/', 1) AS top_folder,
SPLIT_PART(f.path, '/', -1) AS file_name
FROM tables.drive.file f
pathtop_folderfile_name
finance/2026/q1.xlsxfinanceq1.xlsx
hr/policies.pdfhrpolicies.pdf

A delimiter of several characters:

SELECT t.ref, SPLIT_PART(t.ref, '::', 2) AS class_name FROM data.symbols t
refclass_name
Billing::Invoice::totalInvoice

See also​

STRPOS · REGEXP_REPLACE · REGEXP_SPLIT_TO_TABLE