should be it

This commit is contained in:
2025-10-24 19:21:19 -05:00
parent a4b23fc57c
commit f09560c7b1
14047 changed files with 3161551 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
# name: test/sql/error/aggregate_order_by.test
# description: Use non-aggregated column in the ORDER BY clause
# group: [error]
statement ok
CREATE TABLE lists_tbl AS SELECT i%20 as groups, i AS l FROM range(1000) tmp(i);
statement error
SELECT COUNT(DISTINCT l) FROM lists_tbl group by groups order by l limit 10;
----
GROUP BY clause
statement error
SELECT DISTINCT ON(l) COUNT(DISTINCT l) FROM lists_tbl group by groups;
----
GROUP BY clause

View File

@@ -0,0 +1,13 @@
# name: test/sql/error/error_position.test
# description: Test error position
# group: [error]
statement ok
set errors_as_json=true;
# error within table macro
statement error
create macro checksum(x) as table SELECT bit_xor(md5_number(CAST(COLUMNS(*) AS VARCHAR))) FROM query_table(table_name);
----
<REGEX>:.*"position".*:.*"95".*

View File

@@ -0,0 +1,12 @@
# name: test/sql/error/escape_percent_sign.test
# description: Issue 1926: Exception messages need to escape percent signs
# group: [error]
statement ok
CREATE VIEW list_int AS
SELECT case when i%2 <> 0 then [1] else NULL end FROM range(10000) tbl(i);
statement error
select count(*) from list_int where l is distinct from NULL;
----
<REGEX>:.*Binder Error.*not found.*

View File

@@ -0,0 +1,68 @@
# name: test/sql/error/extension_function_error.test
# description: Test usage of functions/settings that are found in extensions without having the extension loaded
# group: [error]
require no_extension_autoloading "EXPECTED: This tests behaviour when extensions can't be loaded, expected"
# this function is in the dbgen extension
statement error
SELECT dbgen();
----
tpch
statement error
SELECT DBGEN();
----
tpch
statement error
SELECT * FROM dbgen();
----
tpch
statement error
CALL dbgen(sf=0.1);
----
tpch
# if we use it as a table we don't report this error - though!
statement error
SELECT * FROM dbgen
----
Table with name dbgen does not exist
# how about settings
statement error
SET TimeZone='UTC'
----
icu
statement error
SELECT * FROM TimeZone
----
Table with name TimeZone does not exist
# after loading the extension the function works like a normal function
require tpch
statement error
SELECT dbgen()
----
Function "dbgen" is a table function but it was used as a scalar function
statement error
CALL dbge()
----
dbgen
# same for settings
require icu
statement error
SET TimeZon='UTC'
----
TimeZone
statement ok
SET TimeZone='UTC'

View File

