should be it

This commit is contained in:
2025-10-24 19:21:19 -05:00
parent a4b23fc57c
commit f09560c7b1
14047 changed files with 3161551 additions and 1 deletions

View File

@@ -0,0 +1,83 @@
# 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)
----
<REGEX>:.*Binder Error: No function matches.*
statement error
select REPLACE(1, 2)
----
<REGEX>:.*Binder Error: No function matches.*
statement error
select REPLACE(1, 2, 3, 4)
----
<REGEX>:.*Binder Error: No function matches.*