# name: test/sql/function/string/test_replace.test # description: REPLACE test # group: [string] statement ok PRAGMA enable_verification # test replace on NULLs query T select REPLACE('This is the main test string', NULL, 'ALT') ---- NULL query T select REPLACE(NULL, 'main', 'ALT') ---- NULL query T select REPLACE('This is the main test string', 'main', NULL) ---- NULL # test replace on scalars query T select REPLACE('This is the main test string', 'main', 'ALT') ---- This is the ALT test string query T select REPLACE('This is the main test string', 'main', 'larger-main') ---- This is the larger-main test string query T select REPLACE('aaaaaaa', 'a', '0123456789') ---- 0123456789012345678901234567890123456789012345678901234567890123456789 # test replace on tables statement ok CREATE TABLE strings(a STRING, b STRING) statement ok INSERT INTO strings VALUES ('Hello', 'World'), ('HuLlD', NULL), ('MotörHead','RÄcks'), ('', NULL) query T select REPLACE(a, 'l', '-') FROM strings ---- He--o HuL-D MotörHead (empty) query T select REPLACE(b, 'Ä', '--') FROM strings ---- World NULL R--cks NULL query T select REPLACE(a, 'H', '') FROM strings WHERE b IS NOT NULL ---- ello Motöread # test incorrect usage of replace statement error select REPLACE(1) ---- :.*Binder Error: No function matches.* statement error select REPLACE(1, 2) ---- :.*Binder Error: No function matches.* statement error select REPLACE(1, 2, 3, 4) ---- :.*Binder Error: No function matches.*