|
| 1 | +# Test cases for iceberg sink compaction_type validation |
| 2 | +# This file tests validation logic for compaction_type parameter |
| 3 | + |
| 4 | +statement ok |
| 5 | +DROP TABLE IF EXISTS t_validation; |
| 6 | + |
| 7 | +statement ok |
| 8 | +CREATE TABLE t_validation ( |
| 9 | + id bigint primary key, |
| 10 | + data varchar |
| 11 | +); |
| 12 | + |
| 13 | +# Test case 1: Error - unknown compaction_type |
| 14 | +statement error Unknown compaction type 'invalid-type' |
| 15 | +CREATE SINK s_unknown AS SELECT * FROM t_validation WITH ( |
| 16 | + connector = 'iceberg', |
| 17 | + type = 'upsert', |
| 18 | + primary_key = 'id', |
| 19 | + database.name = 'demo_db', |
| 20 | + table.name = 'test_unknown', |
| 21 | + catalog.name = 'demo', |
| 22 | + catalog.type = 'storage', |
| 23 | + warehouse.path = 's3a://icebergdata/demo', |
| 24 | + s3.endpoint = 'http://127.0.0.1:9301', |
| 25 | + s3.region = 'us-east-1', |
| 26 | + s3.access.key = 'hummockadmin', |
| 27 | + s3.secret.key = 'hummockadmin', |
| 28 | + create_table_if_not_exists = 'true', |
| 29 | + compaction.type = 'invalid_type' |
| 30 | +); |
| 31 | + |
| 32 | +# Test case 2: Error - COW mode with non-full compaction_type (small_files) |
| 33 | +statement error Copy-on-write mode only supports 'full' compaction type |
| 34 | +CREATE SINK s_cow_small_files AS SELECT * FROM t_validation WITH ( |
| 35 | + connector = 'iceberg', |
| 36 | + type = 'upsert', |
| 37 | + primary_key = 'id', |
| 38 | + database.name = 'demo_db', |
| 39 | + table.name = 'test_cow_small', |
| 40 | + catalog.name = 'demo', |
| 41 | + catalog.type = 'storage', |
| 42 | + warehouse.path = 's3a://icebergdata/demo', |
| 43 | + s3.endpoint = 'http://127.0.0.1:9301', |
| 44 | + s3.region = 'us-east-1', |
| 45 | + s3.access.key = 'hummockadmin', |
| 46 | + s3.secret.key = 'hummockadmin', |
| 47 | + create_table_if_not_exists = 'true', |
| 48 | + write_mode = 'copy-on-write', |
| 49 | + compaction.type = 'small_files' |
| 50 | +); |
| 51 | + |
| 52 | +# Test case 3: Error - COW mode with files_with_delete |
| 53 | +statement error Copy-on-write mode only supports 'full' compaction type |
| 54 | +CREATE SINK s_cow_files_delete AS SELECT * FROM t_validation WITH ( |
| 55 | + connector = 'iceberg', |
| 56 | + type = 'upsert', |
| 57 | + primary_key = 'id', |
| 58 | + database.name = 'demo_db', |
| 59 | + table.name = 'test_cow_delete', |
| 60 | + catalog.name = 'demo', |
| 61 | + catalog.type = 'storage', |
| 62 | + warehouse.path = 's3a://icebergdata/demo', |
| 63 | + s3.endpoint = 'http://127.0.0.1:9301', |
| 64 | + s3.region = 'us-east-1', |
| 65 | + s3.access.key = 'hummockadmin', |
| 66 | + s3.secret.key = 'hummockadmin', |
| 67 | + create_table_if_not_exists = 'true', |
| 68 | + write_mode = 'copy-on-write', |
| 69 | + compaction.type = 'files_with_delete' |
| 70 | +); |
| 71 | + |
| 72 | +# Test case 4: Error - small_files with conflicting parameter delete_files_count_threshold |
| 73 | +statement error `compaction.delete_files_count_threshold` is not supported for 'small-files' compaction type |
| 74 | +CREATE SINK s_small_files_conflict AS SELECT * FROM t_validation WITH ( |
| 75 | + connector = 'iceberg', |
| 76 | + type = 'upsert', |
| 77 | + primary_key = 'id', |
| 78 | + database.name = 'demo_db', |
| 79 | + table.name = 'test_small_conflict', |
| 80 | + catalog.name = 'demo', |
| 81 | + catalog.type = 'storage', |
| 82 | + warehouse.path = 's3a://icebergdata/demo', |
| 83 | + s3.endpoint = 'http://127.0.0.1:9301', |
| 84 | + s3.region = 'us-east-1', |
| 85 | + s3.access.key = 'hummockadmin', |
| 86 | + s3.secret.key = 'hummockadmin', |
| 87 | + create_table_if_not_exists = 'true', |
| 88 | + write_mode = 'merge-on-read', |
| 89 | + compaction.type = 'small_files', |
| 90 | + compaction.delete_files_count_threshold = '5' |
| 91 | +); |
| 92 | + |
| 93 | +# Test case 5: Error - files_with_delete with conflicting parameter small_files_threshold_mb |
| 94 | +statement error `compaction.small_files_threshold_mb` must not be set for 'files-with-delete' compaction type |
| 95 | +CREATE SINK s_delete_files_conflict AS SELECT * FROM t_validation WITH ( |
| 96 | + connector = 'iceberg', |
| 97 | + type = 'upsert', |
| 98 | + primary_key = 'id', |
| 99 | + database.name = 'demo_db', |
| 100 | + table.name = 'test_delete_conflict', |
| 101 | + catalog.name = 'demo', |
| 102 | + catalog.type = 'storage', |
| 103 | + warehouse.path = 's3a://icebergdata/demo', |
| 104 | + s3.endpoint = 'http://127.0.0.1:9301', |
| 105 | + s3.region = 'us-east-1', |
| 106 | + s3.access.key = 'hummockadmin', |
| 107 | + s3.secret.key = 'hummockadmin', |
| 108 | + create_table_if_not_exists = 'true', |
| 109 | + write_mode = 'merge-on-read', |
| 110 | + compaction.type = 'files_with_delete', |
| 111 | + compaction.small_files_threshold_mb = '128' |
| 112 | +); |
| 113 | + |
| 114 | +# Clean up |
| 115 | +statement ok |
| 116 | +DROP TABLE t_validation; |
0 commit comments