cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Improve json2sstable error reporting on nonexistent columns
Date Fri, 06 Nov 2015 19:19:39 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 2548365a6 -> ff9b6bb97


Improve json2sstable error reporting on nonexistent columns

patch by Paulo Motta; reviewed by Ariel Weisberg for CASSANDRA-10401


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/ff9b6bb9
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/ff9b6bb9
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/ff9b6bb9

Branch: refs/heads/cassandra-2.1
Commit: ff9b6bb973db7f6ebe650d909d24dcf5aebcfae5
Parents: 2548365
Author: Paulo Motta <pauloricardomg@gmail.com>
Authored: Mon Oct 5 15:04:09 2015 -0700
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Fri Nov 6 19:19:13 2015 +0000

----------------------------------------------------------------------
 CHANGES.txt                                                 | 1 +
 src/java/org/apache/cassandra/tools/SSTableImport.java      | 5 +++++
 test/unit/org/apache/cassandra/tools/SSTableImportTest.java | 9 +++++++++
 3 files changed, 15 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/ff9b6bb9/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 7771969..8ff726e 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.12
+ * Improve json2sstable error reporting on nonexistent columns (CASSANDRA-10401)
  * (cqlsh) fix COPY using wrong variable name for time_format (CASSANDRA-10633)
  * Do not run SizeEstimatesRecorder if a node is not a member of the ring (CASSANDRA-9912)
  * Improve handling of dead nodes in gossip (CASSANDRA-10298)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ff9b6bb9/src/java/org/apache/cassandra/tools/SSTableImport.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/SSTableImport.java b/src/java/org/apache/cassandra/tools/SSTableImport.java
index 87d52be..e0f3ef3 100644
--- a/src/java/org/apache/cassandra/tools/SSTableImport.java
+++ b/src/java/org/apache/cassandra/tools/SSTableImport.java
@@ -281,6 +281,11 @@ public class SSTableImport
      */
     public int importJson(String jsonFile, String keyspace, String cf, String ssTablePath)
throws IOException
     {
+        if (Schema.instance.getCFMetaData(keyspace, cf) == null)
+            throw new IllegalArgumentException(String.format("Unknown keyspace/table %s.%s",
+                                                             keyspace,
+                                                             cf));
+
         ColumnFamily columnFamily = ArrayBackedSortedColumns.factory.create(keyspace, cf);
         IPartitioner partitioner = DatabaseDescriptor.getPartitioner();
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/ff9b6bb9/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/tools/SSTableImportTest.java b/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
index a5f05f8..77036e8 100644
--- a/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
+++ b/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
@@ -51,6 +51,15 @@ import org.apache.cassandra.io.sstable.SSTableReader;
 
 public class SSTableImportTest extends SchemaLoader
 {
+    @Test(expected = IllegalArgumentException.class)
+    public void testImportUnknownCf() throws IOException, URISyntaxException
+    {
+        // Import JSON to temp SSTable file
+        String jsonUrl = resourcePath("SimpleCF.json");
+        File tempSS = tempSSTableFile("Keyspace1", "Standard1");
+        new SSTableImport(true).importJson(jsonUrl, "UnknownKeyspace", "UnknownCF", tempSS.getPath());
+    }
+
     @Test
     public void testImportSimpleCf() throws IOException, URISyntaxException
     {


Mime
View raw message