blob: e279c83e359b6c3361cebb8cbbe0e69a02befb62 [file] [log] [blame]
# name: test/sql/cast/test_cast_boolean.test
# description: SQL feature T031(BOOLEAN data type). Cast operator.
# feature: SQL F201(CAST function)
# group: [cast]
statement ok
PRAGMA enable_verification
query T
SELECT CAST(1=1 AS VARCHAR)
----
TRUE
query T
SELECT CAST(1=0 AS VARCHAR)
----
FALSE
query T
SELECT CAST('true' AS BOOLEAN)
----
true
query T
SELECT CAST('TRUE' AS BOOLEAN)
----
true
query T
SELECT CAST('false' AS BOOLEAN)
----
false
query T
SELECT CAST('FALSE' AS BOOLEAN)
----
false
query T
SELECT CAST(NULL AS BOOLEAN)
----
null
query T
SELECT CAST((1 = NULL) AS BOOLEAN)
----
null
statement error: Invalid character for cast: 0
SELECT CAST('0' AS BOOLEAN)
statement error: Invalid character for cast: 1
SELECT CAST('1' AS BOOLEAN)
statement error: Cast function cannot convert value of type TINYINT to type BOOLEAN
SELECT CAST(CAST('1' AS tinyint) AS BOOLEAN)
statement error: Cast function cannot convert value of type TINYINT to type BOOLEAN
SELECT CAST(CAST('0' AS tinyint) AS BOOLEAN)
statement error: Cast function cannot convert value of type SMALLINT to type BOOLEAN
SELECT CAST(CAST('1' AS smallint) AS BOOLEAN)
statement error: Cast function cannot convert value of type SMALLINT to type BOOLEAN
SELECT CAST(CAST('0' AS smallint) AS BOOLEAN)
statement error: Cast function cannot convert value of type INTEGER to type BOOLEAN
SELECT CAST(CAST('1' AS integer) AS BOOLEAN)
statement error: Cast function cannot convert value of type INTEGER to type BOOLEAN
SELECT CAST(CAST('0' AS integer) AS BOOLEAN)
statement error: Cast function cannot convert value of type BIGINT to type BOOLEAN
SELECT CAST(CAST('1' AS bigint) AS BOOLEAN)
statement error: Cast function cannot convert value of type BIGINT to type BOOLEAN
SELECT CAST(CAST('0' AS bigint) AS BOOLEAN)
statement error: Cast function cannot convert value of type DECIMAL(32767, 0) to type BOOLEAN
SELECT CAST(CAST('1' AS decimal) AS BOOLEAN)
statement error: Cast function cannot convert value of type DECIMAL(32767, 0) to type BOOLEAN
SELECT CAST(CAST('0' AS decimal) AS BOOLEAN)
statement error: Cast function cannot convert value of type DECIMAL(1, 0) to type BOOLEAN
SELECT CAST(CAST('1' AS decimal(1,0)) AS BOOLEAN)
statement error: Cast function cannot convert value of type DECIMAL(1, 0) to type BOOLEAN
SELECT CAST(CAST('0' AS decimal(1,0)) AS BOOLEAN)
statement error: Cast function cannot convert value of type FLOAT to type BOOLEAN
SELECT CAST(CAST('1' AS float) AS BOOLEAN)
statement error: Cast function cannot convert value of type FLOAT to type BOOLEAN
SELECT CAST(CAST('0' AS float) AS BOOLEAN)
statement error: Cast function cannot convert value of type DOUBLE to type BOOLEAN
SELECT CAST(CAST('1' AS double) AS BOOLEAN)
statement error: Cast function cannot convert value of type DOUBLE to type BOOLEAN
SELECT CAST(CAST('0' AS double) AS BOOLEAN)
statement error: Cast function cannot convert value of type DATE to type BOOLEAN
SELECT CAST(CAST('1970-1-1' AS date) AS BOOLEAN)
statement error: Cast function cannot convert value of type TIME(0) to type BOOLEAN
SELECT CAST(CAST('00:00:00' AS time) AS BOOLEAN)
statement error: Cast function cannot convert value of type TIME(9) to type BOOLEAN
SELECT CAST(CAST('00:00:00.000000000' AS time(9)) AS BOOLEAN)
statement error: Cast function cannot convert value of type TIMESTAMP(6) to type BOOLEAN
SELECT CAST(CAST('1970-1-1 00:00:00' AS timestamp) AS BOOLEAN)
statement error: Cast function cannot convert value of type TIMESTAMP(9) to type BOOLEAN
SELECT CAST(CAST('1970-1-1 00:00:00.000000000' AS timestamp(9)) AS BOOLEAN)
statement error: Cast function cannot convert value of type UUID to type BOOLEAN
SELECT CAST(CAST('c4a0327c-44be-416d-ae90-75c05079789f' AS UUID) AS BOOLEAN)
statement error: Cast function cannot convert value of type BINARY(1) to type BOOLEAN
SELECT CAST(CAST(x'00' AS BINARY) AS BOOLEAN)
statement error: Cast function cannot convert value of type VARBINARY to type BOOLEAN
SELECT CAST(CAST(x'00' AS VARBINARY) AS BOOLEAN)