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

Method check

src/MergeTreeCommon/MergeTreeMetaBase.cpp:1405–1547  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1403}
1404
1405void MergeTreeMetaBase::MergingParams::check(const StorageInMemoryMetadata & metadata, bool attach) const
1406{
1407 const bool has_unique_key = metadata.hasUniqueKey();
1408 const auto columns = metadata.getColumns().getAllPhysical();
1409
1410 if (!sign_column.empty() && mode != MergingParams::Collapsing && mode != MergingParams::VersionedCollapsing)
1411 throw Exception("Sign column for MergeTree cannot be specified in modes except Collapsing or VersionedCollapsing.",
1412 ErrorCodes::LOGICAL_ERROR);
1413
1414 if (!has_unique_key && !version_column.empty() && mode != MergingParams::Replacing && mode != MergingParams::VersionedCollapsing)
1415 throw Exception("Version column for MergeTree cannot be specified in modes except Replacing or VersionedCollapsing.",
1416 ErrorCodes::LOGICAL_ERROR);
1417
1418 if (!columns_to_sum.empty() && mode != MergingParams::Summing)
1419 throw Exception("List of columns to sum for MergeTree cannot be specified in all modes except Summing.",
1420 ErrorCodes::LOGICAL_ERROR);
1421
1422 /// Check that if the sign column is needed, it exists and is of type Int8.
1423 auto check_sign_column = [this, & columns](bool is_optional, const std::string & storage)
1424 {
1425 if (sign_column.empty())
1426 {
1427 if (is_optional)
1428 return;
1429
1430 throw Exception("Logical error: Sign column for storage " + storage + " is empty", ErrorCodes::LOGICAL_ERROR);
1431 }
1432
1433 bool miss_column = true;
1434 for (const auto & column : columns)
1435 {
1436 if (column.name == sign_column)
1437 {
1438 if (!typeid_cast<const DataTypeInt8 *>(column.type.get()))
1439 throw Exception("Sign column (" + sign_column + ") for storage " + storage + " must have type Int8."
1440 " Provided column of type " + column.type->getName() + ".", ErrorCodes::BAD_TYPE_OF_FIELD);
1441 miss_column = false;
1442 break;
1443 }
1444 }
1445 if (miss_column)
1446 throw Exception("Sign column " + sign_column + " does not exist in table declaration.", ErrorCodes::NO_SUCH_COLUMN_IN_TABLE);
1447 };
1448
1449 /// that if the version_column column is needed, it exists and is of unsigned integer type.
1450 auto check_version_column = [this, & columns](bool is_optional, const std::string & storage)
1451 {
1452 if (version_column.empty())
1453 {
1454 if (is_optional)
1455 return;
1456
1457 throw Exception("Logical error: Version column for storage " + storage + " is empty", ErrorCodes::LOGICAL_ERROR);
1458 }
1459
1460 bool miss_column = true;
1461 for (const auto & column : columns)
1462 {

Callers 1

MergeTreeMetaBaseMethod · 0.45

Calls 15

extractTableNameFunction · 0.85
hasUniqueKeyMethod · 0.80
getAllPhysicalMethod · 0.80
isPartitionKeyDefinedMethod · 0.80
getPartitionKeyMethod · 0.80
columnsMethod · 0.80
getDataTypesMethod · 0.80
ExceptionClass · 0.50
joinFunction · 0.50
getColumnsMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected