You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pr@cassandra.apache.org by GitBox <gi...@apache.org> on 2020/07/22 17:39:30 UTC

[GitHub] [cassandra-diff] yifan-c commented on a change in pull request #10: CASSANDRA-15953: Support auto discover user tables for comparison

yifan-c commented on a change in pull request #10:
URL: https://github.com/apache/cassandra-diff/pull/10#discussion_r458968188



##########
File path: spark-job/src/main/java/org/apache/cassandra/diff/DiffJob.java
##########
@@ -87,15 +89,28 @@ public void run(JobConfiguration configuration, JavaSparkContext sc) {
         ClusterProvider targetProvider = ClusterProvider.getProvider(configuration.clusterConfig("target"), "target");
         String sourcePartitioner;
         String targetPartitioner;
+        List<KeyspaceTablePair> tablesToCompare = configuration.filteredKeyspaceTables();
         try (Cluster sourceCluster = sourceProvider.getCluster();
              Cluster targetCluster = targetProvider.getCluster()) {
             sourcePartitioner = sourceCluster.getMetadata().getPartitioner();
             targetPartitioner = targetCluster.getMetadata().getPartitioner();
+
+            if (!sourcePartitioner.equals(targetPartitioner)) {
+                throw new IllegalStateException(String.format("Cluster partitioners do not match; Source: %s, Target: %s,",
+                                                              sourcePartitioner, targetPartitioner));
+            }
+
+            if (configuration.shouldAutoDiscoverTables()) {
+                Schema sourceSchema = new Schema(sourceCluster.getMetadata(), configuration);
+                Schema targetSchema = new Schema(targetCluster.getMetadata(), configuration);
+                Schema commonSchema = sourceSchema.intersect(targetSchema);
+                if (commonSchema.size() != sourceSchema.size()) {
+                    logger.warn("Found tables that only exist in either source or target cluster. Ignoring those tables for comparision. ");

Review comment:
       The diff job expects the schema from the compared clusters to be the same. If we found schema mismatch, the comparison might not be valid. Therefore, I choose to log it at `warn` level to highlight the unexpected. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org