should be it
This commit is contained in:
44
external/duckdb/test/sql/cast/test_try_cast.test
vendored
Normal file
44
external/duckdb/test/sql/cast/test_try_cast.test
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# name: test/sql/cast/test_try_cast.test
|
||||
# description: Test try cast
|
||||
# group: [cast]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# TRY_CAST turns a failed cast into NULL
|
||||
query I
|
||||
SELECT TRY_CAST('hello' as INTEGER)
|
||||
----
|
||||
NULL
|
||||
|
||||
# CAST throws an error
|
||||
statement error
|
||||
SELECT CAST('hello' as INTEGER)
|
||||
----
|
||||
|
||||
query IIII
|
||||
SELECT TRY_CAST(3 as BIGINT), CAST(3 AS BIGINT), TRY_CAST(2 as BIGINT), CAST(3 AS INTEGER)
|
||||
----
|
||||
3 3 2 3
|
||||
|
||||
# not a reserved keyword
|
||||
statement ok
|
||||
CREATE TABLE try_cast(try_cast INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO try_cast VALUES (3);
|
||||
|
||||
query I
|
||||
SELECT try_cast FROM try_cast;
|
||||
----
|
||||
3
|
||||
|
||||
query I
|
||||
SELECT try_cast(try_cast as bigint) FROM try_cast;
|
||||
----
|
||||
3
|
||||
|
||||
query I
|
||||
SELECT try_cast(try_cast(try_cast as integer) as integer) FROM try_cast;
|
||||
----
|
||||
3
|
||||
Reference in New Issue
Block a user