should be it

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

View File

@@ -0,0 +1,110 @@
# name: test/sql/storage/compression/constant/constant_columns.test_slow
# description: Test storage of constant columns (columns that all have the same value)
# group: [constant]
# load the DB from disk
load __TEST_DIR__/constant_columns.db
# simple constant
statement ok
CREATE TABLE integers AS SELECT 1 i FROM range(1000000)
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM integers
----
1 1 1 1000000 1000000
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM integers WHERE i=1
----
1 1 1 1000000 1000000
restart
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM integers
----
1 1 1 1000000 1000000
# constant null
statement ok
CREATE TABLE nulls AS SELECT NULL i FROM range(1000000)
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM nulls
----
NULL NULL NULL 1000000 0
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM nulls WHERE i IS NULL
----
NULL NULL NULL 1000000 0
restart
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM nulls
----
NULL NULL NULL 1000000 0
# mix of constant and non-constant
statement ok
CREATE TABLE mixed_table AS SELECT CASE WHEN i < 1000000 then 1 else i end i FROM range(2000000) tbl(i)
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_table
----
1 1999999 2000000 2000000
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_table WHERE i=1
----
1 1 1000000 1000000
restart
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_table
----
1 1999999 2000000 2000000
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_table WHERE i=1
----
1 1 1000000 1000000
# mix of constant and non-constant NULL
statement ok
CREATE TABLE mixed_nulls AS SELECT CASE WHEN i < 1000000 then 1 else NULL end i FROM range(2000000) tbl(i)
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_nulls
----
1 1 2000000 1000000
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_nulls WHERE i=1
----
1 1 1000000 1000000
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_nulls WHERE i IS NULL
----
NULL NULL 1000000 0
restart
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_nulls
----
1 1 2000000 1000000
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_nulls WHERE i=1
----
1 1 1000000 1000000
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM mixed_nulls WHERE i IS NULL
----
NULL NULL 1000000 0

View File

@@ -0,0 +1,51 @@
# name: test/sql/storage/compression/constant/constant_columns_indexes.test_slow
# description: Test storage of constant columns with indexes
# group: [constant]
# load the DB from disk
load __TEST_DIR__/constant_columns.db
# simple constant
statement ok
CREATE TABLE integers AS SELECT i id,
CASE WHEN i < 500000 THEN 1 ELSE NULL END i FROM range(1000000) tbl(i);
statement ok
CREATE INDEX i_index ON integers(id);
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM integers;
----
1 1 1 1000000 500000
query II
SELECT * FROM integers WHERE id = 1;
----
1 1
query II
SELECT * FROM integers WHERE id = 2;
----
2 1
query II
SELECT * FROM integers WHERE id = 999999;
----
999999 NULL
restart
query II
SELECT * FROM integers WHERE id = 1;
----
1 1
query II
SELECT * FROM integers WHERE id = 2;
----
2 1
query II
SELECT * FROM integers WHERE id = 999999;
----
999999 NULL

View File

@@ -0,0 +1,31 @@
# name: test/sql/storage/compression/constant/constant_columns_top_n.test_slow
# description: Test Top-N operation on constant columns
# group: [constant]
# load the DB from disk
load __TEST_DIR__/constant_columns.db
# simple constant
statement ok
CREATE TABLE integers AS SELECT 1 i FROM range(1000000)
statement ok
INSERT INTO integers SELECT 2 FROM range(1000000)
query I
SELECT * FROM integers ORDER BY i LIMIT 5
----
1
1
1
1
1
query I
SELECT * FROM integers ORDER BY i DESC LIMIT 5
----
2
2
2
2
2

View File

@@ -0,0 +1,60 @@
# name: test/sql/storage/compression/constant/constant_columns_types.test_slow
# description: Test storage of constant columns with various types
# group: [constant]
# load the DB from disk
load __TEST_DIR__/constant_columns_types.db
foreach type <numeric> decimal(4,1) decimal(8,1) decimal(12,1) decimal(18,1)
statement ok
CREATE TABLE a AS SELECT 1::${type} i FROM range(1000000)
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM a
----
1 1 1 1000000 1000000
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM a WHERE i=1
----
1 1 1 1000000 1000000
statement ok
DROP TABLE a
endloop
# interval
statement ok
CREATE TABLE a AS SELECT interval 1 year i FROM range(1000000)
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM a
----
1 year 1 year 1000000 1000000
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM a WHERE i=interval 1 year
----
1 year 1 year 1000000 1000000
statement ok
DROP TABLE a
# bool
statement ok
CREATE TABLE a AS SELECT false i FROM range(1000000)
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM a
----
false false 1000000 1000000
query IIII
SELECT MIN(i), MAX(i), COUNT(*), COUNT(i) FROM a WHERE not i
----
false false 1000000 1000000
statement ok
DROP TABLE a

View File

@@ -0,0 +1,32 @@
# name: test/sql/storage/compression/constant/constant_columns_updates.test_slow
# description: Test storage of constant columns with updates
# group: [constant]
# load the DB from disk
load __TEST_DIR__/constant_columns.db
# simple constant
statement ok
CREATE TABLE integers AS SELECT i id, 1 i FROM range(1000000) tbl(i)
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM integers
----
1 1 1 1000000 1000000
query I
UPDATE integers SET i=i+1 WHERE id%2=0
----
500000
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM integers
----
1 2 1.5 1000000 1000000
restart
query IIIII
SELECT MIN(i), MAX(i), AVG(i), COUNT(*), COUNT(i) FROM integers
----
1 2 1.5 1000000 1000000