# name: test/sql/function/string/test_concat.test # description: Test concat function # group: [string] statement ok SET default_null_order='nulls_first'; # Test Case disclaimer # Assertions built using the Domain Testing technique # at: https://bbst.courses/wp-content/uploads/2018/01/Kaner-Intro-to-Domain-Testing-2018.pdf statement ok PRAGMA enable_verification statement ok CREATE TABLE strings(s VARCHAR) statement ok INSERT INTO strings VALUES ('hello'), ('world'), (NULL) # normal concat query T SELECT s || ' ' || s FROM strings ORDER BY s ---- NULL hello hello world world # unicode concat query T SELECT s || ' ' || '🦆' FROM strings ORDER BY s ---- NULL hello 🦆 world 🦆 query T SELECT s || ' ' || '🦆' FROM strings ORDER BY s ---- NULL hello 🦆 world 🦆 # concat with constant NULL query T SELECT s || ' ' || '🦆' || NULL FROM strings ORDER BY s ---- NULL NULL NULL # concat requires at least one argument statement error SELECT CONCAT() ---- # concat with one argument works query T SELECT CONCAT('hello') ---- hello # varargs concat query T SELECT CONCAT('hello', 33, 22) ---- hello3322 # CONCAT ignores null values query T SELECT CONCAT('hello', 33, NULL, 22, NULL) ---- hello3322 # this also applies to non-constant null values query T SELECT CONCAT('hello', ' ', s) FROM strings ORDER BY s ---- hello hello hello hello world