Improve json2sstable error reporting on nonexistent columns

patch by Paulo Motta; reviewed by Ariel Weisberg for CASSANDRA-10401
This commit is contained in:
Paulo Motta 2015-10-05 15:04:09 -07:00 committed by Aleksey Yeschenko
parent 2548365a6e
commit ff9b6bb973
3 changed files with 15 additions and 0 deletions

View File

@ -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)

View File

@ -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();

View File

@ -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
{