@@ -2268,6 +2268,7 @@ void StorageMergeTree::replacePartitionFrom(const StoragePtr & source_table, con
22682268
22692269 static const String TMP_PREFIX = " tmp_replace_from_" ;
22702270
2271+ bool are_policies_partition_compatible = getStoragePolicy ()->isCompatibleForPartitionOps (source_table->getStoragePolicy ());
22712272 for (const DataPartPtr & src_part : src_parts)
22722273 {
22732274 if (is_all)
@@ -2294,7 +2295,7 @@ void StorageMergeTree::replacePartitionFrom(const StoragePtr & source_table, con
22942295 clone_params,
22952296 local_context->getReadSettings (),
22962297 local_context->getWriteSettings (),
2297- true /* must_on_same_disk*/ );
2298+ !are_policies_partition_compatible /* must_on_same_disk*/ );
22982299 dst_parts.emplace_back (std::move (dst_part));
22992300 dst_parts_locks.emplace_back (std::move (part_lock));
23002301 }
@@ -2371,13 +2372,18 @@ void StorageMergeTree::movePartitionToTable(const StoragePtr & dest_table, const
23712372 throw Exception (ErrorCodes::NOT_IMPLEMENTED,
23722373 " Table {} supports movePartitionToTable only for MergeTree family of table engines. Got {}" ,
23732374 getStorageID ().getNameForLogs (), dest_table->getName ());
2374- if (dest_table_storage->getStoragePolicy () != this ->getStoragePolicy ())
2375- throw Exception (ErrorCodes::UNKNOWN_POLICY,
2376- " Destination table {} should have the same storage policy of source table {}. {}: {}, {}: {}" ,
2377- dest_table_storage->getStorageID ().getNameForLogs (),
2378- getStorageID ().getNameForLogs (), getStorageID ().getNameForLogs (),
2379- this ->getStoragePolicy ()->getName (), dest_table_storage->getStorageID ().getNameForLogs (),
2380- dest_table_storage->getStoragePolicy ()->getName ());
2375+ bool are_policies_partition_compatible = getStoragePolicy ()->isCompatibleForPartitionOps (dest_table_storage->getStoragePolicy ());
2376+
2377+ if (!are_policies_partition_compatible)
2378+ throw Exception (
2379+ ErrorCodes::UNKNOWN_POLICY,
2380+ " Destination table {} should have the same or partition compatible storage policy of source table {}. {}: {}, {}: {}" ,
2381+ dest_table_storage->getStorageID ().getNameForLogs (),
2382+ getStorageID ().getNameForLogs (),
2383+ getStorageID ().getNameForLogs (),
2384+ this ->getStoragePolicy ()->getName (),
2385+ dest_table_storage->getStorageID ().getNameForLogs (),
2386+ dest_table_storage->getStoragePolicy ()->getName ());
23812387
23822388 // Use the same back-pressure (delay/throw) logic as for INSERTs to be consistent and avoid possibility of exceeding part limits using MOVE PARTITION queries
23832389 dest_table_storage->delayInsertOrThrowIfNeeded (nullptr , local_context, true );
@@ -2437,7 +2443,7 @@ void StorageMergeTree::movePartitionToTable(const StoragePtr & dest_table, const
24372443 clone_params,
24382444 local_context->getReadSettings (),
24392445 local_context->getWriteSettings (),
2440- true /* must_on_same_disk*/
2446+ !are_policies_partition_compatible /* must_on_same_disk*/
24412447 );
24422448
24432449 dst_parts.emplace_back (std::move (dst_part));
0 commit comments