Thanks for the response! So, the best solution I can come up with is catching the InvalidQueryException and check whether its message contains the phrase "conflicts with an existing column". Seems to work, but super-ugly.
I do assume that in general, if a request fails, it does not permanently change the data in Cassandra, right? It would be great if alter-add could have an if-not-exists clause. Would that be hard to implement? I could not find a standard CQL way of asking what columns exist. Did I miss it? Would it be hard to implement? I get that we're only eventually consistent anyway. Thanks! Best, Oliver On Mon, Feb 5, 2018 at 5:12 PM, Rahul Singh <rahul.xavier.si...@gmail.com> wrote: > Yeah, you can handle the exception — what i meant that it wouldnt cause > harm to the DB > > -- > Rahul Singh > rahul.si...@anant.us > > Anant Corporation > > On Feb 5, 2018, 5:07 PM -0500, Oliver Ruebenacker <cur...@gmail.com>, > wrote: > > Well, it does throw an InvalidQueryException if the column already exists. > > On Mon, Feb 5, 2018 at 4:44 PM, Rahul Singh <rahul.xavier.si...@gmail.com> > wrote: > >> Since CQL != SQL, there’s isnt a syntatical way. Just run the alter table >> command and it shouldn't be an issue if its there. >> >> -- >> Rahul Singh >> rahul.si...@anant.us >> >> Anant Corporation >> >> On Feb 5, 2018, 4:15 PM -0500, Oliver Ruebenacker <cur...@gmail.com>, >> wrote: >> >> >> Hello, >> >> What's the easiest way to add a column to a table but only if it does >> not exist? Thanks! >> >> Best, Oliver >> >> -- >> Oliver Ruebenacker >> Senior Software Engineer, Diabetes Portal >> <http://www.type2diabetesgenetics.org/>, Broad Institute >> <http://www.broadinstitute.org/> >> >> > > > -- > Oliver Ruebenacker > Senior Software Engineer, Diabetes Portal > <http://www.type2diabetesgenetics.org/>, Broad Institute > <http://www.broadinstitute.org/> > > -- Oliver Ruebenacker Senior Software Engineer, Diabetes Portal <http://www.type2diabetesgenetics.org/>, Broad Institute <http://www.broadinstitute.org/>