Re: Add column if it does not exist?

2018-02-08 Thread Eric Stevens
To hop on what Jon said, if your concern is automatic application of schema
migrations, you want to be very careful with this.  I'd consider it an
unsolved problem in Cassandra for some methods of schema application.

The failed ALTER is not what you have to worry about, it's two successful
ALTERs that will be the problem.  Cassandra is eventually consistent,
including for schema changes, and they are also not isolated.  If two
identical ALTER commands both succeed, you will end up in a schema
disagreement.  This is not fun to recover from.

You MUST coordinate your schema migrations FROM A SINGLE HOST ONLY.

On Wed, Feb 7, 2018 at 12:23 PM Rahul Singh 
wrote:

> Yah. I saw one such migration via Spark Job running concurrently and
> created 4 Cfids and migrated data. It was a nightmare to cleanup the
> duplicated sstables.
>
> Alter schema and migrate should always be different applications separate
> from the actual system.
>
> --
> Rahul Singh
> rahul.si...@anant.us
>
> Anant Corporation
>
> On Feb 7, 2018, 12:39 PM -0600, Jon Haddad , wrote:
>
> All of the drivers also have keyspace / table metadata. For instance:
> https://datastax.github.io/python-driver/api/cassandra/metadata.html
>
> I’d be *really* careful how you use this.  A lot of teams want to just
> deploy their code to a couple hundred servers and let them race to apply
> the ALTER.  That will not be a fun time.  I advise against using LWT to
> manage this as well. If you’re looking to apply schema changes like this,
> I’d let a single app server manage it and avoid the headache of concurrency.
>
> Jon
>
> On Feb 6, 2018, at 8:13 PM, Irtiza Ali  wrote:
>
> Hello,
>
> this link might also be helpful to you for querying table schema.
>
> Link:
> https://docs.datastax.com/en/cql/3.3/cql/cql_using/useQuerySystemTable.html
>
> Best, Iriiza
>
>
>
> On Tue, Feb 6, 2018 at 9:55 PM, Oliver Ruebenacker 
> wrote:
>
>>
>>  Hello,
>>
>>   Is there a describe query in CQL? I don't see one on
>> http://cassandra.apache.org/doc/latest/cql/index.html.
>>
>>   I also can't find such a query in the DataStax Java driver API.
>>
>>   Thanks!
>>
>>  Best, Oliver
>>
>> On Tue, Feb 6, 2018 at 11:48 AM, Irtiza Ali  wrote:
>>
>>> Hello.
>>>
>>> Another thing that you can try is the use the describe table query to
>>> get the table schema and parse it. Once done you can check whether column
>>> exists or not.
>>>
>>>
>>> With Regards
>>> Irtiza Ali
>>>
>>> On 6 Feb 2018 21:35, "Oliver Ruebenacker"  wrote:
>>>
   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 ,
> 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 ,
>> 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
>> , Broad Institute
>> 
>>
>>
>
>
> --
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal
> , Broad Institute
> 
>
>


 --
 Oliver Ruebenacker
 Senior Software Engineer, Diabetes Portal
 , 

Re: Add column if it does not exist?

2018-02-07 Thread Rahul Singh
Yah. I saw one such migration via Spark Job running concurrently and created 4 
Cfids and migrated data. It was a nightmare to cleanup the duplicated sstables.

Alter schema and migrate should always be different applications separate from 
the actual system.

--
Rahul Singh
rahul.si...@anant.us

Anant Corporation

On Feb 7, 2018, 12:39 PM -0600, Jon Haddad , wrote:
> All of the drivers also have keyspace / table metadata. For instance: 
> https://datastax.github.io/python-driver/api/cassandra/metadata.html
>
> I’d be *really* careful how you use this.  A lot of teams want to just deploy 
> their code to a couple hundred servers and let them race to apply the ALTER.  
> That will not be a fun time.  I advise against using LWT to manage this as 
> well. If you’re looking to apply schema changes like this, I’d let a single 
> app server manage it and avoid the headache of concurrency.
>
> Jon
>
> > On Feb 6, 2018, at 8:13 PM, Irtiza Ali  wrote:
> >
> > Hello,
> >
> > this link might also be helpful to you for querying table schema.
> >
> > Link: 
> > https://docs.datastax.com/en/cql/3.3/cql/cql_using/useQuerySystemTable.html
> >
> > Best, Iriiza
> >
> >
> >
> > > On Tue, Feb 6, 2018 at 9:55 PM, Oliver Ruebenacker  
> > > wrote:
> > > >
> > > >  Hello,
> > > >
> > > >   Is there a describe query in CQL? I don't see one on 
> > > > http://cassandra.apache.org/doc/latest/cql/index.html.
> > > >
> > > >   I also can't find such a query in the DataStax Java driver API.
> > > >
> > > >   Thanks!
> > > >
> > > >  Best, Oliver
> > > >
> > > > > On Tue, Feb 6, 2018 at 11:48 AM, Irtiza Ali  wrote:
> > > > > > Hello.
> > > > > >
> > > > > > Another thing that you can try is the use the describe table query 
> > > > > > to get the table schema and parse it. Once done you can check 
> > > > > > whether column exists or not.
> > > > > >
> > > > > >
> > > > > > With Regards
> > > > > > Irtiza Ali
> > > > > >
> > > > > > > On 6 Feb 2018 21:35, "Oliver Ruebenacker"  
> > > > > > > wrote:
> > > > > > > >   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 
> > > > > > > > >  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 
> > > > > > > > > > , wrote:
> > > > > > > > > > > Well, it does throw an InvalidQueryException if the 
> > > > > > > > > > > column already exists.
> > > > > > > > > > >
> > > > > > > > > > > > On Mon, Feb 5, 2018 at 4:44 PM, Rahul Singh 
> > > > > > > > > > > >  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 
> > > > > > > > > > > > > , 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, Broad 
> > 