@@ -0,0 +1,186 @@
# name: test/sql/error/incorrect_sql.test
# description: Test various incorrect SQL strings
# group: [error]
# typo
statement error
SELEC 42;
----
Parser Error: syntax error at or near "SELEC"
statement error
SELEC 42, 'thisisareallylongstringloremipsumblablathisisareallylongstringloremipsumblablalthisisareallylongstringloremipsumblablalthisisareallylongstringloremipsumblablal';
----
Parser Error: syntax error at or near "SELEC"
statement error
SELEC 42, '🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆';
----
Parser Error: syntax error at or near "SELEC"
# unrecognized column
statement error
SELECT '🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆', x, '🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆';
----
# unrecognized scalar function
statement error
SELECT FUNFUNFUN();
----
statement error
CREATE VIEW v1
AS SELECT FUNFUNFUN();
----
# unrecognized aggregate parameters
statement error
SELECT SUM(42, 84, 11, 'hello')
----
# no matching function
statement error
SELECT cos(0, 1, 2, 3);
----
# unrecognized table function
statement error
SELECT * FROM RANG();
----
# unknown named parameters
statement error
SELECT * FROM RANGE(1, hello=3);
----
statement error
SELECT * FROM READ_CSV('x', hello=3);
----
# multiple where clauses
statement error
SELECT 42 WHERE 1=1 WHERE 1=0;
----
Parser Error: syntax error at or near "WHERE"
# multiple statements without semi colon
statement error
SELECT 42
SELECT 42;
----
Parser Error: syntax error at or near "SELECT"
# multiple statements, but error is only in second statement
statement error
SELECT 42; SELEC 42;
----
Parser Error: syntax error at or near "SELEC"
# non-existent table
statement error
SELECT * FROM integers2;
----
# non-existent schema
statement error
SELECT * FROM bla.integers2;
----
# non-existent table in view
statement error
CREATE VIEW v1 AS SELECT * FROM integers2;
----
# non-existent table in long single-line query
statement error
with cte1 as (select 42 as j), cte2 as (select ref.j as k from cte1 as ref), cte3 as (select ref2.j+1 as i from cte1 as ref2) SELECT * FROM integers9;
----
statement error
with cte1 as (select 42 as j), cte2 as (select ref.j as k from cte1 as ref), cte3 as (select ref2.j+1 as i from cte1 as ref2) SELECT * FROM integers9 where x=3 order by x+1+1+1+1+1+1+1+1+1+1+1;
----
# non-existent table in multi-line query (Q1)
statement error
SELECT
l_returnflag,
l_linestatus,
sum(l_quantity) AS sum_qty,
sum(l_extendedprice) AS sum_base_price,
sum(l_extendedprice * (1 - l_discount)) AS sum_disc_price,
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge,
avg(l_quantity) AS avg_qty,
avg(l_extendedprice) AS avg_price,
avg(l_discount) AS avg_disc,
count(*) AS count_order
FROM
lineitem
WHERE
l_shipdate <= CAST('1998-09-02' AS date)
GROUP BY
l_returnflag,
l_linestatus
ORDER BY
l_returnflag,
l_linestatus;
----
# now with unicode
# short unicode error
statement error
select 🦆🍞 from 🦆🍞;
----
# long unicode error
statement error
with 🍞🍞 as (select 'bread' as 🍞), 🦆🦆 as (select ref.🍞 as "🍞" from 🍞🍞 as ref) SELECT * FROM integers9 where x LIKE '🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆🦆' order by x+1+1+1+1+1+1+1+1+1+1+1;
----
statement ok
CREATE TABLE integers(integ INTEGER);
statement ok
CREATE TABLE strings(str VARCHAR);
statement ok
CREATE TABLE chickens(feather INTEGER, beak INTEGER);
# non-existent table, with several tables available
statement error
SELECT * FROM integres;
----
# non-existent column
statement error
SELECT feathe FROM chickens;
----
# non-existent column, with multiple tables
statement error
SELECT feathe FROM chickens, integers, strings;
----
statement error
SELECT st FROM chickens, integers, strings;
----
statement error
SELECT chicken.feather FROM chickens
----
# table-qualified non-existent column
statement error
SELECT chicken.st FROM chickens, integers, strings;
----
# now with unicode
statement ok
CREATE TABLE 🦆🍞(🦆🦆🦆 INTEGER, 🍞🍞🍞 INTEGER);
statement error
SELECT 🦆.🦆🦆🦆 FROM 🦆🍞
----
statement error
SELECT 🦆🦆 FROM 🦆🍞, chickens
----

View File

