Cassandra AutoAdd Column Fails Due to Wrong Syntax in Generated Query


Mark F
 

Hi,

It looks like the CassandraSchemaHandler in the 5.1.0-release build does not have the appropriate cassandra CSQL for adding a column to the table.

I am getting a sql error when the auto column creation is used to a new column to a table.

ColumnMetadata colmd = getColumnMetadataForColumn(tmd, column);
if (colmd == null)
{
// Add column since doesn't exist
StringBuilder stmtBuilder = new StringBuilder("ALTER TABLE ");
if (schemaName != null)
{
stmtBuilder.append(schemaName).append('.');
}
stmtBuilder.append(table.getName());
stmtBuilder.append(" ADD COLUMN ");
stmtBuilder.append(column.getName()).append(" ").append(column.getTypeName());
tableStmts.add(stmtBuilder.toString());
}
It looks like it is incorrect to add the COLUMN text after the ADD statement.

13:07:08,580 (localhost-startStop-1) DEBUG [DataNucleus.Datastore.Schema] - Creating table using "ALTER TABLE [removed table name] ADD COLUMN settings varchar"
13:07:08,583 (localhost-startStop-1) ERROR [DataNucleus.General] - Exception in schema generation
com.datastax.driver.core.exceptions.SyntaxError: line 1:52 extraneous input 'varchar' expecting EOF

There is no column keyword here.

https://docs.datastax.com/en/cql/3.3/cql/cql_reference/cqlAlterTable.html

Mark

Join main@datanucleus.groups.io to automatically receive all group messages.