-- String REPEAT function tests -- Basic REPEAT function SELECT REPEAT('hello', 3); +--------------------------------+ | repeat(Utf8("hello"),Int64(3)) | +--------------------------------+ | hellohellohello | +--------------------------------+ SELECT REPEAT('a', 5); +----------------------------+ | repeat(Utf8("a"),Int64(5)) | +----------------------------+ | aaaaa | +----------------------------+ SELECT REPEAT('', 3); +---------------------------+ | repeat(Utf8(""),Int64(3)) | +---------------------------+ | | +---------------------------+ SELECT REPEAT('test', 0); +-------------------------------+ | repeat(Utf8("test"),Int64(0)) | +-------------------------------+ | | +-------------------------------+ SELECT REPEAT('test', 1); +-------------------------------+ | repeat(Utf8("test"),Int64(1)) | +-------------------------------+ | test | +-------------------------------+ -- REPEAT with NULL values SELECT REPEAT(NULL, 3); +-----------------------+ | repeat(NULL,Int64(3)) | +-----------------------+ | | +-----------------------+ SELECT REPEAT('hello', NULL); +----------------------------+ | repeat(Utf8("hello"),NULL) | +----------------------------+ | | +----------------------------+ -- REPEAT with negative numbers SELECT REPEAT('hello', -1); +---------------------------------+ | repeat(Utf8("hello"),Int64(-1)) | +---------------------------------+ | | +---------------------------------+ -- REPEAT with special characters SELECT REPEAT('*', 10); +-----------------------------+ | repeat(Utf8("*"),Int64(10)) | +-----------------------------+ | ********** | +-----------------------------+ SELECT REPEAT('-=', 5); +-----------------------------+ | repeat(Utf8("-="),Int64(5)) | +-----------------------------+ | -=-=-=-=-= | +-----------------------------+ SELECT REPEAT('!@#', 3); +------------------------------+ | repeat(Utf8("!@#"),Int64(3)) | +------------------------------+ | !@#!@#!@# | +------------------------------+ -- Test with table data CREATE TABLE repeat_test(s VARCHAR, n INTEGER, ts TIMESTAMP TIME INDEX); Affected Rows: 0 INSERT INTO repeat_test VALUES ('hello', 2, 1000), ('*', 5, 2000), ('test', 0, 3000), ('a', 10, 4000), (NULL, 3, 5000), ('hi', NULL, 6000); Affected Rows: 6 SELECT s, n, REPEAT(s, n) FROM repeat_test ORDER BY ts; +-------+----+-------------------------------------+ | s | n | repeat(repeat_test.s,repeat_test.n) | +-------+----+-------------------------------------+ | hello | 2 | hellohello | | * | 5 | ***** | | test | 0 | | | a | 10 | aaaaaaaaaa | | | 3 | | | hi | | | +-------+----+-------------------------------------+ -- Unicode REPEAT SELECT REPEAT('世', 3); +-----------------------------+ | repeat(Utf8("世"),Int64(3)) | +-----------------------------+ | 世世世 | +-----------------------------+ SELECT REPEAT('🚀', 5); +-----------------------------+ | repeat(Utf8("🚀"),Int64(5)) | +-----------------------------+ | 🚀🚀🚀🚀🚀 | +-----------------------------+ SELECT REPEAT('café', 2); +-------------------------------+ | repeat(Utf8("café"),Int64(2)) | +-------------------------------+ | cafécafé | +-------------------------------+ -- REPEAT with spaces and formatting SELECT REPEAT(' ', 10); +-----------------------------+ | repeat(Utf8(" "),Int64(10)) | +-----------------------------+ | | +-----------------------------+ SELECT REPEAT('\t', 3); +-----------------------------+ | repeat(Utf8("\t"),Int64(3)) | +-----------------------------+ | \t\t\t | +-----------------------------+ SELECT CONCAT('Start', REPEAT('-', 10), 'End'); +---------------------------------------------------------------+ | concat(Utf8("Start"),repeat(Utf8("-"),Int64(10)),Utf8("End")) | +---------------------------------------------------------------+ | Start----------End | +---------------------------------------------------------------+ -- Large REPEAT operations SELECT LENGTH(REPEAT('a', 100)); +---------------------------------------+ | length(repeat(Utf8("a"), Int64(100))) | +---------------------------------------+ | 100 | +---------------------------------------+ SELECT LENGTH(REPEAT('ab', 50)); +---------------------------------------+ | length(repeat(Utf8("ab"), Int64(50))) | +---------------------------------------+ | 100 | +---------------------------------------+ -- Combining REPEAT with other functions SELECT UPPER(REPEAT('hello', 3)); +---------------------------------------+ | upper(repeat(Utf8("hello"),Int64(3))) | +---------------------------------------+ | HELLOHELLOHELLO | +---------------------------------------+ SELECT REPEAT(UPPER('hello'), 2); +---------------------------------------+ | repeat(upper(Utf8("hello")),Int64(2)) | +---------------------------------------+ | HELLOHELLO | +---------------------------------------+ SELECT REVERSE(REPEAT('abc', 3)); +---------------------------------------+ | reverse(repeat(Utf8("abc"),Int64(3))) | +---------------------------------------+ | cbacbacba | +---------------------------------------+ DROP TABLE repeat_test; Affected Rows: 0