|
| 1 | +statement ok |
| 2 | +USE default |
| 3 | + |
| 4 | +statement ok |
| 5 | +set hide_options_in_show_create_table=1 |
| 6 | + |
| 7 | +# no rewrite: int32 -> int64 |
| 8 | +statement ok |
| 9 | +drop table if exists alter_no_rewrite_t_int |
| 10 | + |
| 11 | +statement ok |
| 12 | +create table alter_no_rewrite_t_int(a int null) |
| 13 | + |
| 14 | +statement ok |
| 15 | +insert into alter_no_rewrite_t_int values (1), (2), (3) |
| 16 | + |
| 17 | +statement ok |
| 18 | +drop table if exists alter_no_rewrite_loc_int |
| 19 | + |
| 20 | +statement ok |
| 21 | +create table alter_no_rewrite_loc_int(block_location string) |
| 22 | + |
| 23 | +statement ok |
| 24 | +insert into alter_no_rewrite_loc_int select block_location from fuse_block('default','alter_no_rewrite_t_int') |
| 25 | + |
| 26 | +statement ok |
| 27 | +alter table alter_no_rewrite_t_int modify column a bigint null |
| 28 | + |
| 29 | +query IIII |
| 30 | +select |
| 31 | + (select count(*) from fuse_block('default','alter_no_rewrite_t_int')) as after_cnt, |
| 32 | + (select count(*) from alter_no_rewrite_loc_int) as before_cnt, |
| 33 | + (select count(*) from ( |
| 34 | + select block_location from alter_no_rewrite_loc_int |
| 35 | + except |
| 36 | + select block_location from fuse_block('default','alter_no_rewrite_t_int') |
| 37 | + )) as missing_from_after, |
| 38 | + (select count(*) from ( |
| 39 | + select block_location from fuse_block('default','alter_no_rewrite_t_int') |
| 40 | + except |
| 41 | + select block_location from alter_no_rewrite_loc_int |
| 42 | + )) as new_in_after |
| 43 | +---- |
| 44 | +1 1 0 0 |
| 45 | + |
| 46 | +query I |
| 47 | +select a from alter_no_rewrite_t_int order by a |
| 48 | +---- |
| 49 | +1 |
| 50 | +2 |
| 51 | +3 |
| 52 | + |
| 53 | +query T |
| 54 | +select data_type from system.columns where database = 'default' and table = 'alter_no_rewrite_t_int' and name = 'a' |
| 55 | +---- |
| 56 | +BIGINT |
| 57 | + |
| 58 | +# no rewrite: decimal precision widen (scale unchanged) |
| 59 | +statement ok |
| 60 | +drop table if exists alter_no_rewrite_t_dec |
| 61 | + |
| 62 | +statement ok |
| 63 | +create table alter_no_rewrite_t_dec(a decimal(10, 2) null) |
| 64 | + |
| 65 | +statement ok |
| 66 | +insert into alter_no_rewrite_t_dec values (1.23), (4.56) |
| 67 | + |
| 68 | +statement ok |
| 69 | +drop table if exists alter_no_rewrite_loc_dec |
| 70 | + |
| 71 | +statement ok |
| 72 | +create table alter_no_rewrite_loc_dec(block_location string) |
| 73 | + |
| 74 | +statement ok |
| 75 | +insert into alter_no_rewrite_loc_dec select block_location from fuse_block('default','alter_no_rewrite_t_dec') |
| 76 | + |
| 77 | +statement ok |
| 78 | +alter table alter_no_rewrite_t_dec modify column a decimal(20, 2) null |
| 79 | + |
| 80 | +query IIII |
| 81 | +select |
| 82 | + (select count(*) from fuse_block('default','alter_no_rewrite_t_dec')) as after_cnt, |
| 83 | + (select count(*) from alter_no_rewrite_loc_dec) as before_cnt, |
| 84 | + (select count(*) from ( |
| 85 | + select block_location from alter_no_rewrite_loc_dec |
| 86 | + except |
| 87 | + select block_location from fuse_block('default','alter_no_rewrite_t_dec') |
| 88 | + )) as missing_from_after, |
| 89 | + (select count(*) from ( |
| 90 | + select block_location from fuse_block('default','alter_no_rewrite_t_dec') |
| 91 | + except |
| 92 | + select block_location from alter_no_rewrite_loc_dec |
| 93 | + )) as new_in_after |
| 94 | +---- |
| 95 | +1 1 0 0 |
| 96 | + |
| 97 | +query T |
| 98 | +select data_type from system.columns where database = 'default' and table = 'alter_no_rewrite_t_dec' and name = 'a' |
| 99 | +---- |
| 100 | +DECIMAL(20, 2) |
| 101 | + |
| 102 | +# range pruning after widening |
| 103 | +statement ok |
| 104 | +drop table if exists alter_no_rewrite_range |
| 105 | + |
| 106 | +statement ok |
| 107 | +create table alter_no_rewrite_range(a int) |
| 108 | + |
| 109 | +statement ok |
| 110 | +insert into alter_no_rewrite_range select number from numbers(1000) |
| 111 | + |
| 112 | +statement ok |
| 113 | +insert into alter_no_rewrite_range select number + 1000 from numbers(1000) |
| 114 | + |
| 115 | +statement ok |
| 116 | +insert into alter_no_rewrite_range select number + 2000 from numbers(1000) |
| 117 | + |
| 118 | +statement ok |
| 119 | +alter table alter_no_rewrite_range modify column a bigint |
| 120 | + |
| 121 | +query T |
| 122 | +explain select 1 from alter_no_rewrite_range where a = 42 |
| 123 | +---- |
| 124 | +EvalScalar |
| 125 | +├── output columns: [1 (#1)] |
| 126 | +├── expressions: [1] |
| 127 | +├── estimated rows: 1.00 |
| 128 | +└── Filter |
| 129 | + ├── output columns: [] |
| 130 | + ├── filters: [is_true(alter_no_rewrite_range.a (#0) = 42)] |
| 131 | + ├── estimated rows: 1.00 |
| 132 | + └── TableScan |
| 133 | + ├── table: default.default.alter_no_rewrite_range |
| 134 | + ├── scan id: 0 |
| 135 | + ├── output columns: [a (#0)] |
| 136 | + ├── read rows: 1000 |
| 137 | + ├── read size: 1.88 KiB |
| 138 | + ├── partitions total: 3 |
| 139 | + ├── partitions scanned: 1 |
| 140 | + ├── pruning stats: [segments: <range pruning: 3 to 1 cost: <slt:ignore>>, blocks: <range pruning: 1 to 1 cost: <slt:ignore>, bloom pruning: 1 to 1 cost: <slt:ignore>>] |
| 141 | + ├── push downs: [filters: [is_true(alter_no_rewrite_range.a (#0) = 42)], limit: NONE] |
| 142 | + └── estimated rows: 3000.00 |
| 143 | + |
| 144 | +# bloom pruning after widening |
| 145 | +statement ok |
| 146 | +drop table if exists alter_no_rewrite_bloom |
| 147 | + |
| 148 | +statement ok |
| 149 | +create table alter_no_rewrite_bloom(a int, b int) |
| 150 | + |
| 151 | +statement ok |
| 152 | +alter table alter_no_rewrite_bloom set options(bloom_index_columns = 'a') |
| 153 | + |
| 154 | +statement ok |
| 155 | +insert into alter_no_rewrite_bloom values (1, 1), (5, 6), (10, 10) |
| 156 | + |
| 157 | +statement ok |
| 158 | +insert into alter_no_rewrite_bloom values (1, 1), (7, 8), (10, 10) |
| 159 | + |
| 160 | +statement ok |
| 161 | +alter table alter_no_rewrite_bloom modify column a bigint |
| 162 | + |
| 163 | +query T |
| 164 | +explain select 1 from alter_no_rewrite_bloom where a = 5 |
| 165 | +---- |
| 166 | +EvalScalar |
| 167 | +├── output columns: [1 (#2)] |
| 168 | +├── expressions: [1] |
| 169 | +├── estimated rows: 1.50 |
| 170 | +└── Filter |
| 171 | + ├── output columns: [] |
| 172 | + ├── filters: [is_true(alter_no_rewrite_bloom.a (#0) = 5)] |
| 173 | + ├── estimated rows: 1.50 |
| 174 | + └── TableScan |
| 175 | + ├── table: default.default.alter_no_rewrite_bloom |
| 176 | + ├── scan id: 0 |
| 177 | + ├── output columns: [a (#0)] |
| 178 | + ├── read rows: 3 |
| 179 | + ├── read size: < 1 KiB |
| 180 | + ├── partitions total: 2 |
| 181 | + ├── partitions scanned: 1 |
| 182 | + ├── pruning stats: [segments: <range pruning: 2 to 2 cost: <slt:ignore>>, blocks: <range pruning: 2 to 2 cost: <slt:ignore>, bloom pruning: 2 to 1 cost: <slt:ignore>>] |
| 183 | + ├── push downs: [filters: [is_true(alter_no_rewrite_bloom.a (#0) = 5)], limit: NONE] |
| 184 | + └── estimated rows: 6.00 |
| 185 | + |
| 186 | +query I |
| 187 | +select 1 from alter_no_rewrite_bloom where a = 5 |
| 188 | +---- |
| 189 | +1 |
0 commit comments