@@ -710,19 +710,21 @@ namespace ExportPartitionUtils
710710 const ColumnWithTypeAndName & source_column,
711711 const ColumnWithTypeAndName & destination_column,
712712 size_t position,
713- const StorageID & destination_storage_id)
713+ const StorageID & destination_storage_id,
714+ bool match_by_name)
714715 {
715716 if (source_column.name != destination_column.name )
716717 throw Exception (
717718 ErrorCodes::BAD_ARGUMENTS ,
718719 " Cannot export to {}: partition key column '{}' is at position {} in the source "
719720 " table, but the destination's column at that position is named '{}'. EXPORT "
720- " PART/PARTITION matches columns by position, so partition key columns must be "
721- " declared at the same position in both tables." ,
721+ " PART/PARTITION {} so partition key columns must be declared {} in both tables." ,
722722 destination_storage_id.getFullTableName (),
723723 source_column.name ,
724724 position,
725- destination_column.name );
725+ destination_column.name ,
726+ match_by_name ? " matches columns by name" : " matches columns by position" ,
727+ match_by_name ? " with the same name" : " at the same position" );
726728
727729 if (!haveSameTupleElementLayout (source_column.type , destination_column.type ))
728730 throw Exception (
@@ -885,15 +887,17 @@ namespace ExportPartitionUtils
885887 continue ;
886888
887889 verifyPartitionKeyColumn (
888- source_columns[source_it->second ], destination_column, source_it->second , destination_storage_id);
890+ source_columns[source_it->second ], destination_column, source_it->second , destination_storage_id,
891+ /* match_by_name=*/ true );
889892 }
890893 }
891894 else
892895 {
893896 const size_t num_columns = std::min (source_columns.size (), destination_columns.size ());
894897 for (size_t i = 0 ; i < num_columns; ++i)
895898 if (partition_key_owner_columns.contains (source_columns[i].name ))
896- verifyPartitionKeyColumn (source_columns[i], destination_columns[i], i, destination_storage_id);
899+ verifyPartitionKeyColumn (source_columns[i], destination_columns[i], i, destination_storage_id,
900+ /* match_by_name=*/ false );
897901 }
898902
899903 // / Lossy casts may silently change values, so reject them unless the user opts in.
0 commit comments