You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CNDB-12503 remove column name restrictions in SAI (#1539)
Trying to create an SAI or other index on a column, which name is either
long or has
non-alphanumeric characters, fails, while the table was successfully
created with such name. This happens if an index name is not provided.
The reason for this limitation is that the column name is used for
generating the default index name, which is used in the file names.
Fixesriptano/cndb#12503, fixesriptano/cndb#12609
This PR removes the check for column names during an index creation.
Thus it allows to create indexes on existing columns with any names
including qualified names and long names.
1. The check was preventing qualified column names with characters,
which cannot be used in file names. This was never an issue as the index
name construction from table and column names already removes any
non-alphanumeric or non-underscore characters.
2. The check was preventing long column names. This limitation is
removed by
- Adding calculation of maximum amount characters, which can be used in
index name, so it will allow to construct file names without exceeding
the limit of 255 chars (255 is added as a constant).
- Then the index name is truncated.
3. The uniqueness of index names is already fixed by existing
implementation, which adds counter prefix when needed.
This change to generated index name does not affect existing indexes as
the existing name from `IndexMetadata` is always serialized to JSON,
thus avoiding to re-generating the name.
This fix required to fix CQL tester, since it was assuming that the
restriction is in place. So column name regex pattern matcher is fixed
in `createIndex` to allow non-restricted column names. There might still
be possible corner cases on some column names used for generating index
names, which will not work with `createIndex`. In such case `execute`
should be used.
It also includes several fixes in affected files:
- Improve the name and usage of constants.
- Fix warnings with minor improvements in affected files.
assertallowedIndexNameLength >= indexNameAddition : "cannot happen with current implementation as allowedIndexNameLength is approximately 255 - ~76. However, allowedIndexNameLength was " + allowedIndexNameLength + " and indexNameAddition was " + indexNameAddition;
156
+
157
+
returnallowedIndexNameLength - indexNameAddition;
117
158
}
118
159
119
160
publicvoidvalidate(TableMetadatatable)
120
161
{
121
162
if (!isValidName(name, true))
122
-
thrownewConfigurationException("Illegal index name " + name);
163
+
thrownewConfigurationException(String.format("Index name must not be empty, or contain non-alphanumeric-underscore characters (got \"%s\")",
164
+
name));
123
165
124
166
if (kind == null)
125
167
thrownewConfigurationException("Index kind is null for index " + name);
0 commit comments