cassandra-bulkload-example icon indicating copy to clipboard operation
cassandra-bulkload-example copied to clipboard

Unknown keyspace Exception

Open Sam-SFO opened this issue 8 years ago • 2 comments

Using Cassandra 2.2.8 on Windows7 I could run your example perfectly fine. (I ran it is stand alone java program not the Gradle project). But when I run my test example I get "Unknown keyspace" Exception. Hard to understand this as this would be simply be writing to the local file. The actual existence of keyspace/table should be resolved SSTableLoader (I suppose). I can see it creating the keyspace and table directories locally- but are empty.

Note: My table has single column PK I have created the SCHEMA and INSERT_STMT in exact same format builder.inDirectory(outputDir) // set target schema .forTable(SCHEMA) java.lang.IllegalArgumentException: Unknown keyspace test at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.getStatement(CQLSSTableWriter.java:521) at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.forTable(CQLSSTableWriter.java:357) at bulkload.TestBulkLoad.main(TestBulkLoad.java:158)

CQLSSTableWriter writer = builder.build(); Exception in thread "main" java.lang.IllegalStateException: Missing schema, you should provide the schema for the SSTable to create with forTable() at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.build(CQLSSTableWriter.java:530) at bulkload.TestBulkLoad.main(TestBulkLoad.java:163)

Thanks

Sam-SFO avatar Nov 22 '16 23:11 Sam-SFO

This problem magically went away on my local machine - I didn't do any thing specific. But the issue comes up on DataStax ver 4.8.11, ( likely on Cassandra 2.1) on Ubuntu14.04, I get error:

java.lang.illegalargumentexception: Unknown key space 'mykeyspace'
at org.apache.cassandra.io.sstable.CQLSSTableWriter$Builder.getStatement

It is able to create /data/keysapce/tablename directories. Based on documentation this exception occurs: if directory doesn't exist or is not writable. That does not seem to be the case. Also again the same code works fine on local Cassandra.

Sam-SFO avatar Nov 28 '16 20:11 Sam-SFO

When this happened to me, I had a typo in my schema. Try creating it in a cqlsh and make sure it runs correctly.

benedictb avatar Sep 23 '19 17:09 benedictb