Commit 51a51d8
committed
sql/schemachanger: move column compute expression to separate DSC element
Previously, the column compute expression was part of the ColumnType
element, which made it difficult to change the compute expression
without affecting the other fields in ColumnType. To address this,
especially for the upcoming work on adding a temporary compute
expression during column type changes that require a backfill (in
#127014), we’re moving the compute expression into its own separate
element, similar to how default expressions (ColumnDefaultExpression)
and ON UPDATE expressions (ColumnOnUpdateExpression) are handled.
Key points to note about this change:
- Version Gate: The new element must be protected by a version gate. For
older versions, we’ll continue using the old compute expression field
in ColumnType. There was one instance where the current cluster
version wasn’t accessible, so I added a field in
ElementCreationMetadata to track if the ColumnType was created in
24.3. This acts as the version gate.
- IsVirtual Attribute: Although logically, the IsVirtual attribute
should belong to ColumnComputeExpression, I left it in ColumnType.
During the ADD COLUMN process, we set up the column family for the new
column only if it’s not virtual. Moving IsVirtual to
ColumnComputeExpression would require a dependency rule to ensure the
ColumnComputeExpression is applied before ColumnType to set up the
column family correctly.
- Dropping a Compute Column: When dropping a computed column, I leave a
NULL expression in the column descriptor. If the expression is removed
entirely, it triggers validation logic that a virtual column must have
a compute expression. We will need to revisit this, especially for
the ALTER TABLE .. TYPE use case and future support for ALTER TABLE ..
DROP EXPRESSION.
Epic: CRDB-25314
Informs: #127014
Release note: None1 parent 5dbc891 commit 51a51d8
File tree
107 files changed
+1327
-539
lines changed- pkg
- ccl/schemachangerccl/testdata/decomp
- sql
- catalog/redact
- opt/exec/execbuilder/testdata
- schemachanger
- scbuild
- internal/scbuildstmt
- testdata
- scdecomp
- testdata
- scexec/scmutationexec
- scop
- scpb
- uml
- scplan
- internal
- opgen
- rules
- current
- testdata
- release_24_1
- release_24_2
- testdata
- screl
- testdata/end_to_end
- add_column_virtual_not_null
- add_column_with_stored_family
- add_column_with_stored
- alter_table_alter_column_type_trivial
- alter_table_alter_primary_key_using_hash
- drop_column_computed_index
- drop_column_create_index_separate_statements
- drop_index_hash_sharded_index
- drop_index_partial_expression_index
- drop_multiple_columns_separate_statements
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
107 files changed
+1327
-539
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
| |||
228 | 229 | | |
229 | 230 | | |
230 | 231 | | |
| 232 | + | |
231 | 233 | | |
232 | 234 | | |
233 | 235 | | |
| |||
256 | 258 | | |
257 | 259 | | |
258 | 260 | | |
| 261 | + | |
259 | 262 | | |
260 | 263 | | |
261 | 264 | | |
| |||
284 | 287 | | |
285 | 288 | | |
286 | 289 | | |
| 290 | + | |
287 | 291 | | |
288 | 292 | | |
289 | 293 | | |
| |||
497 | 501 | | |
498 | 502 | | |
499 | 503 | | |
| 504 | + | |
500 | 505 | | |
501 | 506 | | |
502 | 507 | | |
| |||
525 | 530 | | |
526 | 531 | | |
527 | 532 | | |
| 533 | + | |
528 | 534 | | |
529 | 535 | | |
530 | 536 | | |
| |||
553 | 559 | | |
554 | 560 | | |
555 | 561 | | |
| 562 | + | |
556 | 563 | | |
557 | 564 | | |
558 | 565 | | |
| |||
581 | 588 | | |
582 | 589 | | |
583 | 590 | | |
| 591 | + | |
584 | 592 | | |
585 | 593 | | |
586 | 594 | | |
| |||
835 | 843 | | |
836 | 844 | | |
837 | 845 | | |
| 846 | + | |
838 | 847 | | |
839 | 848 | | |
840 | 849 | | |
| |||
864 | 873 | | |
865 | 874 | | |
866 | 875 | | |
| 876 | + | |
867 | 877 | | |
868 | 878 | | |
869 | 879 | | |
| |||
892 | 902 | | |
893 | 903 | | |
894 | 904 | | |
| 905 | + | |
895 | 906 | | |
896 | 907 | | |
897 | 908 | | |
| |||
920 | 931 | | |
921 | 932 | | |
922 | 933 | | |
| 934 | + | |
923 | 935 | | |
924 | 936 | | |
925 | 937 | | |
| |||
948 | 960 | | |
949 | 961 | | |
950 | 962 | | |
| 963 | + | |
951 | 964 | | |
952 | 965 | | |
953 | 966 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
159 | 160 | | |
160 | 161 | | |
161 | 162 | | |
| 163 | + | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
| |||
187 | 189 | | |
188 | 190 | | |
189 | 191 | | |
| 192 | + | |
190 | 193 | | |
191 | 194 | | |
192 | 195 | | |
| |||
215 | 218 | | |
216 | 219 | | |
217 | 220 | | |
| 221 | + | |
218 | 222 | | |
219 | 223 | | |
220 | 224 | | |
| |||
243 | 247 | | |
244 | 248 | | |
245 | 249 | | |
| 250 | + | |
246 | 251 | | |
247 | 252 | | |
248 | 253 | | |
| |||
534 | 539 | | |
535 | 540 | | |
536 | 541 | | |
| 542 | + | |
537 | 543 | | |
538 | 544 | | |
539 | 545 | | |
| |||
562 | 568 | | |
563 | 569 | | |
564 | 570 | | |
| 571 | + | |
565 | 572 | | |
566 | 573 | | |
567 | 574 | | |
| |||
590 | 597 | | |
591 | 598 | | |
592 | 599 | | |
| 600 | + | |
593 | 601 | | |
594 | 602 | | |
595 | 603 | | |
| |||
618 | 626 | | |
619 | 627 | | |
620 | 628 | | |
| 629 | + | |
621 | 630 | | |
622 | 631 | | |
623 | 632 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| 171 | + | |
| 172 | + | |
171 | 173 | | |
172 | 174 | | |
173 | 175 | | |
| |||
Large diffs are not rendered by default.
Lines changed: 15 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
175 | 175 | | |
176 | 176 | | |
177 | 177 | | |
178 | | - | |
179 | | - | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
180 | 188 | | |
181 | 189 | | |
182 | 190 | | |
| |||
270 | 278 | | |
271 | 279 | | |
272 | 280 | | |
| 281 | + | |
273 | 282 | | |
274 | 283 | | |
275 | 284 | | |
| |||
298 | 307 | | |
299 | 308 | | |
300 | 309 | | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
301 | 313 | | |
302 | 314 | | |
303 | 315 | | |
| |||
307 | 319 | | |
308 | 320 | | |
309 | 321 | | |
310 | | - | |
| 322 | + | |
311 | 323 | | |
312 | 324 | | |
313 | 325 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
812 | | - | |
| 812 | + | |
| 813 | + | |
813 | 814 | | |
814 | 815 | | |
815 | 816 | | |
| |||
Lines changed: 6 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | | - | |
| 41 | + | |
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
152 | 155 | | |
153 | | - | |
| 156 | + | |
154 | 157 | | |
155 | 158 | | |
156 | 159 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
299 | 299 | | |
300 | 300 | | |
301 | 301 | | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
302 | 308 | | |
303 | 309 | | |
304 | 310 | | |
| |||
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
736 | 736 | | |
737 | 737 | | |
738 | 738 | | |
739 | | - | |
740 | 739 | | |
741 | 740 | | |
742 | 741 | | |
743 | 742 | | |
744 | 743 | | |
745 | 744 | | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
746 | 756 | | |
747 | 757 | | |
748 | 758 | | |
| |||
843 | 853 | | |
844 | 854 | | |
845 | 855 | | |
846 | | - | |
847 | | - | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
848 | 859 | | |
849 | 860 | | |
850 | 861 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
| 171 | + | |
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
| |||
0 commit comments