From 2d7e99f7b9108204978d733c7b3162274078898d Mon Sep 17 00:00:00 2001 From: Ruslan Fomkin Date: Tue, 28 Oct 2025 12:11:33 +0100 Subject: [PATCH] Document new table name length limit CASSANDRA-20389 implemented limit on table name length of 222 characters. This commit updates the documentation to reflect this. It also adds an assert in CreateTableValidationTest to ensure that the documented limit matches the actual constant. patch by Ruslan Fomkin; reviewed by Brad Schoening, Dmitry Konstantinov for CASSANDRA-20914 --- doc/modules/cassandra/pages/cql/ddl.adoc | 6 ++++-- .../apache/cassandra/schema/CreateTableValidationTest.java | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/doc/modules/cassandra/pages/cql/ddl.adoc b/doc/modules/cassandra/pages/cql/ddl.adoc index be93bc211e..dd47d2505c 100644 --- a/doc/modules/cassandra/pages/cql/ddl.adoc +++ b/doc/modules/cassandra/pages/cql/ddl.adoc @@ -22,8 +22,10 @@ include::example$BNF/ks_table.bnf[] ---- Both keyspace and table name should be comprised of only alphanumeric -characters, cannot be empty and are limited in size to 48 characters -(that limit exists mostly to avoid filenames (which may include the +or underscore characters and cannot be empty. +Keyspace name is limited in size to 48 characters, while +table name is limited in size to 222 characters +(those limits exist mostly to avoid filenames (which may include the keyspace and table name) to go over the limits of certain file systems). By default, keyspace and table names are case-insensitive (`myTable` is equivalent to `mytable`) but case sensitivity can be forced by using diff --git a/test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java b/test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java index 6a88cfe739..b76177cebf 100644 --- a/test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java +++ b/test/unit/org/apache/cassandra/schema/CreateTableValidationTest.java @@ -40,6 +40,7 @@ import static org.apache.cassandra.schema.SchemaConstants.NAME_LENGTH; import static org.apache.cassandra.schema.SchemaConstants.TABLE_NAME_LENGTH; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -170,6 +171,9 @@ public class CreateTableValidationTest extends CQLTester String tableName = StringUtils.repeat("t", FILENAME_LENGTH - tableIdSuffix); String tooLongTableName = StringUtils.repeat("l", FILENAME_LENGTH - tableIdSuffix + 1); + // Assert that the documented value of 222 corresponds to the actual constant. + assertEquals(222, TABLE_NAME_LENGTH); + execute(String.format("CREATE KEYSPACE %s with replication = " + "{ 'class' : 'SimpleStrategy', 'replication_factor' : 1 }", keyspaceName));