spring-data-cassandra icon indicating copy to clipboard operation
spring-data-cassandra copied to clipboard

Add support for additional table options (e.g., default_time_to_live) in `CassandraAdminTemplate`

Open seungh0 opened this issue 6 months ago • 2 comments

Hello,

I'd like to propose extending CassandraAdminTemplate to support additional table options, such as default_time_to_live.

For example, the following code currently results in an error:

cassandraAdminTemplate.createTable(false, Table::class.java, mapOf("default_time_to_live" to 180000))

// -> Unable to recognize specified Table option 'default_time_to_live'

Additionally, it seems that several valid table options are not currently recognized:

  • default_time_to_live
  • speculative_retry
  • memtable_flush_period_in_ms
  • cdc
  • read_repair
  • min_index_interval
  • max_index_interval
  • crc_check_chance

These options are documented in the official Cassandra documentation:

  • general
    • https://cassandra.apache.org/doc/latest/cassandra/developing/cql/ddl.html#create-table-general-options
  • min_index_interval, max_index_interval, crc_check
    • https://cassandra.apache.org/doc/latest/cassandra/reference/cql-commands/create-table.html#table_options
  • crc_check_chance
    • https://issues.apache.org/jira/browse/CASSANDRA-18872
    • https://cassandra.apache.org/doc/5.0/cassandra/developing/cql/cql_singlefile.html#createTableOptions

Supporting these options in CassandraAdminTemplate would enable developers to define more fine-grained table configurations programmatically, aligning better with native CQL capabilities and increasing flexibility in schema management.

I'm happy to submit a PR if this change aligns with the project's direction.

seungh0 avatar Jun 19 '25 20:06 seungh0

Currently, our options are mostly enums, such as TableOption. We could use that one to determine whether a value must be given like it is now but with the variant that we don't fail if the key is unknown. Escaping and quoting is up to the calling code.

Happy to review a pull request.

mp911de avatar Jun 23 '25 12:06 mp911de

Thank you for your feedback.

  1. I’ve added support for the newly introduced table options.
  2. As you suggested, I updated the logic to allow unregistered options to be used without causing failures.

The changes are split into two separate commits in this PR (#1586).

I’d appreciate it if you could take a look.

seungh0 avatar Jun 23 '25 16:06 seungh0