@@ -0,0 +1,80 @@
# name: test/sql/error/lineitem_errors.test
# description: Test lineitem errors
# group: [error]
statement ok
CREATE TABLE lineitem(l_orderkey BIGINT NOT NULL, l_partkey BIGINT NOT NULL, l_suppkey BIGINT NOT NULL, l_linenumber BIGINT NOT NULL, l_quantity DECIMAL(15,2) NOT NULL, l_extendedprice DECIMAL(15,2) NOT NULL, l_discount DECIMAL(15,2) NOT NULL, l_tax DECIMAL(15,2) NOT NULL, l_returnflag VARCHAR NOT NULL, l_linestatus VARCHAR NOT NULL, l_shipdate DATE NOT NULL, l_commitdate DATE NOT NULL, l_receiptdate DATE NOT NULL, l_shipinstruct VARCHAR NOT NULL, l_shipmode VARCHAR NOT NULL, l_comment VARCHAR NOT NULL);
# l_extendedprice is not ambiguous - we don't need to qualify it
statement error
select * from lineitem where l_extendedpric=5;
----
"l_extendedprice
# l_extendedprice is ambiguous - we need to qualify it
statement error
select * from lineitem, lineitem l2 where l_extendedpric=5;
----
lineitem.l_extendedprice
statement error
select * from lineitem where lineitem.l_extendedpric=5;
----
"l_extendedprice
# check long multi-line errors
statement error
SELECT
l_returnflag,
l_linestatus,
sum(l_quantity) AS sum_qty,
sum(l_extendedprice) AS sum_base_price,
sum(l_extendedprice * (1 - l_discount)) AS sum_disc_price,
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge,
avg(l_quantity) AS avg_qty,
avg(l_extendedprice) AS avg_price,
avg(l_discount) AS avg_disc,
count(*) AS count_order
FROM
lineitem
WHERE
l_shipdate <= CAST('1998-09-02' AS date) + timestamp '2020-01-01'
GROUP BY
l_returnflag,
l_linestatus
ORDER BY
l_returnflag,
l_linestatus;
----
<REGEX>:.*LINE 15:[^\n]+timestamp.*
statement error
SELECT
l_returnflag,
l_linestatus,
sum(l_quantity) AS sum_qty,
sum(l_extendedprice) AS sum_base_price,
sum(l_extendedprice * (1 - l_discount)) AS sum_disc_price,
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge,
avg(l_quantity) AS avg_qty,
avg(l_extendedprice) AS avg_price,
avg(l_discount) AS avg_disc,
count(*) AS count_order
FROM
lineitem
WHERE
l_shipdate <= CAST('1998-09-02' AS date) + timestamp '2020-01-01' -- this has a really long comment that ends up requiring truncation in the error message
GROUP BY
l_returnflag,
l_linestatus
ORDER BY
l_returnflag,
l_linestatus;
----
<REGEX>:.*LINE 15:[^\n]+timestamp.*
# long single-line
statement error
SELECT l_returnflag, l_linestatus, sum(l_quantity) AS sum_qty, sum(l_extendedprice) AS sum_base_price, sum(l_extendedprice * (1 - l_discount)) AS sum_disc_price, sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, avg(l_quantity) AS avg_qty, avg(l_extendedprice) AS avg_price, avg(l_discount) AS avg_disc, count(*) AS count_order FROM lineitem WHERE l_shipdate <= CAST('1998-09-02' AS date) + timestamp '2020-01-01' GROUP BY l_returnflag, l_linestatus ORDER BY l_returnflag, l_linestatus;
----
<REGEX>:.*LINE 1:[^\n]+timestamp.*l_linestatus.*

View File

@@ -0,0 +1,8 @@
# name: test/sql/error/missing_type.test
# description: Test typos in types (type-o's)
# group: [error]
statement error
SELECT ''::blobb
----
Did you mean "blob"?

View File

@@ -0,0 +1,18 @@
# name: test/sql/error/mix_aggregate_and_non_aggregate.test
# description: Test mix of aggregate and non-aggregate
# group: [error]
statement ok
CREATE TABLE tbl(name VARCHAR, style VARCHAR, brewery_id INTEGER, abv DOUBLE, ibu INTEGER);
statement error
SELECT FIRST(name), FIRST(abv)
FROM tbl
GROUP BY style
ORDER BY abv DESC;
----
statement error
SELECT FIRST(name)||abv
FROM tbl
----

View File

