ing-bank / cassandra-jdbc-wrapper

A JDBC wrapper of Java Driver for Apache Cassandra®, which offers a simple JDBC compliant API to work with CQL3.
Apache License 2.0
74 stars 25 forks source link

Liquibase cassandra fails #36

Closed dinchand closed 1 year ago

dinchand commented 1 year ago

@maximevw Firstly Thanks for the release 4.10.2 which fixed my previous issue.

However I now encounter a new one . When I run it I now get

Unexpected error running Liquibase: line 1:53 no viable alternative at input '(' (... TABLE contacting.DATABASECHANGELOG (ID [VARCHAR](...) [Failed SQL: (0) CREATE TABLE contacting.DATABASECHANGELOG (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED datetime NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20), CONTEXTS VARCHAR(255), LABELS VARCHAR(255), DEPLOYMENT_ID VARCHAR(10))]

I did read about the compliance mode and https://github.com/ing-bank/cassandra-jdbc-wrapper/issues/25 . I am not sure if all liquibase users should use that compliance mode. I tried with that as well but no luck. Any pointers ?

maximevw commented 1 year ago

@dinchand, good news for the fix 😄

Liquibase compliance mode is strongly recommended to avoid some unexpected behaviours happening in some scenarios (for example, creating a table and populating it immediately after will fail without the Liquibase compliance mode).

Also, it seems you're trying to run classic Liquibase for SQL here because the query is not valid CQL (varchar(N) does not exist in CQL, explaining the parsing error). Are you using Liquibase Cassandra? Because, as you can see here in the Liquibase Cassandra code, the syntax of the query creating the table DATABASECHANGELOG is different.

An example of integration in a Spring application is available here: https://github.com/liquibase/liquibase-cassandra/issues/212#issuecomment-1741795280. Also, I already successfully ran the standard example provided in the Liquibase documentation as you could see in the issue #25.

I hope a new version of Liquibase Cassandra will be released soon with this JDBC wrapper (since changes have been merged in their main branch few weeks ago: https://github.com/liquibase/liquibase-cassandra/pull/205)

dinchand commented 1 year ago

@maximevw Again thanks for the clear explanations and pointers. I was indeed missing the Liquibase Cassandra as dependency.

Also after you suggested I tried using the latest Liquibase Cassandra. And now I hit

[2023-11-01 17:02:30] SEVERE [liquibase.ext] Could not get keyspace from connection
java.lang.ClassCastException: com.datical.liquibase.ext.database.jvm.ProJdbcConnection cannot be cast to com.ing.data.cassandra.jdbc.CassandraConnection
        at liquibase.ext.cassandra.database.CassandraDatabase.getKeyspace(CassandraDatabase.java:114)
        at liquibase.ext.cassandra.database.CassandraDatabase.getDefaultCatalogName(CassandraDatabase.java:136)
        at liquibase.database.AbstractJdbcDatabase.getLiquibaseCatalogName(AbstractJdbcDatabase.java:710)
        at liquibase.ext.cassandra.lockservice.LockServiceCassandra.getChangeLogLockTableName(LockServiceCassandra.java:197)
        at liquibase.ext.cassandra.lockservice.LockServiceCassandra.isLocked(LockServiceCassandra.java:183)

Possibly because the the CassandraConnection is an implementation of java.sql.Connection but liquibase has its own interface.

maximevw commented 1 year ago

Hello @dinchand,

Indeed, the latest version of Liquibase Cassandra (4.24.0) still relies on Simba JDBC driver, that's certainly why you got this cast exception.

You currently have the following alternative:

maximevw commented 1 year ago

As this is not an issue directly related to the JDBC wrapper for Cassandra, I'll transform into a discussion.