should be it
This commit is contained in:
20
external/duckdb/test/issues/fuzz/argminmax_strings.test
vendored
Normal file
20
external/duckdb/test/issues/fuzz/argminmax_strings.test
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# name: test/issues/fuzz/argminmax_strings.test
|
||||
# description: Issue #3373: heap-use-after-free at string_type.hpp:76:10
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE i_class_id AS
|
||||
SELECT
|
||||
LIST(i_category_id::integer) AS i_category_id,
|
||||
LIST(i_category_id::VARCHAR) AS channel,
|
||||
LIST([i_category_id]) AS sum_sales,
|
||||
LIST({'a': i_category_id}) AS number_sales
|
||||
FROM range(1, 6, 1) t1(i_category_id);
|
||||
|
||||
query II
|
||||
select argmin(i_category_id,i_category_id::VARCHAR), argmax(i_category_id, i_category_id::VARCHAR) from i_class_id;
|
||||
----
|
||||
[1, 2, 3, 4, 5] [1, 2, 3, 4, 5]
|
||||
99
external/duckdb/test/issues/fuzz/bitwise_shift_overflow.test
vendored
Normal file
99
external/duckdb/test/issues/fuzz/bitwise_shift_overflow.test
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
# name: test/issues/fuzz/bitwise_shift_overflow.test
|
||||
# description: Issue #3365: Undefined behavior at bitwise.cpp:148:38
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# issue tests
|
||||
statement error
|
||||
SELECT 1000::bigint<<55;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Overflow in left shift.*
|
||||
|
||||
statement error
|
||||
SELECT 256::bigint<<55;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Overflow in left shift.*
|
||||
|
||||
query I
|
||||
SELECT 255::bigint<<55;
|
||||
----
|
||||
9187343239835811840
|
||||
|
||||
query I
|
||||
SELECT 0::bigint<<999;
|
||||
----
|
||||
0
|
||||
|
||||
# all integer types
|
||||
# tinyint
|
||||
statement error
|
||||
SELECT 10::tinyint<<4::tinyint;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Overflow in left shift.*
|
||||
|
||||
query I
|
||||
SELECT 10::tinyint<<3::tinyint;
|
||||
----
|
||||
80
|
||||
|
||||
# cannot left shift negative numbers
|
||||
statement error
|
||||
SELECT (-128)::tinyint<<0::tinyint;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Cannot left-shift.*
|
||||
|
||||
statement error
|
||||
SELECT (-10)::tinyint<<4::tinyint;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Cannot left-shift.*
|
||||
|
||||
statement error
|
||||
SELECT (-10)::tinyint<<3::tinyint;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Cannot left-shift.*
|
||||
|
||||
# smallint
|
||||
statement error
|
||||
SELECT 1000::smallint<<6::smallint;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Overflow in left shift.*
|
||||
|
||||
query I
|
||||
SELECT 1000::smallint<<5::smallint;
|
||||
----
|
||||
32000
|
||||
|
||||
# integer
|
||||
statement error
|
||||
SELECT 1000::integer<<22::integer;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Overflow in left shift.*
|
||||
|
||||
query I
|
||||
SELECT 1000::integer<<21::integer;
|
||||
----
|
||||
2097152000
|
||||
|
||||
# bigint
|
||||
statement error
|
||||
SELECT 1000::bigint<<54::bigint;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Overflow in left shift.*
|
||||
|
||||
query I
|
||||
SELECT 1000::bigint<<53::bigint;
|
||||
----
|
||||
9007199254740992000
|
||||
|
||||
# hugeint
|
||||
statement error
|
||||
SELECT 1000::hugeint<<118::hugeint;
|
||||
----
|
||||
<REGEX>:Out of Range Error.*Overflow in left shift.*
|
||||
|
||||
query I
|
||||
SELECT 1000::hugeint<<117::hugeint;
|
||||
----
|
||||
166153499473114484112975882535043072000
|
||||
37
external/duckdb/test/issues/fuzz/encode_string_data_crash.test
vendored
Normal file
37
external/duckdb/test/issues/fuzz/encode_string_data_crash.test
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# name: test/issues/fuzz/encode_string_data_crash.test
|
||||
# description: Issue #3350: SEGV in duckdb::EncodeStringDataPrefix
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE strings(b REAL, a INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO strings VALUES
|
||||
(5, 10), (10, 20), (13, 26), (13, 26),
|
||||
(15, 30), (20, 40), (22,80), (30, 90);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE id(c TEXT, strings_with_null INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO id VALUES('c', NULL);
|
||||
|
||||
query I
|
||||
SELECT sum(a) OVER (
|
||||
PARTITION BY (
|
||||
SELECT c FROM id WHERE strings_with_null=a
|
||||
) ORDER BY a
|
||||
) FROM strings
|
||||
ORDER BY 1
|
||||
----
|
||||
10
|
||||
30
|
||||
82
|
||||
82
|
||||
112
|
||||
152
|
||||
232
|
||||
322
|
||||
43
external/duckdb/test/issues/fuzz/foreign_key_index_selection.test
vendored
Normal file
43
external/duckdb/test/issues/fuzz/foreign_key_index_selection.test
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# name: test/issues/fuzz/foreign_key_index_selection.test
|
||||
# description: Issue #3352: String null pointer in foreign key
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE s1(t0 INTEGER, a TEXT, b TEXT);
|
||||
|
||||
# key does not exist
|
||||
statement error
|
||||
CREATE TABLE c2(c0 INTEGER, c1 INTEGER UNIQUE, FOREIGN KEY (c0) REFERENCES s1(tz));
|
||||
----
|
||||
<REGEX>:Binder Error:.*Failed to create foreign key.*
|
||||
|
||||
# key does not have an index on it
|
||||
statement error
|
||||
CREATE TABLE c2(c0 INTEGER, c1 INTEGER UNIQUE, FOREIGN KEY (c0) REFERENCES s1(t0));
|
||||
----
|
||||
<REGEX>:Binder Error:.*Failed to create foreign key.*
|
||||
|
||||
statement ok
|
||||
CREATE TABLE s2(t0 INTEGER, a TEXT, b TEXT, UNIQUE (t0, a));
|
||||
|
||||
# key does not have an index on it
|
||||
statement error
|
||||
CREATE TABLE c2(c0 INTEGER, c1 INTEGER UNIQUE, FOREIGN KEY (c0) REFERENCES s2(t0));
|
||||
----
|
||||
<REGEX>:Binder Error:.*Failed to create foreign key.*
|
||||
|
||||
# this works
|
||||
statement ok
|
||||
CREATE TABLE s3(t0 INTEGER UNIQUE, a TEXT, b TEXT, UNIQUE (t0, a));
|
||||
|
||||
statement ok
|
||||
CREATE TABLE c2(c0 INTEGER, c1 INTEGER UNIQUE, FOREIGN KEY (c0) REFERENCES s3(t0));
|
||||
|
||||
statement ok
|
||||
INSERT INTO s3 VALUES (1, 'a', 'b');
|
||||
|
||||
statement ok
|
||||
INSERT INTO c2 VALUES (1, 2);
|
||||
17
external/duckdb/test/issues/fuzz/function_pointer_crash_in_subquery.test
vendored
Normal file
17
external/duckdb/test/issues/fuzz/function_pointer_crash_in_subquery.test
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# name: test/issues/fuzz/function_pointer_crash_in_subquery.test
|
||||
# description: Issue 3351: NullPointer at duckdb/src/function/function.cpp:368:29
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE strings(a INTEGER);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE c0(test2 tinyint, s1 smallint, s2 integer, test1 bigint, i double, id real, c1 varchar);
|
||||
|
||||
statement error
|
||||
SELECT * FROM c0 s1 INNER JOIN c0 s2 ON (SELECT s1.s2=s2 FROM c0 WHERE s2.s2=s2) ORDER BY s1.s2;
|
||||
----
|
||||
Binder Error: Cannot extract field 's2' from expression "s1"
|
||||
14
external/duckdb/test/issues/fuzz/multi_rollup_assertion.test
vendored
Normal file
14
external/duckdb/test/issues/fuzz/multi_rollup_assertion.test
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# name: test/issues/fuzz/multi_rollup_assertion.test
|
||||
# description: Issue 3349: Assertion Failed: chunk.ColumnCount() == op.aggregates.size()
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table strings (a VARCHAR, b VARCHAR);
|
||||
|
||||
query III
|
||||
select b, b, count(*) from strings group by rollup (b, b) order by 1, 2, 3;
|
||||
----
|
||||
NULL NULL 0
|
||||
17
external/duckdb/test/issues/fuzz/nan_progress.test
vendored
Normal file
17
external/duckdb/test/issues/fuzz/nan_progress.test
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# name: test/issues/fuzz/nan_progress.test
|
||||
# description: Issue 3366: NaN in progress bar
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
SET enable_progress_bar=true;
|
||||
|
||||
statement ok
|
||||
WITH RECURSIVE t AS
|
||||
(
|
||||
SELECT 1 AS x
|
||||
UNION
|
||||
SELECT t1.x + t2.x + t3.x AS x
|
||||
FROM t t1, t t2, t t3
|
||||
WHERE t1.x < 100
|
||||
)
|
||||
SELECT * FROM t ORDER BY 1;
|
||||
12
external/duckdb/test/issues/fuzz/prepared_statement_crash.test
vendored
Normal file
12
external/duckdb/test/issues/fuzz/prepared_statement_crash.test
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# name: test/issues/fuzz/prepared_statement_crash.test
|
||||
# description: Issue #3364: heap-use-after-free in duckdb::LogicalType::operator==(duckdb::LogicalType const&)
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PREPARE s1 AS SELECT CAST(? AS INTEGER), CAST(? AS STRING);
|
||||
|
||||
statement ok
|
||||
SELECT MIN ( DISTINCT + CAST ( NULL AS INTEGER ) ) * COUNT ( * ) * - + 16 * CASE + + AVG ( ALL 97 ) WHEN ( + NULLIF ( SUM ( CAST ( NULL AS REAL ) ), 6 ) ) THEN 51 * 31 + - 6 WHEN + 48 * - 34 THEN NULL WHEN 91 * + ( SUM ( CAST ( NULL AS INTEGER ) ) ) THEN NULL END * - 4 + - 67;
|
||||
|
||||
statement ok
|
||||
EXECUTE s1(42, 'dpfkg');
|
||||
20
external/duckdb/test/issues/fuzz/recursive_view_expression_assertion.test
vendored
Normal file
20
external/duckdb/test/issues/fuzz/recursive_view_expression_assertion.test
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
# name: test/issues/fuzz/recursive_view_expression_assertion.test
|
||||
# description: Issue #3354: Assertion Failed at expression_iterator.cpp:187
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA threads=1
|
||||
|
||||
statement ok
|
||||
create view strings as (with recursive t(a) as (select 1 union select a+1 from t where a < 3) select * from t order by a);
|
||||
|
||||
# this is the original issue #3354 bug
|
||||
statement ok
|
||||
SELECT a, (SELECT a FROM strings i2 WHERE a=(SELECT SUM(a) FROM strings i2 WHERE i2.a>i1.a)) FROM strings i1 ORDER BY 1;
|
||||
|
||||
# related issue #4445 bug
|
||||
statement ok
|
||||
SELECT a, (SELECT a FROM strings i2 RIGHT JOIN (SELECT SUM(a) sum_a FROM strings i2 WHERE i2.a>i1.a) sq ON i2.a = sq.sum_a) FROM strings i1 ORDER BY 1;
|
||||
58
external/duckdb/test/issues/fuzz/sequence_overflow.test
vendored
Normal file
58
external/duckdb/test/issues/fuzz/sequence_overflow.test
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# name: test/issues/fuzz/sequence_overflow.test
|
||||
# description: Issue #3361: signed integer overflow in sequence
|
||||
# group: [fuzz]
|
||||
|
||||
require skip_reload
|
||||
|
||||
statement ok
|
||||
create sequence test INCREMENT BY -1 MINVALUE -9223372036854775808 MAXVALUE -9223372036854775800 CYCLE;
|
||||
|
||||
query I
|
||||
SELECT nextval('test') from generate_series(0,20);
|
||||
----
|
||||
-9223372036854775800
|
||||
-9223372036854775801
|
||||
-9223372036854775802
|
||||
-9223372036854775803
|
||||
-9223372036854775804
|
||||
-9223372036854775805
|
||||
-9223372036854775806
|
||||
-9223372036854775807
|
||||
-9223372036854775808
|
||||
-9223372036854775800
|
||||
-9223372036854775801
|
||||
-9223372036854775802
|
||||
-9223372036854775803
|
||||
-9223372036854775804
|
||||
-9223372036854775805
|
||||
-9223372036854775806
|
||||
-9223372036854775807
|
||||
-9223372036854775808
|
||||
-9223372036854775800
|
||||
-9223372036854775801
|
||||
-9223372036854775802
|
||||
|
||||
query I
|
||||
SELECT nextval('test') from generate_series(0,20);
|
||||
----
|
||||
-9223372036854775803
|
||||
-9223372036854775804
|
||||
-9223372036854775805
|
||||
-9223372036854775806
|
||||
-9223372036854775807
|
||||
-9223372036854775808
|
||||
-9223372036854775800
|
||||
-9223372036854775801
|
||||
-9223372036854775802
|
||||
-9223372036854775803
|
||||
-9223372036854775804
|
||||
-9223372036854775805
|
||||
-9223372036854775806
|
||||
-9223372036854775807
|
||||
-9223372036854775808
|
||||
-9223372036854775800
|
||||
-9223372036854775801
|
||||
-9223372036854775802
|
||||
-9223372036854775803
|
||||
-9223372036854775804
|
||||
-9223372036854775805
|
||||
14
external/duckdb/test/issues/fuzz/sqlite_wrapper_crash.test
vendored
Normal file
14
external/duckdb/test/issues/fuzz/sqlite_wrapper_crash.test
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# name: test/issues/fuzz/sqlite_wrapper_crash.test
|
||||
# description: Issue #3353: NullPointer at sqlite3_api_wrapper.cpp:237:75
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE strings (a INTEGER DEFAULT -1, b INTEGER DEFAULT -2, t0 INTEGER DEFAULT -3);
|
||||
|
||||
statement ok
|
||||
DELETE FROM strings
|
||||
WHERE b IN (SELECT sum(a) FROM strings GROUP BY b)
|
||||
RETURNING *;
|
||||
21
external/duckdb/test/issues/fuzz/stats_propagation_overflow.test
vendored
Normal file
21
external/duckdb/test/issues/fuzz/stats_propagation_overflow.test
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
# name: test/issues/fuzz/stats_propagation_overflow.test
|
||||
# description: Issue #3367: signed integer overflow at propagate_and_compress.cpp:79:37
|
||||
# group: [fuzz]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test(a BIGINT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES(-5361272612100082873);
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES(3877673001272535186);
|
||||
|
||||
query I
|
||||
SELECT a FROM test ORDER BY 1;
|
||||
----
|
||||
-5361272612100082873
|
||||
3877673001272535186
|
||||
60
external/duckdb/test/issues/general/test_1091.test
vendored
Normal file
60
external/duckdb/test/issues/general/test_1091.test
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# name: test/issues/general/test_1091.test
|
||||
# description: Issue 1091: INTERNAL error with insert and delete in same transaction
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE SEQUENCE elems_seq;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE nodes ( id BIGINT PRIMARY KEY, label VARCHAR NOT NULL);
|
||||
|
||||
statement ok
|
||||
CREATE INDEX nodes_label ON nodes (label);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE edges (id BIGINT PRIMARY KEY,from_node_id BIGINT NOT NULL,to_node_id BIGINT NOT NULL,label STRING NOT NULL,UNIQUE (from_node_id, to_node_id, label));
|
||||
|
||||
statement ok
|
||||
CREATE INDEX edges_outgoing ON edges (from_node_id, label);
|
||||
|
||||
statement ok
|
||||
CREATE INDEX edges_incoming ON edges (to_node_id, label);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE properties ( elem_id BIGINT NOT NULL, name VARCHAR NOT NULL, value_boolean BOOLEAN, value_long BIGINT, value_int INTEGER, value_float FLOAT, value_double DOUBLE, value_string VARCHAR, value_blob BLOB, PRIMARY KEY (elem_id, name));
|
||||
|
||||
statement ok
|
||||
CREATE INDEX properties_elemid ON properties (elem_id);
|
||||
|
||||
statement ok
|
||||
INSERT INTO nodes (id, label) SELECT nextval('elems_seq'), 'test';
|
||||
|
||||
statement ok
|
||||
SELECT * FROM nodes;
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
statement ok
|
||||
UPDATE properties SET value_int = 5 WHERE elem_id = 1 AND name = 'x';
|
||||
|
||||
statement ok
|
||||
INSERT INTO properties (elem_id, name, value_int) VALUES (1, 'x', 5);
|
||||
|
||||
statement ok
|
||||
SELECT value_boolean, value_long, value_int, value_float, value_double, value_string, CAST(value_blob AS VARCHAR) FROM properties WHERE elem_id = 1 AND name = 'x';
|
||||
|
||||
statement ok
|
||||
SELECT name FROM properties WHERE elem_id = 1;
|
||||
|
||||
statement ok
|
||||
DELETE FROM properties WHERE elem_id = 1 AND name = 'x';
|
||||
|
||||
statement ok
|
||||
SELECT name FROM properties WHERE elem_id = 1;
|
||||
|
||||
statement ok
|
||||
COMMIT;
|
||||
57
external/duckdb/test/issues/general/test_11280.test_slow
vendored
Normal file
57
external/duckdb/test/issues/general/test_11280.test_slow
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
# name: test/issues/general/test_11280.test_slow
|
||||
# description: Issue 11280: Table size COUNT(*) for VIEWs is larger than that for TABLE created using the same VIEW from partitioned parquet dataset on s3
|
||||
# group: [general]
|
||||
|
||||
require parquet
|
||||
|
||||
require tpch
|
||||
|
||||
statement ok
|
||||
set threads=1;
|
||||
|
||||
statement ok
|
||||
pragma disable_optimizer;
|
||||
|
||||
statement ok
|
||||
call dbgen(sf=0.001);
|
||||
|
||||
statement ok
|
||||
copy (select date_trunc('month', l_shipdate) as partition_shipdate, [l_returnflag, l_linestatus] as string_list, * from lineitem) to '__TEST_DIR__/lineitem_partitioned_test' (format parquet, partition_by(partition_shipdate, l_returnflag));
|
||||
|
||||
statement ok
|
||||
CREATE TABLE unique_strings(string_list VARCHAR[], l_returnflag VARCHAR);
|
||||
|
||||
statement ok
|
||||
INSERT INTO unique_strings VALUES('[R, F]','R');
|
||||
|
||||
statement ok
|
||||
INSERT INTO unique_strings VALUES('[N, F]','N');
|
||||
|
||||
statement ok
|
||||
INSERT INTO unique_strings VALUES('[A, F]','A');
|
||||
|
||||
statement ok
|
||||
INSERT INTO unique_strings VALUES('[N, O]','N');
|
||||
|
||||
statement ok
|
||||
CREATE VIEW parquet_view AS FROM read_parquet('__TEST_DIR__/lineitem_partitioned_test/partition_shipdate=*/l_returnflag=*/*.parquet');
|
||||
|
||||
# works!
|
||||
# after probing 6, the scan structure still has 6 for this one
|
||||
query I
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM parquet_view
|
||||
INNER JOIN unique_strings USING (string_list, l_returnflag);
|
||||
----
|
||||
6005
|
||||
|
||||
# doesn't work
|
||||
# after probing 6, the scan structure goes to 0 for this one
|
||||
query I
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM parquet_view
|
||||
INNER JOIN unique_strings USING (l_returnflag, string_list);
|
||||
----
|
||||
6005
|
||||
8
external/duckdb/test/issues/general/test_11391.test
vendored
Normal file
8
external/duckdb/test/issues/general/test_11391.test
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# name: test/issues/general/test_11391.test
|
||||
# description: Issue 11391: Catalog Error with nested CTEs
|
||||
# group: [general]
|
||||
|
||||
query I
|
||||
with foo as (with foo as (select 1) select * from foo) select * from foo;
|
||||
----
|
||||
1
|
||||
18
external/duckdb/test/issues/general/test_11566.test
vendored
Normal file
18
external/duckdb/test/issues/general/test_11566.test
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# name: test/issues/general/test_11566.test
|
||||
# description: Issue 11566: Assertion failure when using DISTINCT ON + ORDER BY with JSON column
|
||||
# group: [general]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
SELECT typeof(arg_min({foo: 'bar'}::JSON, 1));
|
||||
----
|
||||
JSON
|
||||
|
||||
query II
|
||||
SELECT DISTINCT ON (my_row_id) my_row_id, value FROM (SELECT * FROM (VALUES ('1', {foo: 'bar'}::JSON, 1), ('1', {foo: 'baz'}::JSON, 2), ) AS t(my_row_id, value, idx)) ORDER BY idx;
|
||||
----
|
||||
1 {"foo":"bar"}
|
||||
122
external/duckdb/test/issues/general/test_1248.test
vendored
Normal file
122
external/duckdb/test/issues/general/test_1248.test
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
# name: test/issues/general/test_1248.test
|
||||
# description: Issue 1248: Segmentation fault on subselects with "recursive"
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement error
|
||||
with test(round) as (
|
||||
select 0
|
||||
union all
|
||||
select round+1 from test where round <= 20
|
||||
)
|
||||
select test.round
|
||||
from
|
||||
(select round from test limit 1) as subselect,
|
||||
test;
|
||||
----
|
||||
|
||||
query I
|
||||
with test(round) as (
|
||||
select 0
|
||||
)
|
||||
select test.round
|
||||
from
|
||||
(select round from test limit 1) as subselect,
|
||||
test;
|
||||
----
|
||||
0
|
||||
|
||||
query II
|
||||
with test(round) as (
|
||||
select 0
|
||||
)
|
||||
select *
|
||||
from
|
||||
test t1,
|
||||
test t2;
|
||||
----
|
||||
0 0
|
||||
|
||||
query I
|
||||
with recursive test(round) as (
|
||||
select 0
|
||||
union all
|
||||
select round+1 from test where round <= 20
|
||||
)
|
||||
select test.round
|
||||
from
|
||||
test
|
||||
order by all;
|
||||
----
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20
|
||||
21
|
||||
|
||||
query I
|
||||
with recursive test(round) as (
|
||||
select 0
|
||||
union all
|
||||
select round+1 from test where round <= 20
|
||||
)
|
||||
select count(*)
|
||||
from
|
||||
(select round from test limit 1) as subselect,
|
||||
test;
|
||||
----
|
||||
22
|
||||
|
||||
query II
|
||||
with recursive test(round) as (
|
||||
select 0
|
||||
union all
|
||||
select round+1 from test where round <= 20
|
||||
)
|
||||
select *
|
||||
from
|
||||
(select round from test limit 1) as subselect,
|
||||
test
|
||||
order by all;
|
||||
----
|
||||
0 0
|
||||
0 1
|
||||
0 2
|
||||
0 3
|
||||
0 4
|
||||
0 5
|
||||
0 6
|
||||
0 7
|
||||
0 8
|
||||
0 9
|
||||
0 10
|
||||
0 11
|
||||
0 12
|
||||
0 13
|
||||
0 14
|
||||
0 15
|
||||
0 16
|
||||
0 17
|
||||
0 18
|
||||
0 19
|
||||
0 20
|
||||
0 21
|
||||
123
external/duckdb/test/issues/general/test_1290.test
vendored
Normal file
123
external/duckdb/test/issues/general/test_1290.test
vendored
Normal file
@@ -0,0 +1,123 @@
|
||||
# name: test/issues/general/test_1290.test
|
||||
# description: Issue 1290: FULL JOIN reports missing values for join key
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table a as select 42 as i, 80 as j;
|
||||
|
||||
statement ok
|
||||
create table b as select 43 as i, 84 as k;
|
||||
|
||||
statement ok
|
||||
create table c as select 44 as i, 84 as l;
|
||||
|
||||
query III
|
||||
select i, a.i, b.i from a inner join b using (i);
|
||||
----
|
||||
|
||||
query III
|
||||
select i, a.i, b.i from a left outer join b using (i);
|
||||
----
|
||||
42 42 NULL
|
||||
|
||||
query III
|
||||
select i, a.i, b.i from a right outer join b using (i);
|
||||
----
|
||||
43 NULL 43
|
||||
|
||||
query III
|
||||
select i, a.i, b.i from a natural full outer join b order by 1;
|
||||
----
|
||||
42 42 NULL
|
||||
43 NULL 43
|
||||
|
||||
query III
|
||||
select i, a.i, b.i from a full outer join b using (i) order by 1;
|
||||
----
|
||||
42 42 NULL
|
||||
43 NULL 43
|
||||
|
||||
query III
|
||||
select * from a full outer join b using (i) order by 1;
|
||||
----
|
||||
42 80 NULL
|
||||
43 NULL 84
|
||||
|
||||
query IIII
|
||||
select i, a.i, b.i, c.i from a full outer join b using (i) full outer join c using (i) order by 1;
|
||||
----
|
||||
42 42 NULL NULL
|
||||
43 NULL 43 NULL
|
||||
44 NULL NULL 44
|
||||
|
||||
query IIII
|
||||
select * from a full outer join b using (i) full outer join c using (i) order by 1;
|
||||
----
|
||||
42 80 NULL NULL
|
||||
43 NULL 84 NULL
|
||||
44 NULL NULL 84
|
||||
|
||||
query IIII
|
||||
select i, a.i, b.i, c.i from a natural full outer join b natural full outer join (values (42)) c(i) order by 1;
|
||||
----
|
||||
42 42 NULL 42
|
||||
43 NULL 43 NULL
|
||||
|
||||
query IIII
|
||||
select i, a.i, b.i, c.i from a natural full outer join b natural full outer join (values (43)) c(i) order by 1;
|
||||
----
|
||||
42 42 NULL NULL
|
||||
43 NULL 43 43
|
||||
|
||||
query IIII
|
||||
select i, a.i, b.i, c.i from a natural full outer join b natural full outer join (values (44)) c(i) order by 1;
|
||||
----
|
||||
42 42 NULL NULL
|
||||
43 NULL 43 NULL
|
||||
44 NULL NULL 44
|
||||
|
||||
query IIII
|
||||
select i, a.i, b.i, c.i from a natural full outer join b natural full outer join c order by 1;
|
||||
----
|
||||
42 42 NULL NULL
|
||||
43 NULL 43 NULL
|
||||
44 NULL NULL 44
|
||||
|
||||
query IIII
|
||||
select * from a natural full outer join b natural full outer join c order by 1;
|
||||
----
|
||||
42 80 NULL NULL
|
||||
43 NULL 84 NULL
|
||||
44 NULL NULL 84
|
||||
|
||||
# right join
|
||||
query III
|
||||
select * from a natural right outer join b order by 1;
|
||||
----
|
||||
43 NULL 84
|
||||
|
||||
query IIIII
|
||||
select * from a, b natural right outer join c;
|
||||
----
|
||||
42 80 44 NULL 84
|
||||
|
||||
query IIIIIIIIII
|
||||
select *, * from a, b natural right outer join c;
|
||||
----
|
||||
42 80 44 NULL 84 42 80 44 NULL 84
|
||||
|
||||
query IIIIII
|
||||
select a.*, b.*, c.* from a, b natural right outer join c;
|
||||
----
|
||||
42 80 NULL NULL 44 84
|
||||
|
||||
query IIIIII
|
||||
select * from a natural full outer join b, a a1 natural full outer join c order by all;
|
||||
----
|
||||
42 80 NULL 42 80 NULL
|
||||
42 80 NULL 44 NULL 84
|
||||
43 NULL 84 42 80 NULL
|
||||
43 NULL 84 44 NULL 84
|
||||
13
external/duckdb/test/issues/general/test_13252.test
vendored
Normal file
13
external/duckdb/test/issues/general/test_13252.test
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
# name: test/issues/general/test_13252.test
|
||||
# description: DuckDB Internal Error with the UNION_EXTRACT
|
||||
# group: [general]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement error
|
||||
WITH tbl1 AS (SELECT NULL AS u) SELECT UNION_EXTRACT(CAST(u AS JSON), 'a') FROM tbl1;
|
||||
----
|
||||
union_extract can only take a union parameter
|
||||
45
external/duckdb/test/issues/general/test_13542.test
vendored
Normal file
45
external/duckdb/test/issues/general/test_13542.test
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# name: test/issues/general/test_13542.test
|
||||
# description: Correlated subquery related? Failed to bind column reference "once_state2" [35.0] (bindings: {#[1.0], #[33.0]})
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table stuff (
|
||||
ts timestamp,
|
||||
item_id int,
|
||||
type text
|
||||
);
|
||||
|
||||
query III
|
||||
with
|
||||
unique_items as (
|
||||
select distinct item_id from stuff
|
||||
),
|
||||
state_stuff as (
|
||||
select
|
||||
item_id,
|
||||
exists (select 1 from stuff c where s.item_id = c.item_id
|
||||
and type = 'state1') as once_state1,
|
||||
exists (select 1 from stuff c where s.item_id = c.item_id
|
||||
and type = 'state2') as once_state2
|
||||
from unique_items s)
|
||||
select * from state_stuff;
|
||||
----
|
||||
|
||||
query III
|
||||
with
|
||||
unique_items as (
|
||||
select distinct item_id from stuff
|
||||
),
|
||||
state_stuff as (
|
||||
select
|
||||
item_id,
|
||||
exists (select 1 from stuff c where s.item_id = c.item_id
|
||||
and type = 'state1') as once_state1,
|
||||
exists (select 1 from stuff c where s.item_id = c.item_id
|
||||
and type = 'state2') as once_state2
|
||||
from unique_items s)
|
||||
select * from state_stuff where not once_state2;
|
||||
----
|
||||
26
external/duckdb/test/issues/general/test_1358.test
vendored
Normal file
26
external/duckdb/test/issues/general/test_1358.test
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# name: test/issues/general/test_1358.test
|
||||
# description: Issue 1358: Binder Error: column xxxx must appear in the GROUP BY clause or be used in an aggregate function
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE planes(tailnum VARCHAR, "year" INTEGER, "type" VARCHAR, manufacturer VARCHAR, model VARCHAR, engines INTEGER, seats INTEGER, speed INTEGER, engine VARCHAR);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE flights("year" INTEGER, "month" INTEGER, "day" INTEGER, dep_time INTEGER, sched_dep_time INTEGER, dep_delay DOUBLE, arr_time INTEGER, sched_arr_time INTEGER, arr_delay DOUBLE, carrier VARCHAR, flight INTEGER, tailnum VARCHAR, origin VARCHAR, dest VARCHAR, air_time DOUBLE, distance DOUBLE, "hour" DOUBLE, "minute" DOUBLE, time_hour TIMESTAMP);
|
||||
|
||||
statement ok
|
||||
SELECT origin, dest,
|
||||
COUNT(flight) AS num_flts,
|
||||
round(SUM(seats)) AS num_seats,
|
||||
round(AVG(arr_delay)) AS avg_delay
|
||||
FROM flights f LEFT OUTER JOIN planes p
|
||||
ON f.tailnum = p.tailnum
|
||||
WHERE distance BETWEEN 200 AND 300
|
||||
AND air_time IS NOT NULL
|
||||
GROUP BY origin, dest
|
||||
HAVING num_flts > 3000
|
||||
ORDER BY num_seats DESC, avg_delay ASC
|
||||
LIMIT 2;
|
||||
37
external/duckdb/test/issues/general/test_13824.test
vendored
Normal file
37
external/duckdb/test/issues/general/test_13824.test
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# name: test/issues/general/test_13824.test
|
||||
# description: min() and max() should use default collation
|
||||
# group: [general]
|
||||
|
||||
require icu
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table test(id int, name text)
|
||||
|
||||
statement ok
|
||||
insert into test values (1, 'a'), (2, 'b'), (3, 'c'), (4, 'A'), (5, 'G'), (6, 'd')
|
||||
|
||||
query I
|
||||
select min(name) from test
|
||||
----
|
||||
A
|
||||
|
||||
query I
|
||||
select max(name) from test
|
||||
----
|
||||
d
|
||||
|
||||
statement ok
|
||||
set default_collation = 'EN_US';
|
||||
|
||||
query I
|
||||
select min(name) from test
|
||||
----
|
||||
a
|
||||
|
||||
query I
|
||||
select max(name) from test
|
||||
----
|
||||
G
|
||||
45
external/duckdb/test/issues/general/test_13938.test
vendored
Normal file
45
external/duckdb/test/issues/general/test_13938.test
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# name: test/issues/general/test_13938.test
|
||||
# description: Issue 13938 - INTERNAL Error: Attempted to dereference unique_ptr that is NULL
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 TIMESTAMP, c1 VARCHAR[]);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c0 FLOAT, c1 TIMESTAMP, c2 FLOAT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0 VALUES('2023-10-10 00:00:00+00:00', NULL);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0 VALUES('2025-12-25 12:00:00+02:00', []), ('2004-07-27 10:00:00+02', []);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0(c1, c0) VALUES([], '2023-01-01 00:00:00+00:00'), ([], '2021-01-01 00:00:00+01');
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0(c1, c0) VALUES([], '2021-01-01 00:00:00+00');
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES(2.71, '1999-12-31 23:59:59', 1.41421356237);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES(1.61803, '1970-01-01 00:00:00', 1.61803);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1(c0) VALUES(1064961652.34), (123.45);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1(c0) VALUES('514332609.12');
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1(c0, c2, c1) VALUES(2.71828, 2.345, '1995-05-23 08:45:00'), ('1308880808', 12.34, '2021-01-01 15:30:45');
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1(c0) VALUES(92857950), (840458867);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES('3.14', '1999-12-31 23:59:59', 3.1415);
|
||||
|
||||
statement ok
|
||||
SELECT * FROM t0 RIGHT JOIN t1 ON(CAST(t1.c1 AS TIMESTAMP) BETWEEN t0.c0 AND t0.c0);
|
||||
56
external/duckdb/test/issues/general/test_14232.test
vendored
Normal file
56
external/duckdb/test/issues/general/test_14232.test
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
# name: test/issues/general/test_14232.test
|
||||
# description: Issue 14232 - Incorrect results for IN clause
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1 (t1a TEXT, t1b SMALLINT, t1c INTEGER, t1d BIGINT,
|
||||
t1e REAL, t1f DOUBLE PRECISION, t1g NUMERIC(10, 2), t1h TIMESTAMP, t1i DATE)
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 (t1a, t1b, t1c, t1d, t1e, t1f, t1g, t1h, t1i) VALUES
|
||||
('t1a', 6, 8, 10, 15.0, 20, 20.00, '2014-04-04 01:00:00', '2014-04-04'),
|
||||
('t1b', 8, 16, 19, 17.0, 25, 26.00, '2014-05-04 01:01:00', '2014-05-04'),
|
||||
('t1a', 16, 12, 21, 15.0, 20, 20.00, '2014-06-04 01:02:00.001', '2014-06-04'),
|
||||
('t1a', 16, 12, 10, 15.0, 20, 20.00, '2014-07-04 01:01:00', '2014-07-04'),
|
||||
('t1c', 8, 16, 19, 17.0, 25, 26.00, '2014-05-04 01:02:00.001', '2014-05-05'),
|
||||
('t1d', NULL, 16, 22, 17.0, 25, 26.00, '2014-06-04 01:01:00', NULL),
|
||||
('t1d', NULL, 16, 19, 17.0, 25, 26.00, '2014-07-04 01:02:00.001', NULL),
|
||||
('t1e', 10, NULL, 25, 17.0, 25, 26.00, '2014-08-04 01:01:00', '2014-08-04'),
|
||||
('t1e', 10, NULL, 19, 17.0, 25, 26.00, '2014-09-04 01:02:00.001', '2014-09-04'),
|
||||
('t1d', 10, NULL, 12, 17.0, 25, 26.00, '2015-05-04 01:01:00', '2015-05-04'),
|
||||
('t1a', 6, 8, 10, 15.0, 20, 20.00, '2014-04-04 01:02:00.001', '2014-04-04'),
|
||||
('t1e', 10, NULL, 19, 17.0, 25, 26.00, '2014-05-04 01:01:00', '2014-05-04')
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t2 (t2a TEXT, t2b SMALLINT, t2c INTEGER, t2d BIGINT,
|
||||
t2e REAL, t2f DOUBLE PRECISION, t2g NUMERIC(10, 2), t2h TIMESTAMP, t2i DATE)
|
||||
|
||||
statement ok
|
||||
INSERT INTO t2 (t2a, t2b, t2c, t2d, t2e, t2f, t2g, t2h, t2i) VALUES
|
||||
('t2a', 6, 12, 14, 15.0, 20, 20.00, '2014-04-04 01:01:00', '2014-04-04'),
|
||||
('t1b', 10, 12, 19, 17.0, 25, 26.00, '2014-05-04 01:01:00', '2014-05-04'),
|
||||
('t1b', 8, 16, 119, 17.0, 25, 26.00, '2015-05-04 01:01:00', '2015-05-04'),
|
||||
('t1c', 12, 16, 219, 17.0, 25, 26.00, '2016-05-04 01:01:00', '2016-05-04'),
|
||||
('t1b', NULL, 16, 319, 17.0, 25, 26.00, '2017-05-04 01:01:00', NULL),
|
||||
('t2e', 8, NULL, 419, 17.0, 25, 26.00, '2014-06-04 01:01:00', '2014-06-04'),
|
||||
('t1f', 19, NULL, 519, 17.0, 25, 26.00, '2014-05-04 01:01:00', '2014-05-04'),
|
||||
('t1b', 10, 12, 19, 17.0, 25, 26.00, '2014-06-04 01:01:00', '2014-06-04'),
|
||||
('t1b', 8, 16, 19, 17.0, 25, 26.00, '2014-07-04 01:01:00', '2014-07-04'),
|
||||
('t1c', 12, 16, 19, 17.0, 25, 26.00, '2014-08-04 01:01:00', '2014-08-05'),
|
||||
('t1e', 8, NULL, 19, 17.0, 25, 26.00, '2014-09-04 01:01:00', '2014-09-04'),
|
||||
('t1f', 19, NULL, 19, 17.0, 25, 26.00, '2014-10-04 01:01:00', '2014-10-04'),
|
||||
('t1b', NULL, 16, 19, 17.0, 25, 26.00, '2014-05-04 01:01:00', NULL)
|
||||
|
||||
query II rowsort
|
||||
SELECT t1a,
|
||||
t1b
|
||||
FROM t1
|
||||
WHERE t1c IN (SELECT t2c
|
||||
FROM t2
|
||||
WHERE t1a = t2a)
|
||||
GROUP BY t1a,
|
||||
t1b,
|
||||
ORDER BY t1a
|
||||
----
|
||||
t1b 8
|
||||
t1c 8
|
||||
44
external/duckdb/test/issues/general/test_14244.test
vendored
Normal file
44
external/duckdb/test/issues/general/test_14244.test
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# name: test/issues/general/test_14244.test
|
||||
# description: Issue 14244 - 'with recursive cte' within a function bleeds into subsequent 'with recursive cte'
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification;
|
||||
|
||||
statement ok
|
||||
create or replace function fun() as table (
|
||||
with recursive cte(i) as (
|
||||
select 0 AS i
|
||||
union all
|
||||
select 1234 AS i
|
||||
)
|
||||
select max(i) from cte
|
||||
);
|
||||
|
||||
query II
|
||||
with recursive cte(i, j) as (
|
||||
select 0 as i, 0 as j
|
||||
union all
|
||||
select i + 1 AS i, (from fun()) AS j
|
||||
from cte
|
||||
where i = 0
|
||||
)
|
||||
select * from cte
|
||||
ORDER BY all
|
||||
----
|
||||
0 0
|
||||
1 1234
|
||||
|
||||
query II
|
||||
with recursive differentName(i, j) as (
|
||||
select 0 as i, 0 as j
|
||||
union all
|
||||
select i + 1 AS i, (from fun()) AS j
|
||||
from differentName
|
||||
where i = 0
|
||||
)
|
||||
select * from differentName
|
||||
ORDER BY all
|
||||
----
|
||||
0 0
|
||||
1 1234
|
||||
27
external/duckdb/test/issues/general/test_1427.test
vendored
Normal file
27
external/duckdb/test/issues/general/test_1427.test
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# name: test/issues/general/test_1427.test
|
||||
# description: Issue 1427: Segment Fault Crash when select a view (which has IN statement)
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table t as select 123 as a
|
||||
|
||||
statement ok
|
||||
select * from (select 123 as a) t where a in (select 123 );
|
||||
|
||||
statement ok
|
||||
select * from t where a in (select 123 );
|
||||
|
||||
statement ok
|
||||
create view t0 as select * from t where a in (select 123 );
|
||||
|
||||
statement ok
|
||||
select * from t0
|
||||
|
||||
statement ok
|
||||
create view t1 as select * from (select 123 as a) t where a in (select 123 );
|
||||
|
||||
statement ok
|
||||
select * from t1
|
||||
19
external/duckdb/test/issues/general/test_14286.test
vendored
Normal file
19
external/duckdb/test/issues/general/test_14286.test
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# name: test/issues/general/test_14286.test
|
||||
# description: Issue 14286 - An error was encountered using both distinct and struct
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
WITH cte(category, a_list, b_list, c_list) AS (
|
||||
SELECT
|
||||
category,
|
||||
array_agg(DISTINCT name) FILTER(WHERE id != 5) AS a_list,
|
||||
array_agg(name) FILTER(WHERE id != 5) AS b_list,
|
||||
array_agg({'id': id, 'name': name, 'catetory': category}) AS c_list
|
||||
FROM (
|
||||
SELECT 1 AS id, '大熊猫' AS name, '熊' AS category UNION ALL
|
||||
SELECT 2 AS id, '大熊猫' AS name, '猫' AS category UNION ALL
|
||||
SELECT 3 AS id, '小熊猫' AS name, '猫' AS category
|
||||
) t
|
||||
GROUP BY category)
|
||||
SELECT category, list_sort(a_list), list_sort(b_list), list_sort(c_list)
|
||||
FROM cte ORDER BY ALL
|
||||
43
external/duckdb/test/issues/general/test_14540.test
vendored
Normal file
43
external/duckdb/test/issues/general/test_14540.test
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
# name: test/issues/general/test_14540.test
|
||||
# description: Issue 14540 - INTERNAL Error: Failed to bind column reference(a unnest rewriter fail)
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE QueryRequest AS SELECT * FROM (
|
||||
|
||||
SELECT
|
||||
['A', 'B']::text[] AS query_request
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
['A']::text[] AS query_request
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
['B']::text[] AS query_request
|
||||
|
||||
) AS UNUSED_TABLE_NAME;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE ObjectAttributes AS SELECT
|
||||
'zero' AS object_id,
|
||||
['a']::text[] AS logica_value;
|
||||
|
||||
query IIII rowsort
|
||||
SELECT
|
||||
QueryRequest.query_request AS query_request,
|
||||
ObjectAttributes.object_id AS object_id,
|
||||
ObjectAttributes.logica_value AS object_attributes,
|
||||
count(DISTINCT x_9.unnested_pod) AS attributes_union
|
||||
FROM
|
||||
QueryRequest AS QueryRequest, ObjectAttributes AS ObjectAttributes, (select unnest(((ObjectAttributes.logica_value) || (QueryRequest.query_request))) as unnested_pod) as x_9
|
||||
WHERE
|
||||
(ObjectAttributes.object_id = 'zero')
|
||||
GROUP BY QueryRequest.query_request, ObjectAttributes.object_id, ObjectAttributes.logica_value;
|
||||
----
|
||||
[A, B] zero [a] 3
|
||||
[A] zero [a] 2
|
||||
[B] zero [a] 2
|
||||
18
external/duckdb/test/issues/general/test_15416.test
vendored
Normal file
18
external/duckdb/test/issues/general/test_15416.test
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# name: test/issues/general/test_15416.test
|
||||
# description: Issue 15416 - CTE does implicit and unexpected cross join when referencing columns that aren't in the table in the from clause
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement error
|
||||
WITH cte AS (
|
||||
SELECT x
|
||||
)
|
||||
SELECT
|
||||
b.x
|
||||
FROM
|
||||
(SELECT 1) _(x),
|
||||
LATERAL (SELECT * FROM cte) b(x)
|
||||
----
|
||||
Referenced column "x" not found in FROM clause!
|
||||
28
external/duckdb/test/issues/general/test_15432.test
vendored
Normal file
28
external/duckdb/test/issues/general/test_15432.test
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
# name: test/issues/general/test_15432.test
|
||||
# description: Issue 15432 - Regression bug (V1.1.4 vs V1.0 and V1.0): binder error references non-existent call to sum()
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE function transpose(lst) AS (
|
||||
SELECT list_transform(range(1, 1 + length(lst[1])),
|
||||
lambda j: list_transform(range(1, length(lst) + 1),
|
||||
lambda i: lst[i][j]
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE function centroid(points) AS (
|
||||
list_transform(transpose(points),
|
||||
lambda x: list_sum(x) / length(points)
|
||||
)
|
||||
);
|
||||
|
||||
query II
|
||||
SELECT points, centroid(points)
|
||||
FROM UNNEST([[[1], [2], [3]]]) t(points);
|
||||
----
|
||||
[[1], [2], [3]] [2.0]
|
||||
49
external/duckdb/test/issues/general/test_15483.test
vendored
Normal file
49
external/duckdb/test/issues/general/test_15483.test
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# name: test/issues/general/test_15483.test
|
||||
# description: Issue 15483 - internal error with recursive SQL query
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification;
|
||||
|
||||
query II
|
||||
with recursive aoc6_input(i) as (select E'....#.....\n.........#\n..........\n..#.......\n.......#..\n..........\n.#..^.....\n........#.\n#.........\n......#...\n'),
|
||||
lines(y,line) as (
|
||||
select 0, substr(i,1,position(E'\n' in i)-1), substr(i,position(E'\n' in i)+1)
|
||||
from aoc6_input
|
||||
union all
|
||||
select y+1,substr(r,1,position(E'\n' in r)-1), substr(r,position(E'\n' in r)+1)
|
||||
from lines l(y,l,r) where position(E'\n' in r)>0
|
||||
),
|
||||
rawfield(x,y,v) as (
|
||||
select x::smallint,y::smallint,substr(line,x::integer,1)
|
||||
from (select * from lines l where line<>'') l, lateral generate_series(1,length(line)) g(x)
|
||||
),
|
||||
field(x,y,v) as (select x,y,case when v='^' then '.' else v end from rawfield),
|
||||
startpos(x,y) as (select x,y from rawfield where v='^'),
|
||||
bounds(maxx,maxy) as (select max(x) as maxx, max(y) as maxy from field),
|
||||
directions(dd,dx,dy) as (values(0,0::smallint,-1::smallint),(1,1::smallint,0::smallint),(2,0::smallint,1::smallint),(3,-1::smallint,0::smallint)),
|
||||
part1(px,py,pd) as (
|
||||
select x,y,0 from startpos
|
||||
union all
|
||||
select case when s then px+dx else px end, case when s then py+dy else py end, case when s then pd else (pd+1)%4 end
|
||||
from (select *, f.v is distinct from '#' as s
|
||||
from (part1 p join directions d on pd=dd) left join field f on f.x=px+dx and f.y=py+dy), bounds b
|
||||
where px>0 and py>0 and px<=maxx and py<=maxy
|
||||
),
|
||||
part1pos(vx,vy) as (select distinct px, py from part1, bounds where px>0 and py>0 and px<=maxx and py<=maxy),
|
||||
candidates(vx,vy) as (select * from part1pos, startpos where vx<>x or vy<>y)
|
||||
select (select count(*) from part1pos) as part1,
|
||||
(select count(*) from
|
||||
candidates as c where not exists (
|
||||
with recursive part2(px,py,pd) as (
|
||||
select x,y,0 from startpos
|
||||
union
|
||||
select case when s then px+dx else px end, case when s then py+dy else py end, case when s then pd else (pd+1)%4 end
|
||||
from (select *, (f.v is distinct from '#' and ((px+dx<>vx) or (py+dy<>vy))) as s
|
||||
from (part2 p join directions d on pd=dd) left join field f on f.x=px+dx and f.y=py+dy), bounds b
|
||||
where px>0 and py>0 and px<=maxx and py<=maxy
|
||||
)
|
||||
select * from part2, bounds where px<1 or py<1 or px>maxx or py>maxy
|
||||
)) as part2;
|
||||
----
|
||||
41 6
|
||||
67
external/duckdb/test/issues/general/test_1599.test
vendored
Normal file
67
external/duckdb/test/issues/general/test_1599.test
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
# name: test/issues/general/test_1599.test
|
||||
# description: Issue 1599: Update + Transactions raises RuntimeError: Not implemented Error: operator
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
start transaction;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1 (i INTEGER, j INTEGER);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t2 (i INTEGER, j INTEGER, id INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (0, 0);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (1, 1);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (2, 2);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t2 VALUES (0, 0, 0);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t2 VALUES (1, 1, 1);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t2 VALUES (2, 2, 2);
|
||||
|
||||
statement ok
|
||||
ALTER TABLE t1 ADD COLUMN ref INTEGER;
|
||||
|
||||
query III
|
||||
select * from t1
|
||||
----
|
||||
0 0 NULL
|
||||
1 1 NULL
|
||||
2 2 NULL
|
||||
|
||||
statement ok
|
||||
UPDATE "t1" SET "ref" = (
|
||||
SELECT "id"
|
||||
FROM "t2"
|
||||
WHERE "t2"."i" == "t1"."i" AND "t2"."j" == "t1"."j"
|
||||
);
|
||||
|
||||
query III
|
||||
select * from t1
|
||||
----
|
||||
0 0 0
|
||||
1 1 1
|
||||
2 2 2
|
||||
|
||||
statement ok
|
||||
commit;
|
||||
|
||||
query III
|
||||
select * from t1
|
||||
----
|
||||
0 0 0
|
||||
1 1 1
|
||||
2 2 2
|
||||
26
external/duckdb/test/issues/general/test_1613.test
vendored
Normal file
26
external/duckdb/test/issues/general/test_1613.test
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# name: test/issues/general/test_1613.test
|
||||
# description: Issue 1613: Millisecond format specifier in strftime, %g , doesn't work for most of the timestamp values and returns invalid UTF8
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
select strftime(timestamp '2021-04-15 14:55:17.915', '%Y-%m-%d %H:%M:%S.%g')
|
||||
----
|
||||
2021-04-15 14:55:17.915
|
||||
|
||||
query I
|
||||
select strftime(timestamp '2021-04-15 14:55:17.915', '%Y-%m-%d %H:%M:%S.%f')
|
||||
----
|
||||
2021-04-15 14:55:17.915000
|
||||
|
||||
query I
|
||||
select strptime('2021-04-15 14:55:17.915', '%Y-%m-%d %H:%M:%S.%g')
|
||||
----
|
||||
2021-04-15 14:55:17.915
|
||||
|
||||
query I
|
||||
select strptime('2021-04-15 14:55:17.915000', '%Y-%m-%d %H:%M:%S.%f')
|
||||
----
|
||||
2021-04-15 14:55:17.915
|
||||
58
external/duckdb/test/issues/general/test_16213.test_slow
vendored
Normal file
58
external/duckdb/test/issues/general/test_16213.test_slow
vendored
Normal file
@@ -0,0 +1,58 @@
|
||||
# name: test/issues/general/test_16213.test_slow
|
||||
# description: Issue 16213 - Specific query not finishing since v1.1.0 and filling up all temp disk space
|
||||
# group: [general]
|
||||
|
||||
require no_extension_autoloading "EXPECTED: ICU casts to Date do not trigger autoloading"
|
||||
|
||||
require icu
|
||||
|
||||
# replicate date generation in issue, but in SQL
|
||||
statement ok
|
||||
create table records as
|
||||
select
|
||||
range id,
|
||||
to_timestamp(1514764800 + range / 1_000_000 * (1704067200 - 1514764800)) as creation_dt,
|
||||
creation_dt::date as creation_day,
|
||||
printf('%02X', range % 200) category,
|
||||
from range(1_000_000);
|
||||
|
||||
statement ok
|
||||
create table labels as
|
||||
select
|
||||
id,
|
||||
creation_dt + (1 * 60 * 60 + random() * (125 * 24 * 60 * 60 - 1 * 60 * 60) || ' seconds')::interval as label_dt,
|
||||
1::bigint as label,
|
||||
from (
|
||||
from records
|
||||
using sample 50_000
|
||||
);
|
||||
|
||||
# this should not time out
|
||||
statement ok
|
||||
with
|
||||
day_cat_rows as
|
||||
(select category,
|
||||
creation_day
|
||||
from records
|
||||
group by category,
|
||||
creation_day),
|
||||
recs as
|
||||
(select category,
|
||||
records.creation_dt,
|
||||
labels.label_dt,
|
||||
labels.label
|
||||
from records
|
||||
left join labels on labels.id = records.id),
|
||||
counts as
|
||||
(select day_cat_rows.creation_day,
|
||||
category,
|
||||
(select count(1)
|
||||
from recs
|
||||
where recs.creation_dt > day_cat_rows.creation_day - '30 days'::interval
|
||||
and recs.creation_dt <= day_cat_rows.creation_day
|
||||
and recs.category = day_cat_rows.category
|
||||
and recs.label_dt <= day_cat_rows.creation_day
|
||||
and recs.label = 1) as num_labeled_30d,
|
||||
from day_cat_rows)
|
||||
select *
|
||||
from counts;
|
||||
26
external/duckdb/test/issues/general/test_16257.test_slow
vendored
Normal file
26
external/duckdb/test/issues/general/test_16257.test_slow
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# name: test/issues/general/test_16257.test_slow
|
||||
# description: Issue 16257 - value count mismatch when writing DELTA_BINARY_PACKED
|
||||
# group: [general]
|
||||
|
||||
require parquet
|
||||
|
||||
# Some macros to generate lorem ipsum
|
||||
statement ok
|
||||
CREATE OR REPLACE MACRO deterministic_random(rand) AS hash(rand) / 18446744073709551615;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE MACRO lorem_word(rand) AS ['voluptatem', 'quaerat', 'quiquia', 'non', 'dolore', 'dolorem', 'labore', 'consectetur', 'porro', 'sed', 'numquam', 'aliquam', 'sit', 'eius', 'modi', 'est', 'amet', 'magnam', 'dolor', 'etincidunt', 'velit', 'neque', 'ipsum', 'adipisci', 'quisquam', 'ut', 'tempora'][1 + floor(rand * 27 % 27)::BIGINT];
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE MACRO lorem_sentence_util(s) AS upper(s[1]) || s[2:] || '.';
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE MACRO lorem_sentence(rand, words) AS lorem_sentence_util(list_aggr([lorem_word(deterministic_random(rand + i)) for i in range(words)], 'string_agg', ' '));
|
||||
|
||||
|
||||
statement ok
|
||||
SET preserve_insertion_order=false;
|
||||
|
||||
# added NULLs for issue #16306
|
||||
statement ok
|
||||
COPY (SELECT CASE WHEN random() < 0.01 THEN NULL ELSE lorem_sentence(random(), 20) END FROM range(1_000_000)) TO '__TEST_DIR__/16257.parquet' (PARQUET_VERSION V2, ROW_GROUP_SIZE 2_000_000);
|
||||
24
external/duckdb/test/issues/general/test_16524.test
vendored
Normal file
24
external/duckdb/test/issues/general/test_16524.test
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# name: test/issues/general/test_16524.test
|
||||
# description: Issue 16524 - DuckDB internal error with a relatively complex JOIN involving lateral subqueries
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE INT8_TBL(q1 int8, q2 int8);
|
||||
|
||||
statement ok
|
||||
INSERT INTO INT8_TBL VALUES
|
||||
(' 123 ',' 456'),
|
||||
('123 ','4567890123456789'),
|
||||
('4567890123456789','123'),
|
||||
(+4567890123456789,'4567890123456789'),
|
||||
('+4567890123456789','-4567890123456789');
|
||||
|
||||
statement ok
|
||||
select * from
|
||||
int8_tbl c left join (
|
||||
int8_tbl a left join (select q1, coalesce(q2,42) as x from int8_tbl b) ss1
|
||||
on a.q2 = ss1.q1
|
||||
cross join
|
||||
lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2
|
||||
) on c.q2 = ss2.q1,
|
||||
lateral (select ss2.y offset 0) ss3
|
||||
63
external/duckdb/test/issues/general/test_16662.test
vendored
Normal file
63
external/duckdb/test/issues/general/test_16662.test
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# name: test/issues/general/test_16662.test
|
||||
# description: Issue 16662 - Unexpected binder error when using a CTE multiple times
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE VIEW
|
||||
"tbl1" AS
|
||||
-- End of EXAMPLE 4 (pt1)
|
||||
WITH
|
||||
data_infra as (
|
||||
select
|
||||
'a' as AMES,
|
||||
'b' as TONG
|
||||
-- Example 6: Unomment out the following line to see it work
|
||||
-- If there is more than one resulting row in the group by then there is not error
|
||||
-- union all
|
||||
-- select
|
||||
-- 'c' as AMES,
|
||||
-- 'b' as TONG
|
||||
--End Example 6
|
||||
-- Example 5: Comment out the following line to see it work
|
||||
-- If there is no group by then there is an error
|
||||
group by
|
||||
1
|
||||
-- End of Example 5
|
||||
)
|
||||
SELECT
|
||||
-- Example 1: Comment the following lines to see it work
|
||||
-- If the CTE is used only once then there is no error
|
||||
case
|
||||
when 'b' in (
|
||||
select
|
||||
TONG
|
||||
from
|
||||
data_infra
|
||||
) then 'tong'
|
||||
else 'Various'
|
||||
end as collapsed_TONG,
|
||||
--- End of Example 1
|
||||
-- Example 2: Comment the following lines to see it work
|
||||
-- If the CTE is used only once then there is no error
|
||||
case
|
||||
when 'ba' in (
|
||||
select
|
||||
TONG
|
||||
from
|
||||
data_infra
|
||||
) then 'ames'
|
||||
else null
|
||||
end as collapsed_AMES,
|
||||
--- End of Example 2
|
||||
-- Example 3: Delete this line to see it work
|
||||
-- If there is no null column there is no error
|
||||
NULL AS NULL_COL;
|
||||
|
||||
statement ok
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
"tbl1";
|
||||
18
external/duckdb/test/issues/general/test_16783.test
vendored
Normal file
18
external/duckdb/test/issues/general/test_16783.test
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# name: test/issues/general/test_16783.test
|
||||
# description: Issue 16783 - Anti-join meets INTERNAL Error: Attempted to dereference unique_ptr that is NULL
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 FLOAT);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c0 FLOAT);
|
||||
|
||||
statement ok
|
||||
select * from t0
|
||||
where not exists(
|
||||
select 1 from t1 where (((((t0.c0) AND ((t1.c0 BETWEEN t0.c0 AND t0.c0)))) OR (((t0.c0) AND ((t1.c0 BETWEEN t0.c0 AND t0.c0))))))
|
||||
);
|
||||
12
external/duckdb/test/issues/general/test_17310.test
vendored
Normal file
12
external/duckdb/test/issues/general/test_17310.test
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
# name: test/issues/general/test_17310.test
|
||||
# description: Issue 17310 - Casting issue from float64 to decimal
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification
|
||||
|
||||
# should not error
|
||||
query I
|
||||
select try_cast('nan'::double as decimal(18,2));
|
||||
----
|
||||
NULL
|
||||
33
external/duckdb/test/issues/general/test_17446.test
vendored
Normal file
33
external/duckdb/test/issues/general/test_17446.test
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# name: test/issues/general/test_17446.test
|
||||
# description: Issue 17446 - multiple joins crash with 'Execute called with a result vector of type INTEGER that does not match expression type VARCHAR'
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma disable_optimizer;
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 varchar);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c0 INT);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t2(c1 INT);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t40(c0 varchar);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0(c0) VALUES ('duckdb');
|
||||
|
||||
statement ok
|
||||
INSERT INTO t2(c1) VALUES (1);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t40(c0) VALUES ('duckdb');
|
||||
|
||||
statement ok
|
||||
SELECT * FROM t0, (SELECT 0) as subQuery0 LEFT JOIN (SELECT t0.c0 AS col_1, t1.c0 AS col_2, t2.c1 AS col_3 FROM t1 RIGHT JOIN t2 ON true) as subQuery1 ON true;
|
||||
29
external/duckdb/test/issues/general/test_17700.test
vendored
Normal file
29
external/duckdb/test/issues/general/test_17700.test
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/issues/general/test_17700.test
|
||||
# description: Issue 17446 - unexpected internal error in multi-join query (ExpressionExecutor::Execute called with a result vector of type BOOLEAN that does not match expression type INTEGER)
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 BOOLEAN);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t2(c1 INT);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t3(c0 INT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t3(c0) VALUES (1);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0(c0) VALUES (TRUE);
|
||||
|
||||
statement ok
|
||||
CREATE VIEW v0(c0, c1, c2) AS SELECT DISTINCT t0.c0 AS col_0, t0.c0 AS col_1, t3.c0 AS col_2 FROM t0, t3;
|
||||
|
||||
statement ok
|
||||
INSERT INTO t2(c1) VALUES (1);
|
||||
|
||||
query IIIII
|
||||
SELECT * FROM t2, v0 INNER JOIN ( SELECT t2.c1 AS col_0 WHERE v0.c2) as subQuery0 ON v0.c2;
|
||||
----
|
||||
1 true true 1 1
|
||||
44
external/duckdb/test/issues/general/test_17757.test
vendored
Normal file
44
external/duckdb/test/issues/general/test_17757.test
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# name: test/issues/general/test_17757.test
|
||||
# description: Issue 17757 - Aggregation filter not working all the time on Linux, but working on MacOS
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE id_mapping (
|
||||
id HUGEINT NOT NULL,
|
||||
child_id HUGEINT NOT NULL
|
||||
) ;
|
||||
|
||||
statement ok
|
||||
INSERT INTO id_mapping (id, child_id)
|
||||
SELECT id, UNNEST(child_ids)
|
||||
FROM (
|
||||
SELECT
|
||||
i AS id,
|
||||
[10000 + i, 20000 + i, 30000 + i] AS child_ids
|
||||
FROM generate_series(1000) t(i)
|
||||
) ;
|
||||
|
||||
statement ok
|
||||
INSERT INTO id_mapping (id, child_id)
|
||||
SELECT id, id FROM id_mapping ;
|
||||
|
||||
query II
|
||||
SELECT
|
||||
id,
|
||||
ARRAY_AGG(child_id) FILTER ( child_id != id )
|
||||
AS child_ids
|
||||
FROM id_mapping
|
||||
GROUP BY id
|
||||
HAVING LENGTH(child_ids) != 3;
|
||||
----
|
||||
|
||||
|
||||
query II
|
||||
SELECT
|
||||
id,
|
||||
ARRAY_AGG(child_id) FILTER ( child_id != id )
|
||||
AS child_ids
|
||||
FROM id_mapping
|
||||
GROUP BY id
|
||||
HAVING LENGTH(child_ids) != 3;
|
||||
----
|
||||
54
external/duckdb/test/issues/general/test_17891.test_slow
vendored
Normal file
54
external/duckdb/test/issues/general/test_17891.test_slow
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
# name: test/issues/general/test_17891.test_slow
|
||||
# description: Issue 17891: JOIN fails on string columns in 1.3.0 but works in 1.2.2
|
||||
# group: [general]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
create view seqs_table_a as from 'data/parquet-testing/seqs_table.parquet';
|
||||
|
||||
statement ok
|
||||
create view seqs_table_b as from 'data/parquet-testing/seqs_table.parquet';
|
||||
|
||||
query I
|
||||
WITH orig AS (
|
||||
SELECT o.id
|
||||
FROM "seqs_table_a" AS o
|
||||
INNER JOIN "seqs_table_b" AS d
|
||||
ON d.key = o.key
|
||||
),
|
||||
dest AS (
|
||||
SELECT o.id
|
||||
FROM "seqs_table_b" AS o
|
||||
INNER JOIN "seqs_table_a" AS d
|
||||
ON d.key = o.key
|
||||
),
|
||||
orig_mm AS (
|
||||
SELECT a.id
|
||||
FROM "seqs_table_a" AS a
|
||||
LEFT JOIN orig AS o
|
||||
ON o.id = a.id
|
||||
WHERE o.id IS NULL
|
||||
),
|
||||
dest_mm AS (
|
||||
SELECT b.id
|
||||
FROM "seqs_table_b" AS b
|
||||
LEFT JOIN dest AS d
|
||||
ON d.id = b.id
|
||||
WHERE d.id IS NULL
|
||||
)
|
||||
SELECT CONCAT_WS(
|
||||
' - ',
|
||||
'orig',
|
||||
o.id
|
||||
) AS mismatch
|
||||
FROM orig_mm AS o
|
||||
UNION
|
||||
SELECT CONCAT_WS(
|
||||
' - ',
|
||||
'dest',
|
||||
d.id
|
||||
) AS mismatch
|
||||
FROM dest_mm AS d
|
||||
----
|
||||
|
||||
23
external/duckdb/test/issues/general/test_18163.test
vendored
Normal file
23
external/duckdb/test/issues/general/test_18163.test
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# name: test/issues/general/test_18163.test
|
||||
# description: Issue 18163 - Deterministic query return undeterministic results
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t90(c0 VARCHAR);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t90(c0) VALUES ('1'), ('2'), ('3'), ('4'), ('5'), ('6'), (0.4501927109298812), (0.55577448732208);
|
||||
|
||||
statement ok
|
||||
CREATE VIEW v0(c0) AS SELECT TAN('1944920781') FROM t90 GROUP BY t90.c0;
|
||||
|
||||
loop i 0 15
|
||||
|
||||
query T
|
||||
SELECT '' FROM v0 HAVING STDDEV_SAMP(0.8716885601427876);
|
||||
----
|
||||
|
||||
endloop
|
||||
39
external/duckdb/test/issues/general/test_18543.test
vendored
Normal file
39
external/duckdb/test/issues/general/test_18543.test
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# name: test/issues/general/test_18543.test
|
||||
# description: Issue 18543 - Incorrect handling with CTE and EXIST
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c0 BOOLEAN)
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t2(c0 BOOLEAN)
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t3(c0 BOOLEAN)
|
||||
|
||||
statement ok
|
||||
INSERT INTO t2(c0) VALUES (true)
|
||||
|
||||
statement ok
|
||||
INSERT INTO t3(c0) VALUES (true)
|
||||
|
||||
|
||||
query I
|
||||
WITH c AS (
|
||||
SELECT *
|
||||
FROM t1
|
||||
WHERE false
|
||||
)
|
||||
SELECT t2.c0
|
||||
FROM t2 CROSS JOIN t3 CROSS JOIN c
|
||||
UNION ALL
|
||||
SELECT t2.c0 FROM t2 CROSS JOIN t3
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM c
|
||||
)
|
||||
----
|
||||
true
|
||||
29
external/duckdb/test/issues/general/test_18703.test
vendored
Normal file
29
external/duckdb/test/issues/general/test_18703.test
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/issues/general/test_18703.test
|
||||
# description: Issue 18703 - DuckDB Crash with Correlated Aggregation inside a WITH clause
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 INT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0 VALUES (1), (0), (NULL);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c0 BOOLEAN);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (TRUE), (FALSE), (NULL);
|
||||
|
||||
query I
|
||||
SELECT * FROM t0
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM t1
|
||||
WHERE (WITH seq(i) AS (VALUES (1)) SELECT SUM(i) * t0.c0 FROM seq) IS NOT NULL
|
||||
) ORDER BY c0;
|
||||
----
|
||||
0
|
||||
1
|
||||
50
external/duckdb/test/issues/general/test_18803.test
vendored
Normal file
50
external/duckdb/test/issues/general/test_18803.test
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# name: test/issues/general/test_18803.test
|
||||
# description: Issue 18803 - MATERIALIZED CTE with FALSE condition causes incorrect empty result in multi-table JOIN
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c INT)
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c INT)
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t2(c INT)
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0 VALUES (1)
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (1)
|
||||
|
||||
statement ok
|
||||
INSERT INTO t2 VALUES (1)
|
||||
|
||||
query I
|
||||
WITH foo AS MATERIALIZED (
|
||||
SELECT 1 AS one
|
||||
FROM t0
|
||||
WHERE FALSE
|
||||
)
|
||||
SELECT t0.c
|
||||
FROM t0
|
||||
JOIN t1 ON TRUE
|
||||
JOIN t2 ON TRUE
|
||||
----
|
||||
1
|
||||
|
||||
query I
|
||||
WITH foo AS MATERIALIZED (
|
||||
SELECT 1 AS one
|
||||
FROM t0
|
||||
WHERE FALSE
|
||||
)
|
||||
SELECT t0.c
|
||||
FROM t0
|
||||
JOIN t1 ON NOT EXISTS (SELECT one FROM foo)
|
||||
JOIN t2 ON NOT EXISTS (SELECT one FROM foo)
|
||||
----
|
||||
1
|
||||
38
external/duckdb/test/issues/general/test_1881.test
vendored
Normal file
38
external/duckdb/test/issues/general/test_1881.test
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# name: test/issues/general/test_1881.test
|
||||
# description: Issue 1881: Segmentation fault, pandas UPDATE with JOIN
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# with random values (original)
|
||||
statement ok
|
||||
create table foo as select (random() * 1000)::int a from range(100000);
|
||||
|
||||
statement ok
|
||||
create table bar as select (random() * 1000)::int a, (random() * 1000)::int b from range(10000);
|
||||
|
||||
statement ok
|
||||
ALTER TABLE foo ADD b INTEGER;
|
||||
|
||||
statement ok
|
||||
UPDATE foo SET b = "bar"."b" FROM "bar" WHERE bar.a = foo.a;
|
||||
|
||||
statement ok
|
||||
drop table foo
|
||||
|
||||
statement ok
|
||||
drop table bar
|
||||
|
||||
# fixed values
|
||||
statement ok
|
||||
create table foo as select * from range(0, 513) tbl(a);
|
||||
|
||||
statement ok
|
||||
create table bar as select a, 1 b from range(0, 513) tbl(a)
|
||||
|
||||
statement ok
|
||||
ALTER TABLE foo ADD b INTEGER;
|
||||
|
||||
statement ok
|
||||
UPDATE foo SET b = "bar"."b" FROM "bar" WHERE bar.a = foo.a;
|
||||
16
external/duckdb/test/issues/general/test_1890.test
vendored
Normal file
16
external/duckdb/test/issues/general/test_1890.test
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# name: test/issues/general/test_1890.test
|
||||
# description: Issue 1890: INTERVAL not working as expected across day boundry
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
SELECT TIMESTAMP '2000-01-01 00:00:00' - INTERVAL 1 MINUTE
|
||||
----
|
||||
1999-12-31 23:59:00
|
||||
|
||||
query I
|
||||
SELECT TIMESTAMP '2000-01-01 23:59:00' + INTERVAL 1 MINUTE
|
||||
----
|
||||
2000-01-02 00:00:00
|
||||
171
external/duckdb/test/issues/general/test_19067.test
vendored
Normal file
171
external/duckdb/test/issues/general/test_19067.test
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
# name: test/issues/general/test_19067.test
|
||||
# description: Issue 19067 - Cascading Views using CTEs High Memory & CPU
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_1 AS
|
||||
SELECT
|
||||
i AS id,
|
||||
i * 10 AS value,
|
||||
'item_' || i AS name,
|
||||
(i % 3) + 1 AS category
|
||||
FROM generate_series(1, 100) AS t(i);
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_2 AS
|
||||
WITH prev1 AS (SELECT * FROM view_1)
|
||||
SELECT
|
||||
*,
|
||||
value * 2 AS double_value
|
||||
FROM prev1;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_3 AS
|
||||
WITH prev2 AS (SELECT * FROM view_2)
|
||||
SELECT
|
||||
*,
|
||||
LENGTH(name) AS name_length
|
||||
FROM prev2;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_4 AS
|
||||
WITH prev3 AS (SELECT * FROM view_3)
|
||||
SELECT
|
||||
*,
|
||||
CASE
|
||||
WHEN category = 1 THEN 'Type A'
|
||||
WHEN category = 2 THEN 'Type B'
|
||||
ELSE 'Type C'
|
||||
END AS category_desc
|
||||
FROM prev3;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_5 AS
|
||||
WITH prev AS (SELECT * FROM view_4)
|
||||
SELECT
|
||||
*,
|
||||
value + id AS sum_value_id
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_6 AS
|
||||
WITH prev AS (SELECT * FROM view_5)
|
||||
SELECT
|
||||
*,
|
||||
UPPER(name) AS name_upper
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_7 AS
|
||||
WITH prev AS (SELECT * FROM view_6)
|
||||
SELECT
|
||||
*,
|
||||
ROW_NUMBER() OVER (ORDER BY id) AS row_num
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_8 AS
|
||||
WITH prev AS (SELECT * FROM view_7)
|
||||
SELECT
|
||||
*,
|
||||
CASE WHEN value > 500 THEN 'HIGH' ELSE 'LOW' END AS value_flag
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_9 AS
|
||||
WITH prev AS (SELECT * FROM view_8)
|
||||
SELECT
|
||||
*,
|
||||
id % 10 AS id_mod_10
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_10 AS
|
||||
WITH prev AS (SELECT * FROM view_9)
|
||||
SELECT
|
||||
*,
|
||||
value / 10 AS value_divided
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_11 AS
|
||||
WITH prev AS (SELECT * FROM view_10)
|
||||
SELECT
|
||||
*,
|
||||
SUBSTRING(name, 1, 4) AS name_prefix
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_12 AS
|
||||
WITH prev AS (SELECT * FROM view_11)
|
||||
SELECT
|
||||
*,
|
||||
AVG(value) OVER () AS avg_value
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_13 AS
|
||||
WITH prev AS (SELECT * FROM view_12)
|
||||
SELECT
|
||||
*,
|
||||
value - avg_value AS diff_from_avg
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_14 AS
|
||||
WITH prev AS (SELECT * FROM view_13)
|
||||
SELECT
|
||||
*,
|
||||
RANK() OVER (ORDER BY value) AS value_rank
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_15 AS
|
||||
WITH prev AS (SELECT * FROM view_14)
|
||||
SELECT
|
||||
*,
|
||||
id % 2 = 0 AS is_even
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_16 AS
|
||||
WITH prev AS (SELECT * FROM view_15)
|
||||
SELECT
|
||||
*,
|
||||
name || '_' || category_desc AS full_name
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_17 AS
|
||||
WITH prev AS (SELECT * FROM view_16)
|
||||
SELECT
|
||||
*,
|
||||
id * id AS id_squared
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_18 AS
|
||||
WITH prev AS (SELECT * FROM view_17)
|
||||
SELECT
|
||||
*,
|
||||
COUNT(*) OVER (PARTITION BY category) AS category_count
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_19 AS
|
||||
WITH prev AS (SELECT * FROM view_18)
|
||||
SELECT
|
||||
*,
|
||||
ROUND((value * 100.0 / sum_value_id), 2) AS value_percentage
|
||||
FROM prev;
|
||||
|
||||
statement ok
|
||||
CREATE OR REPLACE VIEW view_20 AS
|
||||
WITH prev AS (SELECT * FROM view_19)
|
||||
SELECT
|
||||
*,
|
||||
CASE WHEN value_rank <= 10 THEN 'TOP_10' ELSE 'OTHER' END AS final_category
|
||||
FROM prev;
|
||||
68
external/duckdb/test/issues/general/test_19221.test
vendored
Normal file
68
external/duckdb/test/issues/general/test_19221.test
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
# name: test/issues/general/test_19221.test
|
||||
# description: Issue 19221 - Cannot use file_row_number, filename, file_index with WITH ORDINALITY
|
||||
# group: [general]
|
||||
|
||||
require parquet
|
||||
|
||||
statement ok
|
||||
COPY (FROM range(1)) TO '__TEST_DIR__/ordinality_virtual_columns.parquet';
|
||||
|
||||
query II
|
||||
SELECT
|
||||
ordinality,
|
||||
file_row_number,
|
||||
FROM read_parquet('__TEST_DIR__/ordinality_virtual_columns.parquet') WITH ORDINALITY
|
||||
----
|
||||
1 0
|
||||
|
||||
query II
|
||||
SELECT
|
||||
ordinality,
|
||||
filename like '%ordinality_virtual_columns.parquet',
|
||||
FROM read_parquet('__TEST_DIR__/ordinality_virtual_columns.parquet') WITH ORDINALITY
|
||||
----
|
||||
1 true
|
||||
|
||||
query II
|
||||
SELECT
|
||||
ordinality,
|
||||
file_index,
|
||||
FROM read_parquet('__TEST_DIR__/ordinality_virtual_columns.parquet') WITH ORDINALITY
|
||||
----
|
||||
1 0
|
||||
|
||||
query II
|
||||
SELECT
|
||||
ordinality,
|
||||
file_row_number,
|
||||
FROM read_parquet('__TEST_DIR__/ordinality_virtual_columns.parquet', file_row_number = true) WITH ORDINALITY
|
||||
----
|
||||
1 0
|
||||
|
||||
query II
|
||||
SELECT
|
||||
ordinality,
|
||||
filename like '%ordinality_virtual_columns.parquet',
|
||||
FROM read_parquet('__TEST_DIR__/ordinality_virtual_columns.parquet', filename = true) WITH ORDINALITY
|
||||
----
|
||||
1 true
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
ordinality,
|
||||
file_row_number,
|
||||
filename like '%ordinality_virtual_columns.parquet',
|
||||
file_index,
|
||||
FROM read_parquet('__TEST_DIR__/ordinality_virtual_columns.parquet') WITH ORDINALITY
|
||||
----
|
||||
1 0 true 0
|
||||
|
||||
query IIII
|
||||
SELECT
|
||||
ordinality,
|
||||
file_row_number,
|
||||
filename like '%ordinality_virtual_columns.parquet',
|
||||
file_index,
|
||||
FROM read_parquet('__TEST_DIR__/ordinality_virtual_columns.parquet', file_row_number = true, filename = true) WITH ORDINALITY
|
||||
----
|
||||
1 0 true 0
|
||||
41
external/duckdb/test/issues/general/test_1933.test
vendored
Normal file
41
external/duckdb/test/issues/general/test_1933.test
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
# name: test/issues/general/test_1933.test
|
||||
# description: Issue 1933: use INTERVAL function Time out of bounds report error
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
SELECT DATE '2021-06-30' - INTERVAL '4' MONTH;
|
||||
----
|
||||
2021-02-28 00:00:00
|
||||
|
||||
query I
|
||||
SELECT DATE '2021-08-31' + INTERVAL '1' MONTH;
|
||||
----
|
||||
2021-09-30 00:00:00
|
||||
|
||||
query I
|
||||
SELECT DATE '2021-08-31' + INTERVAL '2' MONTH;
|
||||
----
|
||||
2021-10-31 00:00:00
|
||||
|
||||
query I
|
||||
SELECT DATE '2021-08-31' + INTERVAL '3' MONTH;
|
||||
----
|
||||
2021-11-30 00:00:00
|
||||
|
||||
query I
|
||||
SELECT DATE '2021-08-31' + INTERVAL '4' MONTH;
|
||||
----
|
||||
2021-12-31 00:00:00
|
||||
|
||||
query I
|
||||
SELECT DATE '2021-08-31' - INTERVAL '6' MONTH;
|
||||
----
|
||||
2021-02-28 00:00:00
|
||||
|
||||
query I
|
||||
SELECT DATE '2021-08-31' - INTERVAL '18' MONTH;
|
||||
----
|
||||
2020-02-29 00:00:00
|
||||
72
external/duckdb/test/issues/general/test_1987.test
vendored
Normal file
72
external/duckdb/test/issues/general/test_1987.test
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# name: test/issues/general/test_1987.test
|
||||
# description: Issue 1987: Casting decimal column to integer requires explicit 0 decimal specifier
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
create table test (consumption decimal(14,5));
|
||||
|
||||
statement ok
|
||||
insert into test values(17953.2)
|
||||
|
||||
query I
|
||||
select * from test where cast(consumption as int) = 17953
|
||||
----
|
||||
17953.2
|
||||
|
||||
query I
|
||||
select * from test where cast(consumption as int) = 17953.0
|
||||
----
|
||||
17953.2
|
||||
|
||||
query I
|
||||
select * from test where cast(consumption as int) = 17953::decimal(18,5)
|
||||
----
|
||||
17953.2
|
||||
|
||||
query I
|
||||
select * from test where consumption = (17953.2::decimal(18,5))
|
||||
----
|
||||
17953.2
|
||||
|
||||
query I
|
||||
select * from test where consumption::decimal(6,1) = 17953.2
|
||||
----
|
||||
17953.2
|
||||
|
||||
query I
|
||||
select * from test where consumption::decimal(6,1) = (17953.2::decimal(10,2))
|
||||
----
|
||||
17953.2
|
||||
|
||||
query I
|
||||
select * from test where consumption::decimal(6,1)::varchar = '17953.2'
|
||||
----
|
||||
17953.2
|
||||
|
||||
query I
|
||||
select * from test where consumption::varchar::decimal(6,1) = 17953.2
|
||||
----
|
||||
17953.2
|
||||
|
||||
# decimal with scale=0
|
||||
statement ok
|
||||
drop table test
|
||||
|
||||
statement ok
|
||||
create table test (consumption decimal(14,0));
|
||||
|
||||
statement ok
|
||||
insert into test values(17953)
|
||||
|
||||
query I
|
||||
select * from test where cast(consumption as int) = 17953
|
||||
----
|
||||
17953
|
||||
|
||||
query I
|
||||
select * from test where cast(consumption as int) = 17953.0
|
||||
----
|
||||
17953
|
||||
23
external/duckdb/test/issues/general/test_2240.test
vendored
Normal file
23
external/duckdb/test/issues/general/test_2240.test
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# name: test/issues/general/test_2240.test
|
||||
# description: Issue 2240: Exception thrown when inserting and updating a text column in the same row in a transaction
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test (id INTEGER, name TEXT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES (1, 'Bob');
|
||||
|
||||
statement ok
|
||||
UPDATE test SET name = 'Alice' Where id = 1;
|
||||
|
||||
statement ok
|
||||
COMMIT;
|
||||
|
||||
query T
|
||||
select name from test where id = 1;
|
||||
----
|
||||
Alice
|
||||
39
external/duckdb/test/issues/general/test_2407.test
vendored
Normal file
39
external/duckdb/test/issues/general/test_2407.test
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# name: test/issues/general/test_2407.test
|
||||
# description: Issue 2407: arg_max/arg_min doesn't work properly with DATE
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test(d DATE, i INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES ('2021-01-01', 1), ('2021-02-01', 2), ('2021-03-01', 3), ('2021-04-01', 4);
|
||||
|
||||
query II
|
||||
select arg_max(i, d), arg_max(d, i) from test;
|
||||
----
|
||||
4 2021-04-01
|
||||
|
||||
query II
|
||||
select arg_min(i, d), arg_min(d, i) from test;
|
||||
----
|
||||
1 2021-01-01
|
||||
|
||||
# bigint
|
||||
statement ok
|
||||
CREATE TABLE test2(d BIGINT, i INTEGER);
|
||||
|
||||
statement ok
|
||||
INSERT INTO test2 VALUES (-9223372036854775807, 1), (-1, 2), (1, 3), (9223372036854775807, 4);
|
||||
|
||||
query II
|
||||
select arg_max(i, d), arg_max(d, i) from test2;
|
||||
----
|
||||
4 9223372036854775807
|
||||
|
||||
query II
|
||||
select arg_min(i, d), arg_min(d, i) from test2;
|
||||
----
|
||||
1 -9223372036854775807
|
||||
198
external/duckdb/test/issues/general/test_2416.test
vendored
Normal file
198
external/duckdb/test/issues/general/test_2416.test
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
# name: test/issues/general/test_2416.test
|
||||
# description: Issue 2416: Segmentation fault on macro creation
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
select list_extract(null, null);
|
||||
----
|
||||
NULL
|
||||
|
||||
query I
|
||||
select list_extract(null, 1);
|
||||
----
|
||||
NULL
|
||||
|
||||
query I
|
||||
select list_extract([1, 2, 3], NULL);
|
||||
----
|
||||
NULL
|
||||
|
||||
query I
|
||||
SELECT list_extract([1, 2, 3], 2)
|
||||
----
|
||||
2
|
||||
|
||||
query I
|
||||
SELECT list_extract([1, 2, 3], 1)
|
||||
----
|
||||
1
|
||||
|
||||
statement ok
|
||||
PREPARE v1 AS SELECT list_extract($1::int[], 1)
|
||||
|
||||
query I
|
||||
EXECUTE v1([1, 2, 3])
|
||||
----
|
||||
1
|
||||
|
||||
query I
|
||||
EXECUTE v1(NULL)
|
||||
----
|
||||
NULL
|
||||
|
||||
statement ok
|
||||
PREPARE v2 AS SELECT list_extract([1, 2, 3], $1)
|
||||
|
||||
query I
|
||||
EXECUTE v2(2)
|
||||
----
|
||||
2
|
||||
|
||||
query I
|
||||
EXECUTE v2(NULL)
|
||||
----
|
||||
NULL
|
||||
|
||||
statement ok
|
||||
create macro extract_field(my_struct, my_field) as my_struct[my_field];
|
||||
|
||||
query I
|
||||
SELECT extract_field([1, 2, 3], 1)
|
||||
----
|
||||
1
|
||||
|
||||
# the same but with array_length
|
||||
query I
|
||||
select array_length(null);
|
||||
----
|
||||
NULL
|
||||
|
||||
statement ok
|
||||
PREPARE v3 AS SELECT array_length($1::int[])
|
||||
|
||||
query I
|
||||
EXECUTE v3([1, 2, 3])
|
||||
----
|
||||
3
|
||||
|
||||
query I
|
||||
EXECUTE v3(NULL)
|
||||
----
|
||||
NULL
|
||||
|
||||
statement ok
|
||||
PREPARE v4 AS SELECT array_length($1)
|
||||
|
||||
query I
|
||||
EXECUTE v4([1, 2, 3])
|
||||
----
|
||||
3
|
||||
|
||||
statement ok
|
||||
create macro array_l(my_arr) as array_length(my_arr);
|
||||
|
||||
query I
|
||||
SELECT array_l([1, 2, 3])
|
||||
----
|
||||
3
|
||||
|
||||
statement ok
|
||||
CREATE MACRO my_extract(my_nested_type, index_or_field) AS my_nested_type[index_or_field]
|
||||
|
||||
query T
|
||||
SELECT my_extract('1234', 2)
|
||||
----
|
||||
2
|
||||
|
||||
query T
|
||||
SELECT my_extract([1, 2, 3, 4], 2)
|
||||
----
|
||||
2
|
||||
|
||||
query T
|
||||
SELECT my_extract({a: 1, b: 2, c: 3, d: 4}, 'd')
|
||||
----
|
||||
4
|
||||
|
||||
statement ok
|
||||
CREATE MACRO my_list_or_string_extract_2(my_list_or_string) AS my_list_or_string[3]
|
||||
|
||||
query T
|
||||
SELECT my_list_or_string_extract_2('1234')
|
||||
----
|
||||
3
|
||||
|
||||
query T
|
||||
SELECT my_list_or_string_extract_2('12')
|
||||
----
|
||||
(empty)
|
||||
|
||||
query T
|
||||
SELECT my_list_or_string_extract_2([1, 2, 3, 4])
|
||||
----
|
||||
3
|
||||
|
||||
query T
|
||||
SELECT my_list_or_string_extract_2([1, 2])
|
||||
----
|
||||
NULL
|
||||
|
||||
statement error
|
||||
SELECT my_list_or_string_extract_2({a: 1, b: 2, c: 3, d: 4})
|
||||
----
|
||||
<REGEX>:Binder Error.*use a string key.*
|
||||
|
||||
statement ok
|
||||
CREATE MACRO my_struct_extract_c(my_struct) AS my_struct['c']
|
||||
|
||||
query T
|
||||
SELECT my_struct_extract_c({a: 1, b: 2, c: 3, d: 4})
|
||||
----
|
||||
3
|
||||
|
||||
statement error
|
||||
SELECT my_struct_extract_c({a: 1, b: 2, d: 4})
|
||||
----
|
||||
<REGEX>:Binder Error.*Could not find key.*
|
||||
|
||||
statement ok
|
||||
CREATE MACRO my_specific_struct_extract(field) AS struct_pack(a => 1, b => 2, c => 3, d => 4)[field]
|
||||
|
||||
query T
|
||||
SELECT my_specific_struct_extract('c')
|
||||
----
|
||||
3
|
||||
|
||||
statement error
|
||||
SELECT my_specific_struct_extract(2)
|
||||
----
|
||||
<REGEX>:Binder Error.*use a string key instead.*
|
||||
|
||||
statement ok
|
||||
CREATE MACRO my_specific_list_extract(index) AS list_value(1, 2, 3, 4)[index]
|
||||
|
||||
query T
|
||||
SELECT my_specific_list_extract(2)
|
||||
----
|
||||
2
|
||||
|
||||
statement error
|
||||
SELECT my_specific_list_extract('c')
|
||||
----
|
||||
<REGEX>:Conversion Error.*string.*to INT64.*
|
||||
|
||||
statement ok
|
||||
CREATE MACRO my_specific_string_extract(index) AS '1234'[index]
|
||||
|
||||
query T
|
||||
SELECT my_specific_string_extract(2)
|
||||
----
|
||||
2
|
||||
|
||||
statement error
|
||||
SELECT my_specific_string_extract('c')
|
||||
----
|
||||
<REGEX>:Conversion Error.*string.*to INT64.*
|
||||
40
external/duckdb/test/issues/general/test_2496.test
vendored
Normal file
40
external/duckdb/test/issues/general/test_2496.test
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
# name: test/issues/general/test_2496.test
|
||||
# description: Issue 2496: Incorrect Struct Sorting Order on Ties
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE list_str AS
|
||||
SELECT * FROM (VALUES
|
||||
({'x': 'duck', 'y': ''}),
|
||||
({'x': 'duck', 'y': 'goose'})
|
||||
) tbl(i)
|
||||
|
||||
query II
|
||||
SELECT lhs.i, rhs.i
|
||||
FROM list_str lhs, list_str rhs
|
||||
ORDER BY lhs.i, rhs.i
|
||||
----
|
||||
{'x': duck, 'y': ''} {'x': duck, 'y': ''}
|
||||
{'x': duck, 'y': ''} {'x': duck, 'y': goose}
|
||||
{'x': duck, 'y': goose} {'x': duck, 'y': ''}
|
||||
{'x': duck, 'y': goose} {'x': duck, 'y': goose}
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test AS
|
||||
SELECT * FROM (VALUES
|
||||
(['duck', '']),
|
||||
(['duck', 'goose'])
|
||||
) tbl(i)
|
||||
|
||||
query II
|
||||
SELECT lhs.i, rhs.i
|
||||
FROM test lhs, test rhs
|
||||
ORDER BY lhs.i, rhs.i
|
||||
----
|
||||
[duck, ''] [duck, '']
|
||||
[duck, ''] [duck, goose]
|
||||
[duck, goose] [duck, '']
|
||||
[duck, goose] [duck, goose]
|
||||
38
external/duckdb/test/issues/general/test_2554.test_slow
vendored
Normal file
38
external/duckdb/test/issues/general/test_2554.test_slow
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# name: test/issues/general/test_2554.test_slow
|
||||
# description: Issue 2554: a recursive CTE SQL works in Sqlite reports a within error in duckdb
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
WITH RECURSIVE
|
||||
input(sud) AS (
|
||||
VALUES('53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79')
|
||||
),
|
||||
digits(z, lp) AS (
|
||||
VALUES('1', 1)
|
||||
UNION ALL SELECT
|
||||
CAST(lp+1 AS TEXT), lp+1 FROM digits WHERE lp<9
|
||||
),
|
||||
x(s, ind) AS (
|
||||
SELECT sud, instr(sud, '.') FROM input
|
||||
UNION ALL
|
||||
SELECT
|
||||
substr(s, 1, ind::int-1) || z || substr(s, ind::int+1),
|
||||
instr( substr(s, 1, ind::int-1) || z || substr(s, ind::int+1), '.' )
|
||||
FROM x, digits AS z
|
||||
WHERE ind::int>0
|
||||
AND NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM digits AS lp
|
||||
WHERE z.z = substr(s, ((ind::int-1)//9)*9 + lp, 1)
|
||||
OR z.z = substr(s, ((ind::int-1)%9) + (lp-1)*9 + 1, 1)
|
||||
OR z.z = substr(s, (((ind::int-1)//3) % 3) * 3
|
||||
+ ((ind::int-1)//27) * 27 + lp
|
||||
+ ((lp-1) // 3) * 6, 1)
|
||||
)
|
||||
)
|
||||
SELECT s FROM x WHERE ind::int=0;
|
||||
----
|
||||
534678912672195348198342567859761423426853791713924856961537284287419635345286179
|
||||
246
external/duckdb/test/issues/general/test_2743.test
vendored
Normal file
246
external/duckdb/test/issues/general/test_2743.test
vendored
Normal file
@@ -0,0 +1,246 @@
|
||||
# name: test/issues/general/test_2743.test
|
||||
# description: Issue 2743: RuntimeError: Not implemented Error: UNIONS are not supported in recursive CTEs yet
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query II
|
||||
WITH RECURSIVE t(x, y) AS
|
||||
(
|
||||
SELECT 1, 1
|
||||
UNION ALL
|
||||
SELECT 1, 2
|
||||
UNION ALL
|
||||
(SELECT x+1, 1
|
||||
FROM t
|
||||
WHERE x < 10 AND y = 1
|
||||
UNION ALL
|
||||
SELECT x+1, 2
|
||||
FROM t
|
||||
WHERE x < 10 AND y = 2)
|
||||
)
|
||||
SELECT * FROM t ORDER BY x, y;
|
||||
----
|
||||
1 1
|
||||
1 2
|
||||
2 1
|
||||
2 2
|
||||
3 1
|
||||
3 2
|
||||
4 1
|
||||
4 2
|
||||
5 1
|
||||
5 2
|
||||
6 1
|
||||
6 2
|
||||
7 1
|
||||
7 2
|
||||
8 1
|
||||
8 2
|
||||
9 1
|
||||
9 2
|
||||
10 1
|
||||
10 2
|
||||
|
||||
query II
|
||||
WITH RECURSIVE t(x, y) AS
|
||||
(
|
||||
SELECT 1, 1
|
||||
UNION ALL
|
||||
SELECT 1, 2
|
||||
UNION ALL
|
||||
SELECT t, z
|
||||
FROM t, LATERAL
|
||||
(SELECT x+1, 2
|
||||
WHERE t.y = 1
|
||||
UNION ALL
|
||||
SELECT x+1, 1
|
||||
WHERE t.y = 2) AS _(t, z)
|
||||
WHERE t.x < 10
|
||||
)
|
||||
SELECT * FROM t ORDER BY x, y;
|
||||
----
|
||||
1 1
|
||||
1 2
|
||||
2 1
|
||||
2 2
|
||||
3 1
|
||||
3 2
|
||||
4 1
|
||||
4 2
|
||||
5 1
|
||||
5 2
|
||||
6 1
|
||||
6 2
|
||||
7 1
|
||||
7 2
|
||||
8 1
|
||||
8 2
|
||||
9 1
|
||||
9 2
|
||||
10 1
|
||||
10 2
|
||||
|
||||
query II
|
||||
WITH RECURSIVE t(x, y) AS
|
||||
(
|
||||
SELECT 1, 1
|
||||
UNION
|
||||
SELECT 1, 2
|
||||
UNION
|
||||
(SELECT x+1, 1
|
||||
FROM t
|
||||
WHERE x < 10 AND y = 1
|
||||
UNION ALL
|
||||
SELECT x+1, 1
|
||||
FROM t
|
||||
WHERE x < 10 AND y = 2)
|
||||
)
|
||||
SELECT * FROM t ORDER BY x, y;
|
||||
----
|
||||
1 1
|
||||
1 2
|
||||
2 1
|
||||
3 1
|
||||
4 1
|
||||
5 1
|
||||
6 1
|
||||
7 1
|
||||
8 1
|
||||
9 1
|
||||
10 1
|
||||
|
||||
statement ok
|
||||
CREATE TABLE flights (
|
||||
source TEXT,
|
||||
dest TEXT,
|
||||
carrier TEXT
|
||||
);
|
||||
|
||||
statement ok
|
||||
INSERT INTO flights VALUES
|
||||
('A', 'B', 'C1'),
|
||||
('A', 'C', 'C2'),
|
||||
('A', 'D', 'C1'),
|
||||
('B', 'D', 'C3'),
|
||||
('C', 'E', 'C3')
|
||||
;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE trains (
|
||||
source TEXT,
|
||||
dest TEXT
|
||||
);
|
||||
|
||||
statement ok
|
||||
INSERT INTO trains VALUES
|
||||
('B', 'C'),
|
||||
('A', 'E'),
|
||||
('C', 'E')
|
||||
;
|
||||
|
||||
query III
|
||||
WITH RECURSIVE connections(source, dest, carrier) AS (
|
||||
(SELECT f.source, f.dest, f.carrier
|
||||
FROM flights f
|
||||
WHERE f.source = 'A'
|
||||
UNION ALL
|
||||
SELECT r.source, r.dest, 'Rail' AS carrier
|
||||
FROM trains r
|
||||
WHERE r.source = 'A')
|
||||
UNION ALL -- two recursive terms below
|
||||
(SELECT c.source, f.dest, f.carrier
|
||||
FROM connections c, flights f
|
||||
WHERE c.dest = f.source
|
||||
UNION ALL
|
||||
SELECT c.source, r.dest, 'Rail' AS carrier
|
||||
FROM connections c, trains r
|
||||
WHERE c.dest = r.source)
|
||||
)
|
||||
SELECT * FROM connections ORDER BY source, dest, carrier;
|
||||
----
|
||||
A B C1
|
||||
A C C2
|
||||
A C Rail
|
||||
A D C1
|
||||
A D C3
|
||||
A E C3
|
||||
A E C3
|
||||
A E Rail
|
||||
A E Rail
|
||||
A E Rail
|
||||
|
||||
query I
|
||||
WITH RECURSIVE t(x) AS
|
||||
(
|
||||
(SELECT 2
|
||||
UNION
|
||||
SELECT 1)
|
||||
UNION ALL
|
||||
(SELECT x+1
|
||||
FROM t
|
||||
WHERE x < 4
|
||||
UNION
|
||||
SELECT x*2
|
||||
FROM t
|
||||
WHERE x >= 4 AND x < 8
|
||||
UNION ALL
|
||||
SELECT x+1
|
||||
FROM t
|
||||
WHERE x >= 4 AND x < 8)
|
||||
) SELECT * FROM t ORDER BY x;
|
||||
----
|
||||
1
|
||||
2
|
||||
2
|
||||
3
|
||||
3
|
||||
4
|
||||
4
|
||||
5
|
||||
5
|
||||
6
|
||||
6
|
||||
7
|
||||
7
|
||||
8
|
||||
8
|
||||
8
|
||||
8
|
||||
10
|
||||
10
|
||||
12
|
||||
12
|
||||
14
|
||||
14
|
||||
|
||||
query I
|
||||
WITH RECURSIVE foo(i) AS
|
||||
(values (1)
|
||||
UNION
|
||||
(SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION ALL
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION ALL
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION ALL
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION ALL
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION ALL
|
||||
SELECT i+1 FROM foo WHERE i < 2
|
||||
UNION
|
||||
SELECT i+1 FROM foo WHERE i < 2)
|
||||
) SELECT * FROM foo ORDER BY i;
|
||||
----
|
||||
1
|
||||
2
|
||||
59
external/duckdb/test/issues/general/test_3091.test_slow
vendored
Normal file
59
external/duckdb/test/issues/general/test_3091.test_slow
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
# name: test/issues/general/test_3091.test_slow
|
||||
# description: Issue 3091: Double to Decimal rounding error
|
||||
# group: [general]
|
||||
|
||||
query T
|
||||
select 39981.70::DOUBLE::DECIMAL(15,2)
|
||||
----
|
||||
39981.70
|
||||
|
||||
query T
|
||||
select (-39981.70)::DOUBLE::DECIMAL(15,2)
|
||||
----
|
||||
-39981.70
|
||||
|
||||
query T
|
||||
select 100::DOUBLE::DECIMAL(3,0);
|
||||
----
|
||||
100
|
||||
|
||||
query T
|
||||
select (-100)::DOUBLE::DECIMAL(3,0);
|
||||
----
|
||||
-100
|
||||
|
||||
require tpch
|
||||
|
||||
statement ok
|
||||
call dbgen(sf=0.1)
|
||||
|
||||
statement ok
|
||||
pragma threads=1
|
||||
|
||||
query III nosort q0
|
||||
select l_extendedprice, l_discount, l_tax from lineitem
|
||||
----
|
||||
|
||||
loop i 7 38
|
||||
|
||||
statement ok
|
||||
begin transaction
|
||||
|
||||
statement ok
|
||||
create table doubles as
|
||||
select l_extendedprice::double as l_extendedprice,
|
||||
l_discount::double as l_discount,
|
||||
l_tax::double as l_tax
|
||||
from lineitem
|
||||
|
||||
query III nosort q0
|
||||
select l_extendedprice::decimal(${i},2) as l_extendedprice,
|
||||
l_discount::decimal(${i},2) as l_discount,
|
||||
l_tax::decimal(${i},2) as l_tax
|
||||
from doubles
|
||||
----
|
||||
|
||||
statement ok
|
||||
rollback
|
||||
|
||||
endloop
|
||||
25
external/duckdb/test/issues/general/test_3127.test
vendored
Normal file
25
external/duckdb/test/issues/general/test_3127.test
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# name: test/issues/general/test_3127.test
|
||||
# description: Issue 3127: Transactional INSERT + ALTER TABLE ADD COLUMN + INSERT erases data values written to new column
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test(i INTEGER, j INTEGER)
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES (1, 1), (2, 2)
|
||||
|
||||
statement ok
|
||||
ALTER TABLE test ADD COLUMN k INTEGER
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES (3, 3, 3)
|
||||
|
||||
query III
|
||||
SELECT * FROM test
|
||||
----
|
||||
1 1 NULL
|
||||
2 2 NULL
|
||||
3 3 3
|
||||
16
external/duckdb/test/issues/general/test_3140.test
vendored
Normal file
16
external/duckdb/test/issues/general/test_3140.test
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# name: test/issues/general/test_3140.test
|
||||
# description: Issue 3091: Parser error in test, same query in CLI works fine
|
||||
# group: [general]
|
||||
|
||||
query T
|
||||
SELECT '" \'' "';
|
||||
----
|
||||
" \' "
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query T
|
||||
SELECT '" \'' "';
|
||||
----
|
||||
" \' "
|
||||
23
external/duckdb/test/issues/general/test_3518.test
vendored
Normal file
23
external/duckdb/test/issues/general/test_3518.test
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# name: test/issues/general/test_3518.test
|
||||
# description: Issue 3518: Exception thrown when inserting and updating an unsigned integer column in the same row in a transaction
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test (c1 UTINYINT, c2 USMALLINT, c3 UINTEGER, c4 UBIGINT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES (1, 1, 1, 1);
|
||||
|
||||
statement ok
|
||||
UPDATE test SET c1 = 2, c2 = 2, c3 = 2, c4 = 2;
|
||||
|
||||
statement ok
|
||||
COMMIT;
|
||||
|
||||
query IIII
|
||||
SELECT c1, c2, c3, c4 FROM test;
|
||||
----
|
||||
2 2 2 2
|
||||
30
external/duckdb/test/issues/general/test_3611.test
vendored
Normal file
30
external/duckdb/test/issues/general/test_3611.test
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# name: test/issues/general/test_3611.test
|
||||
# description: Issue 3611: Address Sanitiser Failure in Storage Compression
|
||||
# group: [general]
|
||||
|
||||
# load the DB from disk
|
||||
load __TEST_DIR__/issue_3611.db
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
PRAGMA force_compression='dictionary'
|
||||
|
||||
statement ok
|
||||
CREATE TABLE all_types AS SELECT varchar FROM test_all_types();
|
||||
|
||||
loop i 0 12
|
||||
|
||||
statement ok
|
||||
INSERT INTO all_types SELECT varchar FROM all_types;
|
||||
|
||||
endloop
|
||||
|
||||
query I nosort r1
|
||||
SELECT varchar FROM all_types;
|
||||
|
||||
restart
|
||||
|
||||
query I nosort r1
|
||||
SELECT varchar FROM all_types;
|
||||
50
external/duckdb/test/issues/general/test_3821.test
vendored
Normal file
50
external/duckdb/test/issues/general/test_3821.test
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
# name: test/issues/general/test_3821.test
|
||||
# description: Issue 3821: Setting default_collation=NOCASE modifies values of GROUP BY queries
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t AS (SELECT 'hello' AS x UNION ALL SELECT 'WORLD' AS x UNION ALL SELECT 'WoRlD' AS x);
|
||||
|
||||
# 3 groups because no collation
|
||||
query I rowsort
|
||||
SELECT x FROM t GROUP BY 1;
|
||||
----
|
||||
WORLD
|
||||
WoRlD
|
||||
hello
|
||||
|
||||
query I rowsort
|
||||
SELECT x COLLATE NOCASE FROM t GROUP BY 1;
|
||||
----
|
||||
WORLD
|
||||
hello
|
||||
|
||||
query I
|
||||
SELECT COUNT(*) FROM t GROUP BY x COLLATE NOCASE ORDER BY ALL;
|
||||
----
|
||||
1
|
||||
2
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t_schema(x VARCHAR COLLATE NOCASE);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t_schema VALUES ('hello'), ('WORLD'), ('WoRlD');
|
||||
|
||||
query I rowsort
|
||||
SELECT x FROM t_schema GROUP BY x;
|
||||
----
|
||||
WORLD
|
||||
hello
|
||||
|
||||
statement ok
|
||||
PRAGMA default_collation=NOCASE;
|
||||
|
||||
query I rowsort
|
||||
SELECT x FROM t GROUP BY 1;
|
||||
----
|
||||
WORLD
|
||||
hello
|
||||
14
external/duckdb/test/issues/general/test_3822.test
vendored
Normal file
14
external/duckdb/test/issues/general/test_3822.test
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# name: test/issues/general/test_3822.test
|
||||
# description: Issue 3822: Array_slice in macro type error
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE MACRO pyfloats_to_floats(x) AS (CAST(string_split(x[2:-2], ',') AS FLOAT4[]))
|
||||
|
||||
query T
|
||||
select pyfloats_to_floats('[1.000000, 2.000000, 3.000000]')
|
||||
----
|
||||
[1.0, 2.0, 3.0]
|
||||
60
external/duckdb/test/issues/general/test_3878.test
vendored
Normal file
60
external/duckdb/test/issues/general/test_3878.test
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
# name: test/issues/general/test_3878.test
|
||||
# description: Issue 3878: Small create table issues
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
#statement error
|
||||
#create table ups (primary key(x));
|
||||
#
|
||||
#statement error
|
||||
#create table ups (constraint con foreign key(x) references y(y));
|
||||
#
|
||||
#statement error
|
||||
#create table ups (x int primary key, primary key(x));
|
||||
#
|
||||
#statement error
|
||||
#create table ups (z int, constraint x foreign key (x) references y(y));
|
||||
|
||||
statement ok
|
||||
create table x (x int primary key);
|
||||
|
||||
#statement error
|
||||
#create table y (y int references x(z));
|
||||
#
|
||||
#statement error
|
||||
#create table y (y int references x(y));
|
||||
|
||||
statement ok
|
||||
create table y (y int references x(x));
|
||||
|
||||
statement error
|
||||
insert into y values (1);
|
||||
----
|
||||
<REGEX>:Constraint Error.*Violates foreign key.*does not exist.*
|
||||
|
||||
statement ok
|
||||
insert into x values (1);
|
||||
|
||||
statement ok
|
||||
insert into y values (1);
|
||||
|
||||
statement error
|
||||
insert into x values (NULL);
|
||||
----
|
||||
<REGEX>:Constraint Error.*NOT NULL constraint failed.*
|
||||
|
||||
statement ok
|
||||
insert into y values (NULL);
|
||||
|
||||
statement error
|
||||
delete from x;
|
||||
----
|
||||
<REGEX>:Constraint Error.*Violates foreign key.*in a different table.*
|
||||
|
||||
statement ok
|
||||
delete from y;
|
||||
|
||||
statement ok
|
||||
delete from x;
|
||||
63
external/duckdb/test/issues/general/test_3997.test
vendored
Normal file
63
external/duckdb/test/issues/general/test_3997.test
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# name: test/issues/general/test_3997.test
|
||||
# description: Issue 3997: CTEs on Insert/update/delete statements
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement ok
|
||||
create table x (x int);
|
||||
|
||||
require no_alternative_verify
|
||||
|
||||
statement ok
|
||||
with y(y) as (select 1) insert into x (select y from y);
|
||||
|
||||
query I
|
||||
select x from x;
|
||||
----
|
||||
1
|
||||
|
||||
statement ok
|
||||
with y(y) as (select 1) update x set x = 2 from y where x = y;
|
||||
|
||||
query I
|
||||
select x from x;
|
||||
----
|
||||
2
|
||||
|
||||
statement ok
|
||||
with y(y) as (select 2) delete from x using y where x = y;
|
||||
|
||||
query I
|
||||
select x from x;
|
||||
----
|
||||
|
||||
statement ok
|
||||
with y(y) as (select 1), z(z) as (select 2) insert into x (select (select y + z + 7) from y, z);
|
||||
|
||||
statement ok
|
||||
with recursive t as (select 1 as x union all select x+1 from t where x < 3) insert into x (select * from t);
|
||||
|
||||
query I
|
||||
select x from x;
|
||||
----
|
||||
10
|
||||
1
|
||||
2
|
||||
3
|
||||
|
||||
statement ok
|
||||
with y(y) as (with z(z) as (select 20) select * from z) delete from x using y where x < y;
|
||||
|
||||
query I
|
||||
select x from x;
|
||||
----
|
||||
|
||||
statement error
|
||||
with y(y) as (select 2) delete from x using (select y) z(z) where x = z;
|
||||
----
|
||||
<REGEX>:Binder Error.*Referenced column.*not found.*
|
||||
|
||||
statement ok
|
||||
insert into x default values;
|
||||
25
external/duckdb/test/issues/general/test_4008.test
vendored
Normal file
25
external/duckdb/test/issues/general/test_4008.test
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# name: test/issues/general/test_4008.test
|
||||
# description: Issue 4008: ANY/ALL without comparison operators
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification;
|
||||
|
||||
statement error
|
||||
select 1 - any(select 1);
|
||||
----
|
||||
<REGEX>:Parser Error.*operators require.*comparisons.*
|
||||
|
||||
query I
|
||||
select 1 = all(select 1);
|
||||
----
|
||||
1
|
||||
|
||||
statement error
|
||||
select 1 where 2 + all(select 2);
|
||||
----
|
||||
<REGEX>:Parser Error.*operators require.*comparisons.*
|
||||
|
||||
query I
|
||||
select 1 where 2 > any(select 2);
|
||||
----
|
||||
8
external/duckdb/test/issues/general/test_4063.test
vendored
Normal file
8
external/duckdb/test/issues/general/test_4063.test
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# name: test/issues/general/test_4063.test
|
||||
# description: Issue 4063: First_value window function sanitizer issue
|
||||
# group: [general]
|
||||
|
||||
query T
|
||||
SELECT first_value(1) OVER ()
|
||||
----
|
||||
1
|
||||
33
external/duckdb/test/issues/general/test_4165.test
vendored
Normal file
33
external/duckdb/test/issues/general/test_4165.test
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
# name: test/issues/general/test_4165.test
|
||||
# description: Issue 4165: SIGSEGV on Debian Buster amd64
|
||||
# group: [general]
|
||||
|
||||
set seed 0.42
|
||||
|
||||
statement ok
|
||||
CREATE TABLE df_a AS
|
||||
SELECT
|
||||
(100000 + (899999 * RANDOM()))::BIGINT AS ID,
|
||||
(4000 * RANDOM())::BIGINT AS C,
|
||||
(4000 * RANDOM())::BIGINT AS P,
|
||||
substring('abc', 1+(RANDOM() * 2)::BIGINT, 1) AS S
|
||||
FROM range(20000)
|
||||
|
||||
statement ok
|
||||
CREATE TABLE df_b AS
|
||||
SELECT * FROM df_a WHERE S='a'
|
||||
|
||||
statement ok
|
||||
select
|
||||
Case
|
||||
when try_cast(b.c as real) is null
|
||||
and a.s = 'b' then a.p
|
||||
when try_cast(b.c as real) is not null
|
||||
and a.s = 'b'
|
||||
and try_cast(b.c as real) < try_cast(a.p as real)
|
||||
then try_cast(a.p as real)
|
||||
else 0
|
||||
END
|
||||
from df_a a
|
||||
left join df_b b on Cast(a.ID as real) = cast(b.ID as real)
|
||||
left join df_b c on a.ID = c.ID;
|
||||
30
external/duckdb/test/issues/general/test_4612.test
vendored
Normal file
30
external/duckdb/test/issues/general/test_4612.test
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
# name: test/issues/general/test_4612.test
|
||||
# description: Issue 4612: Can't select by blob field
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE blobs (b BYTEA);
|
||||
|
||||
statement ok
|
||||
INSERT INTO blobs VALUES('\xaa\xff\xaa'), ('\xAA\xFF\xAA\xAA\xFF\xAA'), ('\xAA\xFF\xAA\xAA\xFF\xAA\xAA\xFF\xAA');
|
||||
|
||||
query I
|
||||
SELECT * FROM blobs;
|
||||
----
|
||||
\xAA\xFF\xAA
|
||||
\xAA\xFF\xAA\xAA\xFF\xAA
|
||||
\xAA\xFF\xAA\xAA\xFF\xAA\xAA\xFF\xAA
|
||||
|
||||
|
||||
query I
|
||||
SELECT * FROM blobs where b = '\xaa\xff\xaA';
|
||||
----
|
||||
\xAA\xFF\xAA
|
||||
|
||||
query I
|
||||
SELECT * FROM blobs where b = '\xAA\xFF\xAA';
|
||||
----
|
||||
\xAA\xFF\xAA
|
||||
19
external/duckdb/test/issues/general/test_4615.test
vendored
Normal file
19
external/duckdb/test/issues/general/test_4615.test
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# name: test/issues/general/test_4615.test
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1 (int AS (x + 100), x INT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (1);
|
||||
|
||||
statement ok
|
||||
UPDATE t1 SET x=0 WHERE x = 1;
|
||||
|
||||
query II
|
||||
SELECT * FROM t1;
|
||||
----
|
||||
100 0
|
||||
23
external/duckdb/test/issues/general/test_4625.test
vendored
Normal file
23
external/duckdb/test/issues/general/test_4625.test
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
# name: test/issues/general/test_4625.test
|
||||
# description: Issue 4625: Address boundary error when using PARTITION BY
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE "crash"
|
||||
("amount" "FLOAT",
|
||||
"account" "TEXT");
|
||||
|
||||
statement ok
|
||||
INSERT INTO "crash"
|
||||
VALUES
|
||||
(1000, '123456789012'),
|
||||
(1000, '1234567890123');
|
||||
|
||||
query T
|
||||
SELECT SUM("amount") OVER (PARTITION BY "account"
|
||||
ORDER BY "account" ASC
|
||||
ROWS CURRENT ROW)
|
||||
FROM "crash";
|
||||
----
|
||||
1000.0
|
||||
1000.0
|
||||
51
external/duckdb/test/issues/general/test_4704.test
vendored
Normal file
51
external/duckdb/test/issues/general/test_4704.test
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
# name: test/issues/general/test_4704.test
|
||||
# description: Issue 4704: Wrong column name was reported with generated column presented
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 AS (1), c1 INT NOT NULL)
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0 SELECT 1 FROM RANGE(1024)
|
||||
|
||||
statement error
|
||||
INSERT INTO t0 VALUES(NULL)
|
||||
----
|
||||
<REGEX>:Constraint Error.*NOT NULL constraint failed.*
|
||||
|
||||
statement error
|
||||
UPDATE t0 SET c1 = NULL
|
||||
----
|
||||
<REGEX>:Constraint Error.*NOT NULL constraint failed.*
|
||||
|
||||
query T
|
||||
SELECT column_name FROM PRAGMA_STORAGE_INFO('t0') LIMIT 2
|
||||
----
|
||||
c1
|
||||
c1
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c0 INT NOT NULL, c1 AS (1))
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 SELECT 1 FROM RANGE(1024)
|
||||
|
||||
statement error
|
||||
INSERT INTO t1 VALUES(NULL)
|
||||
----
|
||||
<REGEX>:Constraint Error.*NOT NULL constraint failed.*
|
||||
|
||||
statement error
|
||||
UPDATE t1 SET c0 = NULL
|
||||
----
|
||||
<REGEX>:Constraint Error.*NOT NULL constraint failed.*
|
||||
|
||||
query T
|
||||
SELECT column_name FROM PRAGMA_STORAGE_INFO('t1') LIMIT 2
|
||||
----
|
||||
c0
|
||||
c0
|
||||
|
||||
25
external/duckdb/test/issues/general/test_4753.test
vendored
Normal file
25
external/duckdb/test/issues/general/test_4753.test
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# name: test/issues/general/test_4753.test
|
||||
# description: Issue 4753: Exists and ANY correlated subquery produce incorrect result
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t (x INT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t VALUES (1), (2);
|
||||
|
||||
query I
|
||||
SELECT NULL = ANY(SELECT sum(x) FROM t t2 WHERE t1.x > 2) FROM t t1;
|
||||
----
|
||||
NULL
|
||||
NULL
|
||||
|
||||
query I
|
||||
SELECT EXISTS(SELECT sum(x) FROM t t2 WHERE t1.x > 2) FROM t t1;
|
||||
----
|
||||
true
|
||||
true
|
||||
|
||||
62
external/duckdb/test/issues/general/test_4766.test
vendored
Normal file
62
external/duckdb/test/issues/general/test_4766.test
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
# name: test/issues/general/test_4766.test
|
||||
# description: Issue 4766: Incorrect results in Query..
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
SET default_null_order='nulls_first';
|
||||
|
||||
statement ok
|
||||
create table test as
|
||||
with cte1 as (
|
||||
select '01234567890' s
|
||||
from range(10)
|
||||
), cte2 as (
|
||||
select '012345678901' s
|
||||
from range(10)
|
||||
), cte3 as (
|
||||
select NULL
|
||||
from range(10)
|
||||
)
|
||||
select *
|
||||
from (
|
||||
select * from cte1
|
||||
union all
|
||||
select * from cte2
|
||||
union all
|
||||
select * from cte3
|
||||
)
|
||||
order by random();
|
||||
|
||||
query T
|
||||
select * from test order by s
|
||||
----
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
01234567890
|
||||
01234567890
|
||||
01234567890
|
||||
01234567890
|
||||
01234567890
|
||||
01234567890
|
||||
01234567890
|
||||
01234567890
|
||||
01234567890
|
||||
01234567890
|
||||
012345678901
|
||||
012345678901
|
||||
012345678901
|
||||
012345678901
|
||||
012345678901
|
||||
012345678901
|
||||
012345678901
|
||||
012345678901
|
||||
012345678901
|
||||
012345678901
|
||||
19
external/duckdb/test/issues/general/test_4935.test
vendored
Normal file
19
external/duckdb/test/issues/general/test_4935.test
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
# name: test/issues/general/test_4935.test
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(a int);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t2(x int, y int, z int, w int);
|
||||
|
||||
statement ok
|
||||
SELECT v1.a, v2.a, v3.a, v4.a, v5.a, v6.a, v7.a, v8.a
|
||||
FROM t1 AS v1, t1 AS v2, t1 AS v3, t1 AS v4, t1 AS v5, t1 AS v6, t1 AS v7, t1 AS v8,
|
||||
t2 AS f1, t2 as f2
|
||||
WHERE
|
||||
f1.x = v1.a AND f1.y = v3 AND f1.z = v4 AND f1.w = v5 AND
|
||||
f2.x = v2.a AND f2.y = v6 AND f2.z = v7 AND f2.w = v8;
|
||||
136
external/duckdb/test/issues/general/test_4950.test
vendored
Normal file
136
external/duckdb/test/issues/general/test_4950.test
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
# name: test/issues/general/test_4950.test
|
||||
# description: Issue 4950: Subquery is not transformed into an anti-join by the optimizer
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma explain_output = optimized_only
|
||||
|
||||
statement ok
|
||||
pragma enable_verification
|
||||
|
||||
statement ok
|
||||
create table lineitem (l_orderkey int, l_suppkey int, l_partkey int);
|
||||
|
||||
statement ok
|
||||
insert into lineitem values (1,1,42),(1,2,43),(3,3,44),(4,5,45),(5,5,46),(6,5,47);
|
||||
|
||||
query III rowsort
|
||||
select * from lineitem l1 where exists (
|
||||
select * from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
);
|
||||
----
|
||||
1 1 42
|
||||
1 2 43
|
||||
|
||||
# deliminator should remove INNER
|
||||
query II
|
||||
explain select * from lineitem l1 where exists (
|
||||
select * from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
);
|
||||
----
|
||||
logical_opt <!REGEX>:.*INNER.*
|
||||
|
||||
# SINGLE join - same story
|
||||
query III
|
||||
select * from lineitem l1 where (
|
||||
select l_orderkey from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
);
|
||||
----
|
||||
1 1 42
|
||||
1 2 43
|
||||
|
||||
query II
|
||||
explain select * from lineitem l1 where (
|
||||
select l_orderkey from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
);
|
||||
----
|
||||
logical_opt <!REGEX>:.*INNER.*
|
||||
|
||||
# operations on the columns - we can't do the optimization here,
|
||||
# but with enable_verification we check the results are the same with/without optimizer
|
||||
query I
|
||||
select count(*) from lineitem l1 where exists (
|
||||
select * from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey + 1
|
||||
and l2.l_suppkey <> l1.l_suppkey + 1
|
||||
);
|
||||
----
|
||||
3
|
||||
|
||||
# more correlated columns
|
||||
query I
|
||||
select count(*) from lineitem l1 where exists (
|
||||
select * from (SELECT l2.l_orderkey AS l_orderkey, l2.l_suppkey + l1.l_suppkey AS l_suppkey FROM lineitem l2) AS l3
|
||||
where
|
||||
l3.l_orderkey = l1.l_orderkey
|
||||
and l3.l_suppkey <> l1.l_suppkey
|
||||
);
|
||||
----
|
||||
6
|
||||
|
||||
# more correlated columns + operations
|
||||
query I
|
||||
select count(*) from lineitem l1 where exists (
|
||||
select * from (SELECT l2.l_orderkey AS l_orderkey, l2.l_suppkey + l1.l_suppkey AS l_suppkey FROM lineitem l2) AS l3
|
||||
where
|
||||
l3.l_orderkey = l1.l_orderkey + 1
|
||||
and l3.l_suppkey <> l1.l_suppkey + 1
|
||||
);
|
||||
----
|
||||
3
|
||||
|
||||
# select other columns + operations
|
||||
query I
|
||||
select count(*) from lineitem l1 where exists (
|
||||
select l_partkey from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey + 1
|
||||
and l2.l_suppkey <> l1.l_suppkey + 1
|
||||
);
|
||||
----
|
||||
3
|
||||
|
||||
# select other columns, but no operations (we can perform the optimization here!
|
||||
query I
|
||||
select count(*) from lineitem l1 where exists (
|
||||
select l_partkey from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
);
|
||||
----
|
||||
2
|
||||
|
||||
query II
|
||||
explain select count(*) from lineitem l1 where exists (
|
||||
select l_partkey from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey
|
||||
and l2.l_suppkey <> l1.l_suppkey
|
||||
);
|
||||
----
|
||||
logical_opt <!REGEX>:.*INNER.*
|
||||
|
||||
# aggregate within the subquery
|
||||
query I
|
||||
select count(*) from lineitem l1 where exists (
|
||||
select sum(l2.l_orderkey) from lineitem l2
|
||||
where
|
||||
l2.l_orderkey = l1.l_orderkey + 1
|
||||
and l2.l_suppkey <> l1.l_suppkey + 1
|
||||
);
|
||||
----
|
||||
6
|
||||
63
external/duckdb/test/issues/general/test_5072.test
vendored
Normal file
63
external/duckdb/test/issues/general/test_5072.test
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
# name: test/issues/general/test_5072.test
|
||||
# description: Issue 5072: CARDINALITY on NULL map results in non-deterministic result
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
SELECT CARDINALITY(CAST(NULL AS MAP(VARCHAR, INT)));
|
||||
----
|
||||
NULL
|
||||
|
||||
query I
|
||||
WITH src AS ( VALUES (1, NULL) )
|
||||
SELECT CARDINALITY(HISTOGRAM(val)) FROM src AS t(k, val);
|
||||
----
|
||||
NULL
|
||||
|
||||
statement error
|
||||
CREATE TABLE t1 AS (SELECT ARRAY[(1, 'x'), (2, 'y'), (4, 's')] AS list);
|
||||
----
|
||||
Invalid Input Error: A table cannot be created from an unnamed struct
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1 (list STRUCT(a INT, b VARCHAR)[]);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (ARRAY[(1, 'x'), (2, 'y'), (4, 's')]);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (ARRAY[(2, 'a'), (3,'b')]);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (NULL);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (ARRAY[(5, NULL), (2, 'T')]);
|
||||
|
||||
query I
|
||||
SELECT MAP_FROM_ENTRIES(list) FROM t1;
|
||||
----
|
||||
{1=x, 2=y, 4=s}
|
||||
{2=a, 3=b}
|
||||
NULL
|
||||
{5=NULL, 2=T}
|
||||
|
||||
query I
|
||||
SELECT CARDINALITY(MAP_FROM_ENTRIES(list)) FROM t1;
|
||||
----
|
||||
3
|
||||
2
|
||||
NULL
|
||||
2
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 VALUES (ARRAY[(7,'g'), (NULL, 'Y')]);
|
||||
|
||||
statement error
|
||||
SELECT CARDINALITY(MAP_FROM_ENTRIES(list)) FROM t1;
|
||||
----
|
||||
Invalid Input Error: Map keys can not be NULL
|
||||
|
||||
|
||||
24
external/duckdb/test/issues/general/test_5200.test
vendored
Normal file
24
external/duckdb/test/issues/general/test_5200.test
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# name: test/issues/general/test_5200.test
|
||||
# description: Issue 5200: a CTE SQL cause INTERNAL Error: Recursive CTE detected WITHIN a recursive CTE node then FATAL Error: Failed: database has been invalidated!
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement error
|
||||
with recursive f(n,f) as ( ------- 构造阶乘表
|
||||
select 0,1::bigint
|
||||
union all
|
||||
select n+1,f*(n+1)::bigint from f where n<45
|
||||
)
|
||||
,t(n,s,f) as (
|
||||
select 1,lv-1,1::bigint from (values(1),(2))s(lv)
|
||||
union all
|
||||
select t.n+1,t.s+f.n,t.f*f.f::bigint
|
||||
from t
|
||||
,f
|
||||
where t.n<9 and f.n<=t.n+1
|
||||
)
|
||||
select sum(f.f/t.f) from t,f where t.n=4 and t.s>0 and t.s=f.n;
|
||||
----
|
||||
Out of Range Error: Overflow in multiplication of INT64 (2432902008176640000 * 21)
|
||||
88
external/duckdb/test/issues/general/test_5390.test
vendored
Normal file
88
external/duckdb/test/issues/general/test_5390.test
vendored
Normal file
@@ -0,0 +1,88 @@
|
||||
# name: test/issues/general/test_5390.test
|
||||
# description: Issue 5390: Segmentation fault with ROWID and LEFT/RIGHT JOIN
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 INT);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c0 INT);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t0 values (5);
|
||||
|
||||
statement ok
|
||||
INSERT INTO t1 values (4);
|
||||
|
||||
query II
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
INTERSECT
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
WHERE
|
||||
1 BETWEEN -1 AND t1.rowid;
|
||||
----
|
||||
|
||||
query II
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
INTERSECT
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
WHERE
|
||||
1 BETWEEN -1 AND t1.c0;
|
||||
----
|
||||
4 5
|
||||
|
||||
query II
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
INTERSECT
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
WHERE 1 BETWEEN +1 AND t1.rowid;
|
||||
----
|
||||
|
||||
query II
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
INTERSECT
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
WHERE 1 BETWEEN 2 AND t1.rowid;
|
||||
----
|
||||
|
||||
|
||||
query II
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
INTERSECT
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
WHERE 1 = t1.rowid;
|
||||
----
|
||||
|
||||
query II
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
INTERSECT
|
||||
SELECT *
|
||||
FROM t1
|
||||
LEFT JOIN t0 ON t1.rowid = t0.rowid
|
||||
WHERE -1 = t1.rowid;
|
||||
----
|
||||
24
external/duckdb/test/issues/general/test_5488.test
vendored
Normal file
24
external/duckdb/test/issues/general/test_5488.test
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
# name: test/issues/general/test_5488.test
|
||||
# description: Issue 5488: Reproducible data corruption on simple insert
|
||||
# group: [general]
|
||||
|
||||
# load the DB from disk
|
||||
load __TEST_DIR__/issue_5488.db
|
||||
|
||||
statement ok
|
||||
pragma force_compression='dictionary'
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test ( col_a TEXT);
|
||||
|
||||
# We need a dataset that will only write unique values as it flushes a segment, this will trigger the bug
|
||||
statement ok
|
||||
INSERT INTO test SELECT case when i<100 then concat(repeat('string',400), i::VARCHAR) else 'target_string_we_will_count' end from range(0,100000) tbl(i);
|
||||
|
||||
statement ok
|
||||
checkpoint;
|
||||
|
||||
query I
|
||||
SELECT count(*) from test where col_a = 'target_string_we_will_count';
|
||||
----
|
||||
99900
|
||||
55
external/duckdb/test/issues/general/test_5614.test
vendored
Normal file
55
external/duckdb/test/issues/general/test_5614.test
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
# name: test/issues/general/test_5614.test
|
||||
# description: Issue 5614:
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
pragma enable_verification
|
||||
|
||||
statement ok
|
||||
create table t0 as select (UNNEST(['hello', 'duckdb', 'duck LORD', 'lord duck'])) as column0;
|
||||
|
||||
|
||||
# create the alias but use the column name
|
||||
query III
|
||||
select
|
||||
row_number() over () as line_number,
|
||||
column0 as text,
|
||||
length(coalesce(column0, '')) as text_length
|
||||
from
|
||||
t0
|
||||
where 'LORD' in (select * from unnest(str_split(column0, ' ')));
|
||||
----
|
||||
1 duck LORD 9
|
||||
|
||||
# Using alias now in Where clause
|
||||
query III
|
||||
select
|
||||
row_number() over () as line_number,
|
||||
column0 as text,
|
||||
length(coalesce(column0, '')) as text_length
|
||||
from
|
||||
t0
|
||||
where 'LORD' in (select * from unnest(str_split(text, ' ')));
|
||||
----
|
||||
1 duck LORD 9
|
||||
|
||||
statement ok
|
||||
CREATE or replace TABLE brands (category VARCHAR, brand_name VARCHAR);
|
||||
|
||||
statement ok
|
||||
INSERT INTO brands (category, brand_name) VALUES ('chocolates', '5-star'), (Null, 'diary milk'), (Null, 'perk'), (Null, 'eclair'), ('Biscuits', 'britannia'), (Null, 'good day'), (Null, 'boost');
|
||||
|
||||
statement error
|
||||
with cte as (
|
||||
select
|
||||
*,
|
||||
row_number() over () as t,
|
||||
count(category) over (order by t) as tmp
|
||||
from brands
|
||||
)
|
||||
select
|
||||
max(category) over (partition by tmp) as category,
|
||||
brand_name
|
||||
from cte;
|
||||
----
|
||||
Binder Error: window function calls cannot be nested
|
||||
27
external/duckdb/test/issues/general/test_5660.test
vendored
Normal file
27
external/duckdb/test/issues/general/test_5660.test
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
# name: test/issues/general/test_5660.test
|
||||
# description: Issue 5660: Group by all throws binder error when a more informative error should be produced
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE foo AS SELECT 'a, b, c' AS "x", '1' AS y;
|
||||
|
||||
statement error
|
||||
SELECT y, UNLIST(string_split("x", ', ')) alias, COUNT(*) FROM foo GROUP BY y, alias;
|
||||
----
|
||||
Binder Error
|
||||
|
||||
statement ok
|
||||
select * from foo
|
||||
|
||||
statement error
|
||||
SELECT y, UNLIST(string_split("x", ', ')) x, COUNT(*) FROM foo GROUP BY ALL;
|
||||
----
|
||||
Binder Error
|
||||
|
||||
# essentially the same as above but with a subquery instead of a group by and unlist
|
||||
statement ok
|
||||
select f.y, k.c1, count(*) FROM foo f, (Select UNLIST(string_split("x", ', ')) c1) k group by y, k.c1;
|
||||
|
||||
# Make sure we don't invalidate the database
|
||||
statement ok
|
||||
select * from foo
|
||||
29
external/duckdb/test/issues/general/test_5664.test
vendored
Normal file
29
external/duckdb/test/issues/general/test_5664.test
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/issues/general/test_5664.test
|
||||
# description: Issue 5664: Create type from non-existing type causes INTERNAL Error
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# create a type with a non-existant type as source
|
||||
statement error
|
||||
CREATE TYPE alias as BLOBL;
|
||||
----
|
||||
<REGEX>:Catalog Error.*Type.*does not exist.*
|
||||
|
||||
statement ok
|
||||
CREATE TYPE a as BLOB;
|
||||
|
||||
statement ok
|
||||
CREATE TYPE b as a;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE test (x b);
|
||||
|
||||
statement ok
|
||||
INSERT INTO test VALUES ('duckdb');
|
||||
|
||||
query I
|
||||
SELECT typeof(x) FROM test;
|
||||
----
|
||||
BLOB
|
||||
61
external/duckdb/test/issues/general/test_5896.test
vendored
Normal file
61
external/duckdb/test/issues/general/test_5896.test
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
# name: test/issues/general/test_5896.test
|
||||
# description: Issue 5896: json_group_array() does not respect filter clauses
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
# the problem was actually that all aggregate modifiers were ignored for non-aggregate functions
|
||||
|
||||
# distinct modifier
|
||||
statement error
|
||||
select sqrt(distinct range) from range(5);
|
||||
----
|
||||
Invalid Input Error: Function "sqrt" is a Scalar Function. "DISTINCT", "FILTER", and "ORDER BY" are only applicable to aggregate functions.
|
||||
|
||||
# filter modifier
|
||||
statement error
|
||||
select sqrt(range) filter (where (range > 3)) from range(5);
|
||||
----
|
||||
Invalid Input Error: Function "sqrt" is a Scalar Function. "DISTINCT", "FILTER", and "ORDER BY" are only applicable to aggregate functions.
|
||||
|
||||
# ordered aggregate (error is taken care of somewhere else)
|
||||
statement error
|
||||
select sqrt(range order by range) from range(5);
|
||||
----
|
||||
Invalid Input Error: Function "sqrt" is a Scalar Function. "DISTINCT", "FILTER", and "ORDER BY" are only applicable to aggregate functions.
|
||||
|
||||
# let's test with a macro
|
||||
statement ok
|
||||
create macro my_sqrt(x) as sqrt(x)
|
||||
|
||||
statement error
|
||||
select my_sqrt(distinct range) from range(5);
|
||||
----
|
||||
Invalid Input Error: Function "my_sqrt" is a Macro Function. "DISTINCT", "FILTER", and "ORDER BY" are only applicable to aggregate functions.
|
||||
|
||||
statement error
|
||||
select list_value(distinct([42]));
|
||||
----
|
||||
Invalid Input Error: Function "list_value" is a Scalar Function. "DISTINCT", "FILTER", and "ORDER BY" are only applicable to aggregate functions.
|
||||
|
||||
statement error
|
||||
SELECT unnest(distinct([42, 42]));
|
||||
----
|
||||
Invalid Input Error: "DISTINCT", "FILTER", and "ORDER BY" are not applicable to "UNNEST"
|
||||
|
||||
statement error
|
||||
SELECT unnest(distinct [42, 42]);
|
||||
----
|
||||
Invalid Input Error: "DISTINCT", "FILTER", and "ORDER BY" are not applicable to "UNNEST"
|
||||
|
||||
statement error
|
||||
SELECT unnest([42, 42] ORDER BY x);
|
||||
----
|
||||
Invalid Input Error: "DISTINCT", "FILTER", and "ORDER BY" are not applicable to "UNNEST"
|
||||
|
||||
|
||||
statement error
|
||||
SELECT unnest([42, 42]) FILTER (WHERE (x > 3));
|
||||
----
|
||||
Invalid Input Error: "DISTINCT", "FILTER", and "ORDER BY" are not applicable to "UNNEST"
|
||||
11
external/duckdb/test/issues/general/test_6822.test
vendored
Normal file
11
external/duckdb/test/issues/general/test_6822.test
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# name: test/issues/general/test_6822.test
|
||||
# description: Issue 6822: Unexpected error in TryMultiplyOperator with lcm(.,.)
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query I
|
||||
SELECT lcm(4, 6 :: int128)
|
||||
----
|
||||
12
|
||||
52
external/duckdb/test/issues/general/test_7250
vendored
Normal file
52
external/duckdb/test/issues/general/test_7250
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
name: test/issues/general/test_7250.test
|
||||
# description: Issue 6822: Unexpected error in TryMultiplyOperator with lcm(.,.)
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t21(c0 INT64);
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 INT64, c1 INT64);
|
||||
|
||||
statement ok
|
||||
CREATE VIEW v0(c0) AS SELECT t0.c1 FROM t21, t0;
|
||||
|
||||
statement ok
|
||||
WITH temp_table1 AS(SELECT (t21.c0) AS c0 FROM t21) SELECT (t0.rowid) AS c0 FROM v0, t0, temp_table1 WHERE ((temp_table1.c0)<(( t0.rowid)));
|
||||
|
||||
statement ok
|
||||
DROP TABLE t21;
|
||||
|
||||
statement ok
|
||||
DROP TABLE t0;
|
||||
|
||||
statement ok
|
||||
DROP VIEW v0;
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t0(c0 FLOAT4, c1 DOUBLE UNIQUE, PRIMARY KEY(c0));
|
||||
|
||||
statement ok
|
||||
CREATE TABLE t1(c0 INT4, c1 INT1 DEFAULT(0), c2 INT4);
|
||||
|
||||
statement ok
|
||||
CREATE VIEW v0(c0) AS SELECT 1 FROM t1, t0;
|
||||
|
||||
|
||||
statement ok
|
||||
SELECT *
|
||||
FROM v0,
|
||||
t0 NATURAL LEFT JOIN t1
|
||||
WHERE
|
||||
(
|
||||
((25
|
||||
BETWEEN
|
||||
0
|
||||
AND
|
||||
(
|
||||
CASE t0.c0
|
||||
-- WHEN 0 THEN t1.c0
|
||||
-- WHEN 0 THEN t1.c1
|
||||
WHEN 0 THEN t1.c2
|
||||
END )))
|
||||
IS NULL);
|
||||
11
external/duckdb/test/issues/general/test_8287.test
vendored
Normal file
11
external/duckdb/test/issues/general/test_8287.test
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# name: test/issues/general/test_8287.test
|
||||
# description: Issue 8287: Internal Exception when dropping system catalog function as if it were a Macro
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement error
|
||||
drop macro sum;
|
||||
----
|
||||
Catalog Error: Cannot drop internal catalog entry "sum"!
|
||||
9
external/duckdb/test/issues/general/test_9380.test
vendored
Normal file
9
external/duckdb/test/issues/general/test_9380.test
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# name: test/issues/general/test_9380.test
|
||||
# description: Issue 9380: "Could not choose a best candidate function for the function call" after upgrading to 0.9
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
CREATE MACRO time_to_datetime(date, string) AS
|
||||
date::TIMESTAMP +
|
||||
TRY_CAST(regexp_replace(string, '^2400$', '0000').substr(1, 2).concat(' hours') AS INTERVAL) +
|
||||
TRY_CAST(regexp_replace(string, '^2400$', '0000').substr(3, 2).concat(' minutes') AS INTERVAL);
|
||||
25
external/duckdb/test/issues/general/test_9384.test
vendored
Normal file
25
external/duckdb/test/issues/general/test_9384.test
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# name: test/issues/general/test_9384.test
|
||||
# description: Issue 9384: DuckDB fails when trying to add a JSON column to an existing table via ALTER TABLE
|
||||
# group: [general]
|
||||
|
||||
require json
|
||||
|
||||
statement ok
|
||||
create schema my_schema;
|
||||
|
||||
statement ok
|
||||
use my_schema;
|
||||
|
||||
statement ok
|
||||
create table t1 (i json);
|
||||
|
||||
statement ok
|
||||
alter table t1 add column my_col json;
|
||||
|
||||
require inet
|
||||
|
||||
statement ok
|
||||
create table t2 (i inet);
|
||||
|
||||
statement ok
|
||||
alter table t2 add column my_col inet;
|
||||
29
external/duckdb/test/issues/general/test_9399.test_slow
vendored
Normal file
29
external/duckdb/test/issues/general/test_9399.test_slow
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
# name: test/issues/general/test_9399.test_slow
|
||||
# description: Issue 9399: Incorrect query output from group by query (regression in 0.9.0)
|
||||
# group: [general]
|
||||
|
||||
# happened with > 8 threads
|
||||
statement ok
|
||||
SET threads=10
|
||||
|
||||
# seed so it's deterministic
|
||||
set seed 0.8765309
|
||||
|
||||
# create table that's has just one row group, and just a few duplicates
|
||||
statement ok
|
||||
CREATE TABLE test AS
|
||||
SELECT CASE WHEN random() < 0.002 THEN range ELSE 100000 - range END c0,
|
||||
random() c1,
|
||||
random() c2
|
||||
FROM range(100000)
|
||||
|
||||
# should return 99815 rows (was 99870 before)
|
||||
query III
|
||||
WITH cte AS (SELECT c0,
|
||||
avg(c1) AS c1_avg,
|
||||
avg(c2) AS c2_avg
|
||||
FROM test GROUP BY c0)
|
||||
SELECT * FROM cte
|
||||
ORDER BY c0
|
||||
----
|
||||
299370 values hashing to bbebcd893b08ad0e1c1240e29a1b814d
|
||||
54
external/duckdb/test/issues/general/test_9456.test
vendored
Normal file
54
external/duckdb/test/issues/general/test_9456.test
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
# name: test/issues/general/test_9456.test
|
||||
# description: Issue 9456: EXISTS operator returns NULL when multiple predicates are present
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
create table u(u0 int, u1 int);
|
||||
|
||||
statement ok
|
||||
create table t(t0 int, t1 int);
|
||||
|
||||
statement ok
|
||||
insert into u values(1, 10);
|
||||
|
||||
statement ok
|
||||
insert into t values(1, 11);
|
||||
|
||||
statement ok
|
||||
insert into u values(null, 20);
|
||||
|
||||
statement ok
|
||||
insert into t values(null, 21);
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
query III
|
||||
SELECT t0, t1, EXISTS (SELECT * FROM u WHERE u0 = t0 AND u1 < t1) FROM t ORDER BY t0, t1;
|
||||
----
|
||||
1 11 true
|
||||
NULL 21 false
|
||||
|
||||
query III
|
||||
SELECT t0, t1, EXISTS (SELECT * FROM u WHERE u0 != t0 AND u1 < t1) FROM t ORDER BY t0, t1;
|
||||
----
|
||||
1 11 false
|
||||
NULL 21 false
|
||||
|
||||
query III
|
||||
SELECT t0, t1, EXISTS (SELECT * FROM u WHERE u0 != t0 AND u1 = t1) FROM t ORDER BY t0, t1;
|
||||
----
|
||||
1 11 false
|
||||
NULL 21 false
|
||||
|
||||
query III
|
||||
SELECT t0, t1, EXISTS (SELECT * FROM u WHERE u0 != t0 AND u1 != t1) FROM t ORDER BY t0, t1;
|
||||
----
|
||||
1 11 false
|
||||
NULL 21 false
|
||||
|
||||
query III
|
||||
SELECT t0, t1, EXISTS (SELECT * FROM u WHERE u0 < t0 AND u1 < t1) FROM t ORDER BY t0, t1;
|
||||
----
|
||||
1 11 false
|
||||
NULL 21 false
|
||||
32
external/duckdb/test/issues/general/test_9738.test
vendored
Normal file
32
external/duckdb/test/issues/general/test_9738.test
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
# name: test/issues/general/test_9738.test
|
||||
# description: Issue 9738: Column identifier is case sensitive when used as a macro parameter.
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
create table MY_TABLE(NAME String);
|
||||
|
||||
statement ok
|
||||
insert into my_table(name) values('Someone');
|
||||
|
||||
statement ok
|
||||
create or replace macro do_nothing(input) as input;
|
||||
|
||||
query I
|
||||
select name from my_table;
|
||||
----
|
||||
Someone
|
||||
|
||||
query I
|
||||
select NAME from my_table;
|
||||
----
|
||||
Someone
|
||||
|
||||
query I
|
||||
select do_nothing(NAME) from my_table;
|
||||
----
|
||||
Someone
|
||||
|
||||
query I
|
||||
select do_nothing(name) from my_table;
|
||||
----
|
||||
Someone
|
||||
70
external/duckdb/test/issues/general/test_9795.test
vendored
Normal file
70
external/duckdb/test/issues/general/test_9795.test
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
# name: test/issues/general/test_9795.test
|
||||
# description: Issue 1091: Min/Max function doesn't use collations.
|
||||
# group: [general]
|
||||
|
||||
statement ok
|
||||
create table tbl (a varchar);
|
||||
|
||||
statement ok
|
||||
insert into tbl values ('ö'), ('o'), ('p');
|
||||
|
||||
query I
|
||||
select max(a) from tbl;
|
||||
----
|
||||
ö
|
||||
|
||||
query I
|
||||
select arg_max(a, a) from tbl;
|
||||
----
|
||||
ö
|
||||
|
||||
query I
|
||||
select max(a collate noaccent) from tbl;
|
||||
----
|
||||
p
|
||||
|
||||
query I
|
||||
select arg_max(a, a collate noaccent) from tbl;
|
||||
----
|
||||
p
|
||||
|
||||
query I
|
||||
select arg_max([a], a collate noaccent) from tbl;
|
||||
----
|
||||
[p]
|
||||
|
||||
query I
|
||||
select min(a) from tbl;
|
||||
----
|
||||
o
|
||||
|
||||
query I
|
||||
select arg_min(a, a) from tbl;
|
||||
----
|
||||
o
|
||||
|
||||
query I
|
||||
select min(a collate noaccent) from tbl;
|
||||
----
|
||||
ö
|
||||
|
||||
query I
|
||||
select arg_min(a, a collate noaccent) from tbl;
|
||||
----
|
||||
ö
|
||||
|
||||
statement ok
|
||||
create table tbl2 (a int);
|
||||
|
||||
statement ok
|
||||
insert into tbl2 values (1), (2), (3);
|
||||
|
||||
query I
|
||||
select min(a) from tbl2;
|
||||
----
|
||||
1
|
||||
|
||||
query I
|
||||
select max(a) from tbl2;
|
||||
----
|
||||
3
|
||||
18
external/duckdb/test/issues/internal/test_5457.test
vendored
Normal file
18
external/duckdb/test/issues/internal/test_5457.test
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
# name: test/issues/internal/test_5457.test
|
||||
# description: Internal Issue 5457: Error type regression: INTERRUPT thrown instead of OutOfMemory
|
||||
# group: [internal]
|
||||
|
||||
require vector_size 2048
|
||||
|
||||
statement ok
|
||||
SET memory_limit='10kb';
|
||||
|
||||
# this works
|
||||
statement ok
|
||||
SELECT 42;
|
||||
|
||||
# explain causes more allocations
|
||||
statement error
|
||||
EXPLAIN SELECT 42;
|
||||
----
|
||||
failed to allocate
|
||||
10
external/duckdb/test/issues/internal/test_5994.test
vendored
Normal file
10
external/duckdb/test/issues/internal/test_5994.test
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# name: test/issues/internal/test_5994.test
|
||||
# description: Internal Issue 5994: (>=1.4) varchar != filter gives wrong result reading from specific parquet
|
||||
# group: [internal]
|
||||
|
||||
require parquet
|
||||
|
||||
query I
|
||||
SELECT COUNT(*) FROM 'data/parquet-testing/internal_5994.parquet' WHERE eventName != 'ListObjects';
|
||||
----
|
||||
118
|
||||
1013
external/duckdb/test/issues/monetdb/analytics10.test
vendored
Normal file
1013
external/duckdb/test/issues/monetdb/analytics10.test
vendored
Normal file
File diff suppressed because it is too large
Load Diff
468
external/duckdb/test/issues/monetdb/analytics11.test
vendored
Normal file
468
external/duckdb/test/issues/monetdb/analytics11.test
vendored
Normal file
@@ -0,0 +1,468 @@
|
||||
# name: test/issues/monetdb/analytics11.test
|
||||
# description: MonetDB Test for grouping sets
|
||||
# group: [monetdb]
|
||||
|
||||
statement ok
|
||||
PRAGMA enable_verification
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tbl_ProductSales (ColID int, Product_Category varchar(64), Product_Name varchar(64), TotalSales int)
|
||||
|
||||
statement ok
|
||||
CREATE TABLE another_T (col1 INT, col2 INT, col3 INT, col4 INT, col5 INT, col6 INT, col7 INT, col8 INT)
|
||||
|
||||
statement ok
|
||||
INSERT INTO tbl_ProductSales VALUES (1,'Game','Mobo Game',200),(2,'Game','PKO Game',400),(3,'Fashion','Shirt',500),(4,'Fashion','Shorts',100)
|
||||
|
||||
statement ok
|
||||
INSERT INTO another_T VALUES (1,2,3,4,5,6,7,8), (11,22,33,44,55,66,77,88), (111,222,333,444,555,666,777,888), (1111,2222,3333,4444,5555,6666,7777,8888)
|
||||
|
||||
query I rowsort
|
||||
SELECT 1
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY Product_Category
|
||||
----
|
||||
1
|
||||
1
|
||||
|
||||
query I rowsort
|
||||
SELECT 1
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY ()
|
||||
----
|
||||
1
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
GROUPING()
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY Product_Category
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
1
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY GROUPING(Product_Name)
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
1
|
||||
FROM tbl_ProductSales
|
||||
WHERE GROUPING(Product_Category) > 1
|
||||
GROUP BY GROUPING SETS((Product_Category))
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
AVG(GROUPING(Product_Category))
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY GROUPING SETS((Product_Category))
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
GROUPING(1)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY Product_Category
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
col1 IN (SELECT ColID + col2 FROM tbl_ProductSales)
|
||||
FROM another_T
|
||||
GROUP BY ROLLUP(col1)
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
(SELECT GROUPING(t1.col1) FROM tbl_ProductSales)
|
||||
FROM another_T t1
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
GROUPING(Product_Name)
|
||||
FROM tbl_ProductSales
|
||||
----
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
GROUPING(Product_Name)
|
||||
FROM tbl_ProductSales GROUP BY ()
|
||||
----
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category) AS myalias
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY Product_Category
|
||||
----
|
||||
0
|
||||
0
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category) myalias
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY Product_Category, Product_Name
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Name, Product_Category)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY Product_Category, Product_Name
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category) AS myalias
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY ROLLUP(Product_Category)
|
||||
----
|
||||
0
|
||||
0
|
||||
1
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category) AS myalias
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY Product_Category, ROLLUP(Product_Category)
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category, Product_Name, ColID)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY ROLLUP(Product_Category, Product_Name, ColID)
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
3
|
||||
3
|
||||
7
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category, Product_Name, ColID)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY ROLLUP((Product_Category, Product_Name, ColID))
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
7
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category, ColID)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY ROLLUP((Product_Category, Product_Name, ColID))
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
3
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category, ColID)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY CUBE((Product_Category, Product_Name, ColID))
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
3
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY GROUPING SETS((Product_Category), (Product_Name), (Product_Category, Product_Name), ())
|
||||
ORDER BY GROUPING(Product_Category)
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY GROUPING SETS((Product_Category), (Product_Name), (Product_Category, Product_Name), ())
|
||||
HAVING GROUPING(Product_Category) = 0
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
|
||||
query II rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category, Product_Name, ColID), GROUPING(Product_Name, ColID)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY CUBE((Product_Category, Product_Name, ColID))
|
||||
ORDER BY GROUPING(Product_Category, ColID)
|
||||
----
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
0
|
||||
7
|
||||
3
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category, Product_Name, ColID) + 1
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY ROLLUP(Product_Category, Product_Name, ColID)
|
||||
HAVING GROUPING(Product_Category, Product_Name, ColID) <> 3
|
||||
ORDER BY GROUPING(Product_Category, Product_Name, ColID) DESC
|
||||
----
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
2
|
||||
2
|
||||
2
|
||||
2
|
||||
8
|
||||
|
||||
# this query was non-deterministic before, "ORDER BY Product_Category, Product_Name" had to be added
|
||||
# now we have the same results as Postgres
|
||||
query IR
|
||||
SELECT
|
||||
GROUPING(Product_Category), AVG(SUM(TotalSales)) OVER (ORDER BY Product_Category, Product_Name ROWS UNBOUNDED PRECEDING)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY GROUPING SETS((Product_Category), (Product_Name), (Product_Category, Product_Name), ())
|
||||
----
|
||||
0 500.0
|
||||
0 300.0
|
||||
0 400.0
|
||||
0 350.0
|
||||
0 360.0
|
||||
0 400.0
|
||||
1 371.42857142857144
|
||||
1 375.0
|
||||
1 388.8888888888889
|
||||
1 360.0
|
||||
1 436.3636363636364
|
||||
|
||||
query II rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category), RANK() OVER (PARTITION BY SUM(TotalSales))
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY GROUPING SETS((Product_Category), (Product_Name), (Product_Category, Product_Name), ())
|
||||
----
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
||||
0
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
1
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
CASE WHEN GROUPING(Product_Category, Product_Name, ColID) * 10 = 30 THEN 2 ELSE NULL END
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY ROLLUP(Product_Category, Product_Name, ColID)
|
||||
----
|
||||
2
|
||||
2
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
NULL
|
||||
|
||||
query II
|
||||
SELECT
|
||||
GROUPING(Product_Category, Product_Name), SUM(TotalSales)
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY GROUPING SETS((Product_Category), (Product_Name), (Product_Category, Product_Name), ())
|
||||
ORDER BY 1, 2
|
||||
----
|
||||
0 100
|
||||
0 200
|
||||
0 400
|
||||
0 500
|
||||
1 600
|
||||
1 600
|
||||
2 100
|
||||
2 200
|
||||
2 400
|
||||
2 500
|
||||
3 1200
|
||||
|
||||
query IIII rowsort
|
||||
SELECT
|
||||
GROUPING(Product_Category),
|
||||
CAST(SUM(SUM(TotalSales)) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS BIGINT),
|
||||
CAST(SUM(GROUPING(Product_Category, Product_Name)) OVER (RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) AS BIGINT),
|
||||
RANK() OVER (PARTITION BY SUM(ColID))
|
||||
FROM tbl_ProductSales
|
||||
GROUP BY GROUPING SETS((Product_Category), (Product_Name), (Product_Category, Product_Name), ())
|
||||
----
|
||||
0
|
||||
4800
|
||||
13
|
||||
1
|
||||
0
|
||||
4800
|
||||
13
|
||||
1
|
||||
0
|
||||
4800
|
||||
13
|
||||
1
|
||||
0
|
||||
4800
|
||||
13
|
||||
1
|
||||
0
|
||||
4800
|
||||
13
|
||||
1
|
||||
0
|
||||
4800
|
||||
13
|
||||
1
|
||||
1
|
||||
4800
|
||||
13
|
||||
1
|
||||
1
|
||||
4800
|
||||
13
|
||||
1
|
||||
1
|
||||
4800
|
||||
13
|
||||
1
|
||||
1
|
||||
4800
|
||||
13
|
||||
1
|
||||
1
|
||||
4800
|
||||
13
|
||||
1
|
||||
|
||||
statement ok
|
||||
CREATE TABLE tbl_X (ColID int, NItems int)
|
||||
|
||||
statement ok
|
||||
INSERT INTO tbl_X VALUES (1,1000),(2,500),(3,323),(4,0)
|
||||
|
||||
query II rowsort
|
||||
SELECT myalias, COUNT(*) FROM
|
||||
(
|
||||
SELECT
|
||||
GROUPING(tbl_ProductSales.ColID, tbl_X.ColID) AS myalias
|
||||
FROM tbl_ProductSales
|
||||
INNER JOIN tbl_X
|
||||
ON tbl_ProductSales.ColID = tbl_X.ColID
|
||||
WHERE tbl_X.NItems < 1000
|
||||
GROUP BY CUBE(tbl_ProductSales.Product_Category, tbl_ProductSales.Product_Name, tbl_ProductSales.ColID), ROLLUP(tbl_X.ColID, tbl_X.NItems)
|
||||
) AS SubTables GROUP BY myalias ORDER BY myalias
|
||||
----
|
||||
0
|
||||
24
|
||||
1
|
||||
12
|
||||
2
|
||||
24
|
||||
3
|
||||
9
|
||||
|
||||
statement error
|
||||
SELECT
|
||||
GROUPING(ColID, ColID)
|
||||
FROM tbl_ProductSales
|
||||
INNER JOIN tbl_X
|
||||
ON tbl_ProductSales.ColID = tbl_X.ColID
|
||||
GROUP BY CUBE(tbl_ProductSales.Product_Category)
|
||||
----
|
||||
|
||||
query I rowsort
|
||||
SELECT
|
||||
GROUPING(tbl_ProductSales.ColID, tbl_X.ColID) AS myalias
|
||||
FROM tbl_ProductSales
|
||||
INNER JOIN tbl_X
|
||||
ON tbl_ProductSales.ColID = tbl_X.ColID
|
||||
WHERE tbl_X.NItems < 1000
|
||||
GROUP BY CUBE(Product_Category, Product_Name, tbl_ProductSales.ColID), ROLLUP(tbl_X.ColID, tbl_X.NItems)
|
||||
ORDER BY SUM(TotalSales) DESC
|
||||
LIMIT 1
|
||||
----
|
||||
3
|
||||
|
||||
statement ok
|
||||
DROP TABLE tbl_ProductSales
|
||||
|
||||
statement ok
|
||||
DROP TABLE tbl_X
|
||||
|
||||
statement ok
|
||||
DROP TABLE another_T
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user