@@ -0,0 +1,48 @@
# name: test/sql/error/qualified_column_error.test
# description: Test errors on qualified columns
# group: [error]
statement ok
create schema "dbt_temp"
statement ok
create or replace table "dbt_temp"."foo_2" as (select 42 as num_2);
statement error
select "dbt_temp"."foo_2".num_3 FROM "dbt_temp"."foo_2"
----
"num_2"
statement error
select "dbt_temp"."foo_1".num_2 FROM "dbt_temp"."foo_2"
----
"foo_2"
statement ok
attach ':memory:' as cat
statement ok
create schema cat.schema
statement ok
create table cat.schema.tbl(col struct(v1 int));
statement error
select cat.schema.tbl.col.v2 from cat.schema.tbl
----
"v1"
statement error
select cat.schema.tbl.cxl.v1 from cat.schema.tbl
----
"col"
statement error
select cat.schema.txl.col.v1 from cat.schema.tbl
----
"cat.schema.tbl"
statement error
select cat.schxma.tbl.col.v1 from cat.schema.tbl
----
"cat.schema.tbl"

View File

@@ -0,0 +1,9 @@
# name: test/sql/error/subquery_single_column.test
# description: Subqueries can only return a single column
# group: [error]
# subqueries can only return a single column
statement error
SELECT (SELECT 42, 84)
----
<REGEX>:.*Binder Error: Subquery returns.*

View File

@@ -0,0 +1,8 @@
# name: test/sql/error/table_function_as_scalar_function.test
# description: Use a table function as a scalar function
# group: [error]
statement error
SELECT read_csv('test.csv')
----
FROM

View File

@@ -0,0 +1,122 @@
# name: test/sql/error/test_try_expression.test
# group: [error]
statement ok
pragma enable_verification;
# --- OPERATOR_CAST ---
query I
select TRY('abc'::INTEGER)
----
NULL
# --- OPERATOR_NOT ---
statement error
select ~CAST('abc' as INTEGER)
----
Could not convert string
query I
select TRY(~CAST('abc' as INTEGER))
----
NULL
# --- OPERATOR_IS_NULL ---
query I
select TRY(CAST('abc' as INTEGER) IS NULL);
----
NULL
# --- OPERATOR_IS_NOT_NULL ---
query I
select TRY(CAST('abc' as INTEGER) IS NOT NULL);
----
NULL
# --- COMPARE_EQUAL ---
query I
select TRY(CAST('abc' as INTEGER) == 'abc')
----
NULL
# --- COMPARE_EQUAL ---
query I
select TRY(CAST('abc' as INTEGER) == 'abc')
----
NULL
# --- COMPARE_NOTEQUAL ---
query I
select TRY(CAST('abc' as INTEGER) != 'abc')
----
NULL
# --- Functions ---
query I
select TRY(ln(0));
----
NULL
query I
with cte as (
select * from (VALUES
('123'),
('test'),
('235')
) t(a)
)
select try(a::INTEGER) from cte
----
123
NULL
235
# Using TRY('abc'::BIGINT) results in null
# Making the result of these queries equivalent
query I nosort expected_result
with cte as (
select i % 5 i from range(100_000) t(i)
),
cte2 as (
select if(i == 0, NULL, i) res from cte
)
select count(res) from cte2;
----
query I nosort expected_result
with cte as (
select i % 5 i from range(100_000) t(i)
),
cte2 as (
select TRY(if(i == 0, 'abc', i::VARCHAR)::BIGINT) res from cte
)
select count(res) from cte2;
----
statement error
select try(if(random() > 2.0, '123', 'abc')::TINYINT)
----
TRY can not be used in combination with a volatile function
statement error
select try(CAST((select 'ABC') as INTEGER))
----
TRY can not be used in combination with a scalar subquery
# The values below are literals, which do not have a PhysicalType, caused a crash before fixing duckdb-internal/issues/5047
statement ok
select TRY('hello');
statement ok
select TRY(123);

View File

@@ -0,0 +1,8 @@
# name: test/sql/error/unknown_window_function.test
# description: Test unknown window function
# group: [error]
statement error
SELECT substr('hello', 3, 2) OVER ();
----
<REGEX>:.*Catalog Error: substr is not an aggregate function.*