From 9e32d9ca75ff358bef16e2b44c26fd9ee97db161 Mon Sep 17 00:00:00 2001 From: Pat Kearns Date: Mon, 28 Mar 2022 13:29:07 +1100 Subject: [PATCH] add quoting to split_part (#528) * add quoting to split_part * update docs for split_part * typo * corrected readme syntax * revert and update to just documentation * add new line * Update README.md * Update README.md * Update README.md Co-authored-by: Joel Labes --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 114c12c4..c012c4b3 100644 --- a/README.md +++ b/README.md @@ -965,9 +965,16 @@ This macro calculates the difference between two dates. #### split_part ([source](macros/cross_db_utils/split_part.sql)) This macro splits a string of text using the supplied delimiter and returns the supplied part number (1-indexed). +**Args**: +- `string_text` (required): Text to be split into parts. +- `delimiter_text` (required): Text representing the delimiter to split by. +- `part_number` (required): Requested part of the split (1-based). If the value is negative, the parts are counted backward from the end of the string. + **Usage:** +When referencing a column, use one pair of quotes. When referencing a string, use single quotes enclosed in double quotes. ``` -{{ dbt_utils.split_part(string_text='1,2,3', delimiter_text=',', part_number=1) }} +{{ dbt_utils.split_part(string_text='column_to_split', delimiter_text='delimiter_column', part_number=1) }} +{{ dbt_utils.split_part(string_text="'1|2|3'", delimiter_text="'|'", part_number=1) }} ``` #### date_trunc ([source](macros/cross_db_utils/date_trunc.sql))