5

I'm trying to understand the syntax of DROP TABLE IF EXISTS in Cassandra.

DROP TABLE IF EXISTS nonexistanttable; does not seem to work:

$ ./cqlsh
Connected to Test Cluster at localhost:9160.
[cqlsh 4.1.1 | Cassandra 2.0.5 | CQL spec 3.1.1 | Thrift protocol 19.39.0]
Use HELP for help.
cqlsh> USE Foo;
cqlsh:foo> DROP TABLE IF EXISTS bar;
Bad Request: unconfigured columnfamily bar

What am I doing wrong?

knorv
  • 49,059
  • 74
  • 210
  • 294

1 Answers1

4

The idea of DROP TABLE IF EXISTS is that you avoid getting the InvalidRequestException "Bad Request: unconfigured columnfamily" by droping the table only if it is actually created so your query statement is valid.

You are getting the exception because this was a bug in 2.0.5. It has been fixed for C* 2.0.6 but if you want to see DROP TABLE IF EXISTS immediately, try downloading and building cassandra from source:

git clone -b cassandra-2.0 git://git.apache.org/cassandra.git cassandra
cd cassandra
ant build
knorv
  • 49,059
  • 74
  • 210
  • 294
Lyuben Todorov
  • 13,987
  • 5
  • 50
  • 69