MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / parse

Method parse

src/Storages/MutationCommands.cpp:129–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127}
128
129std::optional<MutationCommand> MutationCommand::parse(
130 const ASTAlterCommand & command,
131 bool parse_alter_commands,
132 bool with_pure_metadata_commands,
133 UInt64 max_parser_depth,
134 UInt64 max_parser_backtracks)
135{
136 MutationCommand res;
137 res.ast_text = command.formatWithSecretsOneLine();
138 res.max_parser_depth = max_parser_depth;
139 res.max_parser_backtracks = max_parser_backtracks;
140 if (with_pure_metadata_commands)
141 {
142 res.type = ALTER_WITHOUT_MUTATION;
143 return res;
144 }
145
146 if (command.type == ASTAlterCommand::DELETE)
147 {
148 res.type = DELETE;
149 return res;
150 }
151 if (command.type == ASTAlterCommand::UPDATE)
152 {
153 res.type = UPDATE;
154 NameSet seen_columns;
155 for (const ASTPtr & assignment_ast : command.update_assignments->children)
156 {
157 const auto & assignment = assignment_ast->as<ASTAssignment &>();
158 if (!seen_columns.insert(assignment.column_name).second)
159 throw Exception(
160 ErrorCodes::MULTIPLE_ASSIGNMENTS_TO_COLUMN,
161 "Multiple assignments in the single statement to column {}",
162 backQuote(assignment.column_name));
163 }
164 return res;
165 }
166 if (command.type == ASTAlterCommand::APPLY_DELETED_MASK)
167 {
168 res.type = APPLY_DELETED_MASK;
169 return res;
170 }
171 else if (command.type == ASTAlterCommand::APPLY_PATCHES)
172 {
173 res.type = APPLY_PATCHES;
174 return res;
175 }
176 if (command.type == ASTAlterCommand::MATERIALIZE_INDEX)
177 {
178 res.type = MATERIALIZE_INDEX;
179 res.index_name = command.index->as<ASTIdentifier &>().name();
180 return res;
181 }
182 if (command.type == ASTAlterCommand::MATERIALIZE_STATISTICS)
183 {
184 res.type = MATERIALIZE_STATISTICS;
185 if (command.statistics_decl)
186 {

Callers

nothing calls this directly

Calls 15

backQuoteFunction · 0.85
getColumnNamesMethod · 0.80
getDefaultExpressionMethod · 0.80
getCommentMethod · 0.80
getTTLMethod · 0.80
ExceptionClass · 0.50
getIdentifierNameFunction · 0.50
insertMethod · 0.45
nameMethod · 0.45
emptyMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected