blob: 1ed7684da4bc63b40881c9ff482ed10501b412f8 [file] [log] [blame]
# name: test/sql/function/string/test_repeat.test
# description: REPEAT test
# group: [string]
# test repeat on NULLs
query TTT
select REPEAT(NULL, NULL), REPEAT(NULL, 3), REPEAT('MySQL', NULL)
----
NULL NULL NULL
# test repeat on scalars
query TTTT
select REPEAT('', 3), REPEAT('MySQL', 3), REPEAT('MotörHead', 2), REPEAT('Hello', -1)
----
(empty) MySQLMySQLMySQL MotörHeadMotörHead (empty)
# test repeat on tables
statement ok
CREATE TABLE strings(id INTEGER, a VARCHAR, b VARCHAR)
statement ok
INSERT INTO strings VALUES (0, 'Hello', 'World'), (1, 'HuLlD', NULL), (2, 'MotörHead','RÄcks'), (3, '', NULL)
query T
select REPEAT(a, 3) FROM strings ORDER BY id
----
HelloHelloHello
HuLlDHuLlDHuLlD
MotörHeadMotörHeadMotörHead
(empty)
query T
select REPEAT(b, 2) FROM strings ORDER BY id
----
WorldWorld
NULL
RÄcksRÄcks
NULL
query T
select REPEAT(a, 4) FROM strings WHERE b IS NOT NULL ORDER BY id
----
HelloHelloHelloHello
MotörHeadMotörHeadMotörHeadMotörHead
# test incorrect usage of reverse
statement error
select REPEAT()
statement error
select REPEAT(1)
statement error
select REPEAT('hello', 'world')
statement error
select REPEAT('hello', 'world', 3)