Re: Add column if it does not exist?

2018-02-07 Thread Jon Haddad
All of the drivers also have keyspace / table metadata. For instance: 
https://datastax.github.io/python-driver/api/cassandra/metadata.html 


I’d be *really* careful how you use this.  A lot of teams want to just deploy 
their code to a couple hundred servers and let them race to apply the ALTER.  
That will not be a fun time.  I advise against using LWT to manage this as 
well. If you’re looking to apply schema changes like this, I’d let a single app 
server manage it and avoid the headache of concurrency.

Jon

> On Feb 6, 2018, at 8:13 PM, Irtiza Ali  wrote:
> 
> Hello,
> 
> this link might also be helpful to you for querying table schema.
> 
> Link: 
> https://docs.datastax.com/en/cql/3.3/cql/cql_using/useQuerySystemTable.html 
> 
> 
> Best, Iriiza
> 
> 
> 
> On Tue, Feb 6, 2018 at 9:55 PM, Oliver Ruebenacker  > wrote:
> 
>  Hello,
> 
>   Is there a describe query in CQL? I don't see one on 
> http://cassandra.apache.org/doc/latest/cql/index.html 
> .
> 
>   I also can't find such a query in the DataStax Java driver API.
> 
>   Thanks!
> 
>  Best, Oliver
> 
> On Tue, Feb 6, 2018 at 11:48 AM, Irtiza Ali  > wrote:
> Hello.
> 
> Another thing that you can try is the use the describe table query to get the 
> table schema and parse it. Once done you can check whether column exists or 
> not.
> 
> 
> With Regards 
> Irtiza Ali
> 
> On 6 Feb 2018 21:35, "Oliver Ruebenacker"  > wrote:
>   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  > 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  >, wrote:
>> Well, it does throw an InvalidQueryException if the column already exists.
>> 
>> On Mon, Feb 5, 2018 at 4:44 PM, Rahul Singh > > 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 > >, 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 
>>> , Broad Institute 
>>> 
>>> 
>> 
>> 
>> 
>> --
>> Oliver Ruebenacker
>> Senior Software Engineer, Diabetes Portal 
>> , Broad Institute 
>> 
>> 
> 
> 
> 
> -- 
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal 
> , Broad Institute 
> 
> 
> 
> 
> 
> -- 
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal 
> , Broad Institute 
> 
> 
> 



Re: Add column if it does not exist?

2018-02-06 Thread Irtiza Ali
Hello,

this link might also be helpful to you for querying table schema.

Link:
https://docs.datastax.com/en/cql/3.3/cql/cql_using/useQuerySystemTable.html

Best, Iriiza



On Tue, Feb 6, 2018 at 9:55 PM, Oliver Ruebenacker  wrote:

>
>  Hello,
>
>   Is there a describe query in CQL? I don't see one on
> http://cassandra.apache.org/doc/latest/cql/index.html.
>
>   I also can't find such a query in the DataStax Java driver API.
>
>   Thanks!
>
>  Best, Oliver
>
> On Tue, Feb 6, 2018 at 11:48 AM, Irtiza Ali  wrote:
>
>> Hello.
>>
>> Another thing that you can try is the use the describe table query to get
>> the table schema and parse it. Once done you can check whether column
>> exists or not.
>>
>>
>> With Regards
>> Irtiza Ali
>>
>> On 6 Feb 2018 21:35, "Oliver Ruebenacker"  wrote:
>>
>>>   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 ,
 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 ,
> 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
> , Broad Institute
> 
>
>


 --
 Oliver Ruebenacker
 Senior Software Engineer, Diabetes Portal
 , Broad Institute
 


>>>
>>>
>>> --
>>> Oliver Ruebenacker
>>> Senior Software Engineer, Diabetes Portal
>>> , Broad Institute
>>> 
>>>
>>>
>
>
> --
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal
> , Broad Institute
> 
>
>


Re: Add column if it does not exist?

2018-02-06 Thread Irtiza Ali
Yes describe query is available cqlsh. Try the example given below:

