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

Function checkKeyExpression

src/Storages/MergeTree/MergeTreeData.cpp:906–933  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

904}
905
906static void checkKeyExpression(const ExpressionActions & expr, const Block & sample_block, const String & key_name, bool allow_nullable_key)
907{
908 if (expr.hasArrayJoin())
909 throw Exception(ErrorCodes::ILLEGAL_COLUMN, "{} key cannot contain array joins", key_name);
910
911 try
912 {
913 expr.assertDeterministic();
914 }
915 catch (Exception & e)
916 {
917 e.addMessage(fmt::format("for {} key", key_name));
918 throw;
919 }
920
921 for (const ColumnWithTypeAndName & element : sample_block)
922 {
923 const ColumnPtr & column = element.column;
924 if (column && (isColumnConst(*column) || column->isDummy()))
925 throw Exception(ErrorCodes::ILLEGAL_COLUMN, "{} key cannot contain constants", key_name);
926
927 if (!allow_nullable_key && hasNullable(element.type))
928 throw Exception(
929 ErrorCodes::ILLEGAL_COLUMN,
930 "{} key contains nullable columns, "
931 "but merge tree setting `allow_nullable_key` is disabled", key_name);
932 }
933}
934
935void MergeTreeData::checkProperties(
936 const StorageInMemoryMetadata & new_metadata,

Callers 2

checkPropertiesMethod · 0.85

Calls 8

isColumnConstFunction · 0.85
hasNullableFunction · 0.85
isDummyMethod · 0.80
ExceptionClass · 0.50
formatFunction · 0.50
hasArrayJoinMethod · 0.45
assertDeterministicMethod · 0.45
addMessageMethod · 0.45

Tested by

no test coverage detected