cassandra bind variables produces error: no viable alternative at input '?'

227 Views Asked by At

I'm using cassandra. I am trying to update the gc_grace value using new bind variable.

ALTER table  keyspace.table_name with gc_grace_seconds = ? ;

I got the following error:

no viable alternative at input '?'

How can I solve this?

2

There are 2 best solutions below

1
On

As I see from the source code (maybe I'm wrong), but ALTER TABLE doesn't support bindings, so you can't use them for this command (and all DDL commands), and need to just use execute with specific value

0
On

It looks like you're trying to bind parameters programatically to set GC grace on a table. It isn't possible to do that using the Cassandra drivers.

It will only work through cqlsh. For example:

cqlsh> ALTER TABLE community.maptbl WITH gc_grace_seconds = 3600;

It doesn't make sense to do it in your app and it is not recommended. Cheers!