Example:
cqlsh> describe keyspaceName.tableName;

It will return the schema of the table.



On 6 Feb 2018 21:55, "Oliver Ruebenacker"  wrote:

>
>  Hello,
>
>   Is there a describe query in CQL? I don't see one on
> http://cassandra.apache.org/doc/latest/cql/index.html.
>
>   I also can't find such a query in the DataStax Java driver API.
>
>   Thanks!
>
>  Best, Oliver
>
> On Tue, Feb 6, 2018 at 11:48 AM, Irtiza Ali  wrote:
>
>> Hello.
>>
>> Another thing that you can try is the use the describe table query to get
>> the table schema and parse it. Once done you can check whether column
>> exists or not.
>>
>>
>> With Regards
>> Irtiza Ali
>>
>> On 6 Feb 2018 21:35, "Oliver Ruebenacker"  wrote:
>>
>>>   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 ,
 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 ,
> 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
> , Broad Institute
> 
>
>


 --
 Oliver Ruebenacker
 Senior Software Engineer, Diabetes Portal
 , Broad Institute
 


>>>
>>>
>>> --
>>> Oliver Ruebenacker
>>> Senior Software Engineer, Diabetes Portal
>>> , Broad Institute
>>> 
>>>
>>>
>
>
> --
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal
> , Broad Institute
> 
>
>


Re: Add column if it does not exist?

2018-02-06 Thread Oliver Ruebenacker
 Hello,

  Is there a describe query in CQL? I don't see one on
http://cassandra.apache.org/doc/latest/cql/index.html.

  I also can't find such a query in the DataStax Java driver API.

  Thanks!

 Best, Oliver

On Tue, Feb 6, 2018 at 11:48 AM, Irtiza Ali  wrote:

> Hello.
>
> Another thing that you can try is the use the describe table query to get
> the table schema and parse it. Once done you can check whether column
> exists or not.
>
>
> With Regards
> Irtiza Ali
>
> On 6 Feb 2018 21:35, "Oliver Ruebenacker"  wrote:
>
>>   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 > > 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 ,
>>> 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 ,
 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
 , Broad Institute
 


>>>
>>>
>>> --
>>> Oliver Ruebenacker
>>> Senior Software Engineer, Diabetes Portal
>>> , Broad Institute
>>> 
>>>
>>>
>>
>>
>> --
>> Oliver Ruebenacker
>> Senior Software Engineer, Diabetes Portal
>> , Broad Institute
>> 
>>
>>


-- 
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal
, Broad Institute



Re: Add column if it does not exist?

2018-02-06 Thread Irtiza Ali
Hello.

Another thing that you can try is the use the describe table query to get
the table schema and parse it. Once done you can check whether column
exists or not.


With Regards
Irtiza Ali

On 6 Feb 2018 21:35, "Oliver Ruebenacker"  wrote:

>   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 
> 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 ,
>> wrote:
>>
>> Well, it does throw an InvalidQueryException if the column already exists.
>>
>> On Mon, Feb 5, 2018 at 4:44 PM, Rahul Singh > > 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 ,
>>> 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
>>> , Broad Institute
>>> 
>>>
>>>
>>
>>
>> --
>> Oliver Ruebenacker
>> Senior Software Engineer, Diabetes Portal
>> , Broad Institute
>> 
>>
>>
>
>
> --
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal
> , Broad Institute
> 
>
>


Re: Add column if it does not exist?

2018-02-06 Thread Oliver Ruebenacker
  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 
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 ,
> wrote:
>
> Well, it does throw an InvalidQueryException if the column already exists.
>
> On Mon, Feb 5, 2018 at 4:44 PM, Rahul Singh 
> 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 ,
>> 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
>> , Broad Institute
>> 
>>
>>
>
>
> --
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal
> , Broad Institute
> 
>
>


-- 
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal
, Broad Institute



Re: Add column if it does not exist?

2018-02-05 Thread Rahul Singh
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 , wrote:
> Well, it does throw an InvalidQueryException if the column already exists.
>
> > On Mon, Feb 5, 2018 at 4:44 PM, Rahul Singh  
> > 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 , 
> > > 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, Broad Institute
> > > >
>
>
>
> --
> Oliver Ruebenacker
> Senior Software Engineer, Diabetes Portal, Broad Institute
>


Re: Add column if it does not exist?

2018-02-05 Thread Oliver Ruebenacker
Well, it does throw an InvalidQueryException if the column already exists.

On Mon, Feb 5, 2018 at 4:44 PM, Rahul Singh 
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 ,
> 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
> , Broad Institute
> 
>
>


-- 
Oliver Ruebenacker
Senior Software Engineer, Diabetes Portal
, Broad Institute



Re: Add column if it does not exist?

2018-02-05 Thread Rahul Singh
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 , 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, Broad Institute
>


Add column if it does not exist?

2018-02-05 Thread Oliver Ruebenacker
 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
, Broad Institute