Skip to content

Commit be38ff5

Browse files
congxuebincongxuebin
andauthored
Make AOCO_Compression test case stable.
change AOCO_Compression test case to validate pg_relation_size and get_ao_compression_ratio within ±10% expected range according to issue #487 (#493) Co-authored-by: congxuebin <hashdata@hashdatadeMacBook-Pro.local>
1 parent 1e70fdc commit be38ff5

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

src/test/regress/expected/AOCO_Compression.out

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3572,15 +3572,43 @@ Access method: ao_column
35723572
-- When I insert data
35733573
insert into mpp17012_compress_test2 values('a',generate_series(1,250),'ksjdhfksdhfksdhfksjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh','bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
35743574
-- Then the data will be compressed according to a consistent compression ratio
3575+
-- start_ignore
35753576
select pg_size_pretty(pg_relation_size('mpp17012_compress_test2')),
35763577
get_ao_compression_ratio('mpp17012_compress_test2');
35773578
pg_size_pretty | get_ao_compression_ratio
35783579
----------------+--------------------------
35793580
712 bytes | 36.75
35803581
(1 row)
35813582

3583+
-- end_ignore
3584+
select
3585+
case
3586+
when
3587+
abs((pg_relation_size('mpp17012_compress_test2') - 712.0) / 712.0) < 0.1
3588+
then 'test passed'
3589+
else 'test failed'
3590+
end as test_relation_size;
3591+
test_relation_size
3592+
--------------------
3593+
test passed
3594+
(1 row)
3595+
3596+
select
3597+
case
3598+
when
3599+
abs((get_ao_compression_ratio('mpp17012_compress_test2') - 36.75) / 36.75) < 0.1
3600+
then 'test passed'
3601+
else 'test failed'
3602+
end as test_ao_compression_ratio;
3603+
test_ao_compression_ratio
3604+
---------------------------
3605+
test passed
3606+
(1 row)
3607+
35823608
-- Test that an AO/CO table with compresstype zlib and invalid compress level will error at create
35833609
create table a_aoco_table_with_zlib_and_invalid_compression_level(col text) WITH (APPENDONLY=true, COMPRESSTYPE=zlib, compresslevel=-1, ORIENTATION=column);
3610+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col' as the Cloudberry Database data distribution key for this table.
3611+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
35843612
ERROR: value -1 out of bounds for option "compresslevel"
35853613
DETAIL: Valid values are between "0" and "19".
35863614
-- Check that callbacks are registered
@@ -3604,15 +3632,43 @@ select pg_size_pretty(pg_relation_size('a_aoco_table_with_rle_type_compression')
36043632
-- When I insert data
36053633
insert into a_aoco_table_with_rle_type_compression select i from generate_series(1,100)i;
36063634
-- Then the data will be compressed according to a consistent compression ratio
3635+
-- start_ignore
36073636
select pg_size_pretty(pg_relation_size('a_aoco_table_with_rle_type_compression')),
36083637
get_ao_compression_ratio('a_aoco_table_with_rle_type_compression');
36093638
pg_size_pretty | get_ao_compression_ratio
36103639
----------------+--------------------------
36113640
296 bytes | 1.81
36123641
(1 row)
36133642

3643+
-- end_ignore
3644+
select
3645+
case
3646+
when
3647+
abs((pg_relation_size('a_aoco_table_with_rle_type_compression') - 296.0) / 296.0) < 0.1
3648+
then 'test passed'
3649+
else 'test failed'
3650+
end as test_relation_size;
3651+
test_relation_size
3652+
--------------------
3653+
test passed
3654+
(1 row)
3655+
3656+
select
3657+
case
3658+
when
3659+
abs((get_ao_compression_ratio('a_aoco_table_with_rle_type_compression') - 1.81) / 1.81) < 0.1
3660+
then 'test passed'
3661+
else 'test failed'
3662+
end as test_ao_compression_ratio;
3663+
test_ao_compression_ratio
3664+
---------------------------
3665+
test passed
3666+
(1 row)
3667+
36143668
-- Test that an AO/CO table with compresstype rle and invalid compress level will error at create
36153669
create table a_aoco_table_with_rle_type_and_invalid_compression_level(col int) WITH (APPENDONLY=true, COMPRESSTYPE=rle_type, compresslevel=-1, ORIENTATION=column);
3670+
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'col' as the Cloudberry Database data distribution key for this table.
3671+
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
36163672
ERROR: value -1 out of bounds for option "compresslevel"
36173673
DETAIL: Valid values are between "0" and "19".
36183674
-- Check that callbacks are registered

src/test/regress/sql/AOCO_Compression.sql

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,8 +1748,25 @@ get_ao_compression_ratio('mpp17012_compress_test2');
17481748
-- When I insert data
17491749
insert into mpp17012_compress_test2 values('a',generate_series(1,250),'ksjdhfksdhfksdhfksjhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh','bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb');
17501750
-- Then the data will be compressed according to a consistent compression ratio
1751+
-- start_ignore
17511752
select pg_size_pretty(pg_relation_size('mpp17012_compress_test2')),
17521753
get_ao_compression_ratio('mpp17012_compress_test2');
1754+
-- end_ignore
1755+
select
1756+
case
1757+
when
1758+
abs((pg_relation_size('mpp17012_compress_test2') - 712.0) / 712.0) < 0.1
1759+
then 'test passed'
1760+
else 'test failed'
1761+
end as test_relation_size;
1762+
1763+
select
1764+
case
1765+
when
1766+
abs((get_ao_compression_ratio('mpp17012_compress_test2') - 36.75) / 36.75) < 0.1
1767+
then 'test passed'
1768+
else 'test failed'
1769+
end as test_ao_compression_ratio;
17531770

17541771
-- Test that an AO/CO table with compresstype zlib and invalid compress level will error at create
17551772
create table a_aoco_table_with_zlib_and_invalid_compression_level(col text) WITH (APPENDONLY=true, COMPRESSTYPE=zlib, compresslevel=-1, ORIENTATION=column);
@@ -1764,8 +1781,25 @@ select pg_size_pretty(pg_relation_size('a_aoco_table_with_rle_type_compression')
17641781
-- When I insert data
17651782
insert into a_aoco_table_with_rle_type_compression select i from generate_series(1,100)i;
17661783
-- Then the data will be compressed according to a consistent compression ratio
1784+
-- start_ignore
17671785
select pg_size_pretty(pg_relation_size('a_aoco_table_with_rle_type_compression')),
17681786
get_ao_compression_ratio('a_aoco_table_with_rle_type_compression');
1787+
-- end_ignore
1788+
select
1789+
case
1790+
when
1791+
abs((pg_relation_size('a_aoco_table_with_rle_type_compression') - 296.0) / 296.0) < 0.1
1792+
then 'test passed'
1793+
else 'test failed'
1794+
end as test_relation_size;
1795+
1796+
select
1797+
case
1798+
when
1799+
abs((get_ao_compression_ratio('a_aoco_table_with_rle_type_compression') - 1.81) / 1.81) < 0.1
1800+
then 'test passed'
1801+
else 'test failed'
1802+
end as test_ao_compression_ratio;
17691803

17701804
-- Test that an AO/CO table with compresstype rle and invalid compress level will error at create
17711805
create table a_aoco_table_with_rle_type_and_invalid_compression_level(col int) WITH (APPENDONLY=true, COMPRESSTYPE=rle_type, compresslevel=-1, ORIENTATION=column);

0 commit comments

Comments
 (0)