MCPcopy Create free account
hub / github.com/ByConity/ByConity / checkKeyExpression

Function checkKeyExpression

src/MergeTreeCommon/MergeTreeMetaBase.cpp:205–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203}
204
205static void checkKeyExpression(const ExpressionActions & expr, const Block & sample_block, const String & key_name, bool allow_nullable_key)
206{
207 for (const auto & action : expr.getActions())
208 {
209 if (action.node->type == ActionsDAG::ActionType::ARRAY_JOIN)
210 throw Exception(key_name + " key cannot contain array joins", ErrorCodes::ILLEGAL_COLUMN);
211
212 if (action.node->type == ActionsDAG::ActionType::FUNCTION)
213 {
214 IFunctionBase & func = *action.node->function_base;
215 if (!func.isDeterministic())
216 throw Exception(key_name + " key cannot contain non-deterministic functions, "
217 "but contains function " + func.getName(),
218 ErrorCodes::BAD_ARGUMENTS);
219 }
220 }
221
222 for (const ColumnWithTypeAndName & element : sample_block)
223 {
224 const ColumnPtr & column = element.column;
225 if (column && (isColumnConst(*column) || column->isDummy()))
226 throw Exception{key_name + " key cannot contain constants", ErrorCodes::ILLEGAL_COLUMN};
227
228 if (!allow_nullable_key && element.type->isNullable())
229 throw Exception{key_name + " key cannot contain nullable columns", ErrorCodes::ILLEGAL_COLUMN};
230 }
231}
232
233void MergeTreeMetaBase::checkProperties(
234 const StorageInMemoryMetadata & new_metadata, const StorageInMemoryMetadata & old_metadata, bool attach) const

Callers 2

checkPropertiesMethod · 0.85

Calls 7

isColumnConstFunction · 0.85
ExceptionClass · 0.50
getActionsMethod · 0.45
isDeterministicMethod · 0.45
getNameMethod · 0.45
isDummyMethod · 0.45
isNullableMethod · 0.45

Tested by

no test coverage detected