| # name: test/sql/function/string/test_replace.test |
| # description: REPLACE test |
| # group: [string] |
| # Ignored: https://issues.apache.org/jira/browse/IGNITE-15031 |
| |
| # 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 VARCHAR, b VARCHAR) |
| |
| statement ok |
| INSERT INTO strings VALUES ('Hello', 'World'), ('HuLlD', NULL), ('MotörHead','RÄcks'), ('', NULL) |
| |
| query T |
| select REPLACE(a, 'l', '-') FROM strings ORDER BY 1 |
| ---- |
| (empty) |
| He--o |
| HuL-D |
| MotörHead |
| |
| query T |
| select REPLACE(b, 'Ä', '--') FROM strings ORDER BY a |
| ---- |
| NULL |
| World |
| NULL |
| R--cks |
| |
| query T |
| select REPLACE(a, 'H', '') FROM strings WHERE b IS NOT NULL ORDER BY a |
| ---- |
| ello |
| Motöread |
| |
| # test incorrect usage of replace |
| statement error |
| select REPLACE(1) |
| |
| statement error |
| select REPLACE(1, 2) |
| |
| statement error |
| select REPLACE(1, 2, 3, 4) |
| |