I want to run a drop-column CQL statement on a table that may or may not have that column exist. Ideally I would like to do a if-exists then drop column, but I do not believe CQL supports that.
My work around is to catch an invalid query exception, but that is not working and I cannot figure out why. In the following code, the generic Except will hit giving the message "com.datastax.driver.core.exceptions.InvalidQueryException: Column my_col was not found in table my_table". I have no idea why my InvalidQueryException is not hitting.
(ns my-namespace
(:require [qbits
[alia :as alia]
[hayt :as hayt]]))
(defn prepared-statement
[session]
(try
(alia/execute session
(hayt/alter-table :my_table
(hayt/drop-column :my_col)))
(catch com.datastax.driver.core.exceptions.InvalidQueryException ie
(prn "your column doesn't exist"))
(catch Exception e
(prn (ex-data e)))))