@@ -206,7 +206,6 @@ table_parent_clause
206
206
return table;
207
207
}
208
208
209
- // TODO: replace default collation with a rule
210
209
relational_table
211
210
= relational_properties :(LPAR _ c :relational_properties _ RPAR { return c; })?
212
211
blockchain_clauses :blockchain_table_clauses ? _
@@ -2060,7 +2059,7 @@ alter_table_stmt_setting
2060
2059
2061
2060
alter_table_stmt_body
2062
2061
= alter_table_properties
2063
- / / / column_clauses
2062
+ / column_clauses
2064
2063
/ x: constraint_clauses { return {... x, target: ' constraint' }; }
2065
2064
// / alter_table_partitioning
2066
2065
// / alter_external_table
@@ -2070,6 +2069,88 @@ alter_table_stmt_body
2070
2069
/ x: immutable_table_clauses { return {... x, target: ' immutable_table' }; }
2071
2070
/ x: blockchain_table_clauses { return {... x, target: ' blockchain_table' }; }
2072
2071
2072
+ column_clauses
2073
+ = rename_column_clause
2074
+ / (_ column_clauses_action_option _)+
2075
+
2076
+ column_clauses_action_option
2077
+ = add_column_clause
2078
+
2079
+ add_column_clause
2080
+ = action: KW_ADD _
2081
+ column: (column_definition / virtua_column_definition)
2082
+
2083
+ virtua_column_definition
2084
+ = name: identifier_name _
2085
+ type: data_type _
2086
+ collate: (KW_COLLATE _ n: identifier_name { return n; })? _
2087
+ visibility: (KW_VISIBLE / KW_INVISIBLE )? _
2088
+ generated_always: (KW_GENERATED _ KW_ALWAYS { return ' generated always' ; })? _
2089
+ KW_AS _ LPAR _ column_expression: expr _ RPAR _
2090
+ virtual: KW_VIRTUAL ? _
2091
+ evaluation_edition: evaluation_edition_clause? _
2092
+ unusable_editions: unusable_editions_cluase? _
2093
+ constraints: ((_ x: inline_constraint _ { return x; })+ )? _ {
2094
+ return {
2095
+ name,
2096
+ type,
2097
+ collate,
2098
+ visibility,
2099
+ constraints,
2100
+ resource: ' virtual column' ,
2101
+ generated_always,
2102
+ };
2103
+ }
2104
+
2105
+ unusable_editions_cluase
2106
+ = unusable_before_edititon: unusable_editions_clause_before? _
2107
+ unusable_beginning_with_edititon: unusable_editions_clause_beginning? {
2108
+ return {
2109
+ unusable_before_edititon,
2110
+ unusable_beginning_with_edititon
2111
+ };
2112
+ }
2113
+
2114
+ unusable_editions_clause_before
2115
+ = KW_UNUSABLE _ KW_BEFORE _
2116
+ unusable_before_edititon: (
2117
+ KW_CURRENT _ KW_EDITION { return ' current' ; } /
2118
+ KW_EDITION _ edition: identifier_name { return { edition }; }
2119
+ ) {
2120
+ return unusable_before_edititon;
2121
+ }
2122
+
2123
+ unusable_editions_clause_beginning
2124
+ = KW_UNUSABLE _ KW_BEGINNING _ KW_WITH _
2125
+ unusable_beginning_with_edititon: (
2126
+ KW_CURRENT _ KW_EDITION { return ' current' ; } /
2127
+ KW_EDITION _ edition: identifier_name { return { edition }; } /
2128
+ KW_NULL _ KW_EDITION { return ' null' ; }
2129
+ ) {
2130
+ return unusable_beginning_with_edititon;
2131
+ }
2132
+
2133
+ evaluation_edition_clause
2134
+ = KW_EVALUATE _ KW_USING
2135
+ evaluate_using_edition: (
2136
+ KW_CURRENT _ KW_EDITION { return ' current' ; } /
2137
+ KW_EDITION _ edititon: identifier_name { return edition; } /
2138
+ KW_NULL _ KW_EDITION { return ' null' ; }
2139
+ ) {
2140
+ return { evaluate_using_edition };
2141
+ }
2142
+
2143
+ rename_column_clause
2144
+ = operation: KW_RENAME _ KW_COLUMN _
2145
+ old_name: identifier_name _ KW_TO _
2146
+ new_name: identifier_name {
2147
+ return {
2148
+ old_name,
2149
+ new_name,
2150
+ operation,
2151
+ };
2152
+ }
2153
+
2073
2154
alter_table_properties
2074
2155
= KW_READ _ KW_ONLY { return { read_only: ' read only' }; }
2075
2156
/ KW_READ _ KW_ONLY { return { read_write: ' read write' }; }
@@ -2666,6 +2747,13 @@ KW_UPGRADE = 'upgrade'i !ident_start { return '
2666
2747
KW_MINIMIZE = 'minimize'i !ident_start { return 'minimize'; }
2667
2748
KW_NOMINIMIZE = 'nominimize'i !ident_start { return 'nominimize'; }
2668
2749
KW_RECORDS_PER_BLOCK = 'records_per_block'i !ident_start { return 'records_per_block'; }
2750
+ KW_VIRTUAL = 'virtual'i !ident_start { return 'virtual'; }
2751
+ KW_EVALUATE = 'evaluate'i !ident_start { return 'evaluate'; }
2752
+ KW_CURRENT = 'current'i !ident_start { return 'current'; }
2753
+ KW_EDITION = 'edition'i !ident_start { return 'edition'; }
2754
+ KW_UNUSABLE = 'unusable'i !ident_start { return 'unusable'; }
2755
+ KW_BEFORE = 'before'i !ident_start { return 'before'; }
2756
+ KW_BEGINNING = 'beginning'i !ident_start { return 'beginning'; }
2669
2757
2670
2758
KW_VARYING = 'varying'i !ident_start { return 'varying'; }
2671
2759
KW_VARCHAR = 'varchar'i !ident_start { return 'varchar'; }
0 commit comments