All Products
Search
Document Center

MaxCompute:REPEAT

Last Updated:Mar 26, 2026

Returns a string formed by repeating str exactly n times.

Syntax

string repeat(string <str>, bigint <n>)

Parameters

ParameterRequiredTypeDescription
strYesSTRINGThe string to repeat. BIGINT, DOUBLE, DECIMAL, and DATETIME values are implicitly converted to STRING before the function runs.
nYesBIGINTThe number of times to repeat str. The result cannot exceed 2 MB in length.

Return value

Returns a STRING value.

ConditionResult
str or n is nullnull
str is not STRING, BIGINT, DOUBLE, DECIMAL, or DATETIMEError
n is not specifiedError

Examples

Example 1: Repeat abc five times.

select repeat('abc', 5);
-- Return value: abcabcabcabcabc

Example 2: Pass null as an argument.

select repeat('abc', null);
-- Return value: null

Related functions

REPEAT is a string function. For more information about functions related to string searches and conversion, see String functions.