| 1403 | } |
| 1404 | |
| 1405 | void 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 | { |
no test coverage detected