Repeats a string a specified number of times. The string can be specified as a String literal, a function returning a String, or a column reference.

String literal example:

repeat('ha',3)

Output: Returns the string: hahaha.

Column reference example:

repeat(MyString,4)

Output: Returns the values of the MyString column value written four times in a row. 

repeat(column_string,rpt_count)


ArgumentRequired?Data TypeDescription
column_stringYstringName of the column or string literal to be applied to the function
rpt_countNinteger (positive)Count of times to repeat the string

column_string

Name of the column or String literal to be repeated.

Required?Data TypeExample Value
YesString literal, function, or column referencemyColumn

rpt_count

Count of times to repeat the string.

Required?Data TypeExample Value
NoInteger (non-negative)5

Example - REPEAT string function

Source:

myStrrepeat_count
ha0
ha1
ha1.5
ha2
ha-2

 

Transformation:

Results:

myStrrepeat_countrepeat_string
ha0 
ha1ha
ha1.5 
ha2haha
ha-2 

Example - Padding values

In the following example, the imported prodId values are supposed to be eight characters in length. Somewhere during the process, however, leading 0 characters were truncated. The steps below allow you to re-insert the leading characters.

Source:

prodNameprodId
w011
w0210000001
w03345
w0410402

Transformation:

First, we need to identify how many zeroes need to be inserted for each prodId:

Use the REPEAT function to generate a pad string based on the above values:

Merge the pad string and the original prodId column:

Results:

When you delete the intermediate columns and rename column2 to prodId, you have the following table:

prodNameprodId
w0100000001
w0210000001
w0300000345
w0400010402