57 lines
1011 B
SQL
57 lines
1011 B
SQL
# name: test/sql/function/string/test_reverse.test
|
|
# description: REVERSE test
|
|
# group: [string]
|
|
|
|
statement ok
|
|
PRAGMA enable_verification
|
|
|
|
# test reverse on scalars
|
|
query TTTT
|
|
select REVERSE(''), REVERSE('Hello'), REVERSE('MotörHead'), REVERSE(NULL)
|
|
----
|
|
(empty) olleH daeHrötoM NULL
|
|
|
|
# test reverse 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 REVERSE(a) FROM strings
|
|
----
|
|
olleH
|
|
DlLuH
|
|
daeHrötoM
|
|
(empty)
|
|
|
|
query T
|
|
select REVERSE(b) FROM strings
|
|
----
|
|
dlroW
|
|
NULL
|
|
skcÄR
|
|
NULL
|
|
|
|
query T
|
|
select REVERSE(a) FROM strings WHERE b IS NOT NULL
|
|
----
|
|
olleH
|
|
daeHrötoM
|
|
|
|
# test incorrect usage of reverse
|
|
statement error
|
|
select REVERSE()
|
|
----
|
|
<REGEX>:^Binder Error: No function matches.*
|
|
|
|
statement error
|
|
select REVERSE(1, 2)
|
|
----
|
|
<REGEX>:^Binder Error: No function matches.*
|
|
|
|
statement error
|
|
select REVERSE('hello', 'world')
|
|
----
|
|
<REGEX>:^Binder Error: No function matches.* |