Files
email-tracker/external/duckdb/test/sql/create/create_table_compression.test
2025-10-24 19:21:19 -05:00

189 lines
2.9 KiB
SQL

# name: test/sql/create/create_table_compression.test
# description: Test CREATE TABLE using compression options
# group: [create]
# This test defaults to another compression function for smaller block sizes,
# because the bitpacking groups no longer fit the blocks.
require block_size 262144
require skip_reload
statement ok
PRAGMA enable_verification
statement ok
CREATE TABLE T (a INTEGER USING COMPRESSION RLE)
statement ok
DROP TABLE T
statement error
CREATE TABLE T (a INTEGER USING COMPRESSION 'bla')
----
statement error
CREATE TABLE T (a INTEGER USING COMPRESSION )
----
Parser Error: syntax error at or near ")"
statement error
CREATE TABLE T (a INTEGER NOT NULL USING COMPRESSION )
----
Parser Error: syntax error at or near ")"
statement error
CREATE TABLE T (a INTEGER USING COMPRESSION bla)
----
Parser Error: Unrecognized option for column compression, expected none, uncompressed, rle, dictionary, pfor, bitpacking, fsst, chimp, patas, zstd, alp, alprd or roaring
statement ok
CREATE TABLE T (a INTEGER NOT NULL USING COMPRESSION RLE)
statement ok
DROP TABLE T
statement ok
CREATE TABLE T (a INTEGER USING COMPRESSION RLE, b VARCHAR )
statement ok
DROP TABLE T
load __TEST_DIR__/test_compression_hint.db
statement ok
CREATE TABLE T (a INTEGER USING COMPRESSION RLE, b INTEGER USING COMPRESSION BITPACKING, C INTEGER USING COMPRESSION UNCOMPRESSED)
statement ok
INSERT INTO T VALUES (1,1,1), (1,1,1), (1,1,1), (2,2,2), (2,2,2), (3,3,3)
query III
SELECT * FROM T
----
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
3 3 3
restart
query III
SELECT * FROM T
----
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
3 3 3
statement ok
CHECKPOINT
query I
SELECT compression FROM pragma_storage_info('T') WHERE segment_type ILIKE 'INTEGER' LIMIT 3
----
RLE
BitPacking
Uncompressed
statement ok
ALTER TABLE T RENAME COLUMN a TO a_1
statement ok
ALTER TABLE T RENAME COLUMN b TO b_1
statement ok
ALTER TABLE T RENAME COLUMN c TO c_1
restart
query III
SELECT * FROM T
----
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
3 3 3
query I
SELECT compression FROM pragma_storage_info('T') WHERE segment_type ILIKE 'INTEGER' LIMIT 3
----
RLE
BitPacking
Uncompressed
statement ok
ALTER TABLE T RENAME TO T_1
restart
query III
SELECT * FROM T_1
----
1 1 1
1 1 1
1 1 1
2 2 2
2 2 2
3 3 3
query I
SELECT compression FROM pragma_storage_info('T_1') WHERE segment_type ILIKE 'INTEGER' LIMIT 3
----
RLE
BitPacking
Uncompressed
# Test Drop Column
statement ok
ALTER TABLE T_1 DROP COLUMN c_1
statement ok
ALTER TABLE T_1 DROP COLUMN b_1
restart
query I
SELECT * FROM T_1
----
1
1
1
2
2
3
query I
SELECT compression FROM pragma_storage_info('T_1') WHERE segment_type ILIKE 'INTEGER' LIMIT 2
----
RLE
# Test Add Column
statement ok
ALTER TABLE T_1 ADD COLUMN b INTEGER DEFAULT 2
restart
query II
SELECT * FROM T_1
----
1 2
1 2
1 2
2 2
2 2
3 2
statement ok
CHECKPOINT
query I
SELECT compression FROM pragma_storage_info('T_1') WHERE segment_type ILIKE 'INTEGER' LIMIT 3
----
RLE
Constant