Reputation: 40061
I'm preparing statements in the constructor of my repository class, like this
PreparedStatement getStatement = cqlSession.prepare(selectFrom("the_table")
.all()
.whereColumn("the_key").isEqualTo(bindMarker())
.build());
I later bind it to a BoundStatement and read the results like this
String someColumn = row.isNull("some_column") ? null : row.getString("some_column")
During runtime I run an alter on the table, adding a column. Something I expected would work since I query for columns only by name. However, it seems that the driver internally has mapped the column names to column indexes which are now all broken.
Is this expected? It severely limits what can be done in run time.
Am I missing something that would have forced a re-prepare of a statement on schema change?
Can I intercept it and re-prepare manually?
I'm running spring boot 2.5.9 and the driver version 4.11.3 The cassandra cluster runs version 3.11.10
Upvotes: 2
Views: 700
Reputation: 16393
To add to @absurdfarce's answer, Cassandra 3.7 is a very old release. In fact, it was released all the way back to early 2016.
There were several important fixes to prepared statements since then. Although a quick browse of those fixes don't seem to be directly related to the issue you reported, they are significant nonetheless.
Additionally there were several fixes to schema migration/propagation in the last 6 years. Again, they don't directly relate to your problem and I'm ordinarily loathe to push for an upgrade but I think 6 years' worth of fixes between C* 3.7 to 3.11.latest merits it. Cheers!
Upvotes: 1
Reputation: 261
thanks for the question!
Your symptoms sound similar to the behaviours described in CASSANDRA-10786. If you're dealing with a version before Cassandra 4.0 this could very well be what's going on.
Does the description in that issue match up with what you're seeing?
Upvotes: 2