maedhroz commented on code in PR #4561:
URL: https://github.com/apache/cassandra/pull/4561#discussion_r2824299689


##########
src/java/org/apache/cassandra/cql3/statements/schema/CreateIndexStatement.java:
##########
@@ -283,22 +268,40 @@ private void validateIndexTarget(TableMetadata table, 
IndexMetadata.Kind kind, I
         if (column.isPartitionKey() && table.partitionKeyColumns().size() == 1)
             throw ire(ONLY_PARTITION_KEY, column);
 
-        if (baseType.isFrozenCollection() && target.type != Type.FULL)
-            throw ire(CREATE_ON_FROZEN_COLUMN, target.type, column, 
column.name.toCQLString());
-
-        if (!baseType.isFrozenCollection() && target.type == Type.FULL)
+        if (target.type == Type.FULL && !isSAIIndex(attrs) && 
(!baseType.isCollection() || column.type.isMultiCell()))
             throw ire(FULL_ON_FROZEN_COLLECTIONS);
 
         if (!baseType.isCollection() && target.type != Type.SIMPLE)
             throw ire(NON_COLLECTION_SIMPLE_INDEX, target.type, column);
 
-        if (!(baseType instanceof MapType && baseType.isMultiCell()) && 
(target.type == Type.KEYS || target.type == Type.KEYS_AND_VALUES))
+        // Frozen collections are only supported with SAI indexes
+        if (!isSAIIndex(attrs) && baseType.isCollection() && 
!column.type.isMultiCell())
+        {
+            if (target.type == Type.VALUES || target.type == Type.KEYS || 
target.type == Type.KEYS_AND_VALUES)
+            {
+                throw ire(CREATE_ON_FROZEN_COLUMN, target.type.toString(), 
column.name, column.name);
+            }
+        }
+
+        if (!(baseType instanceof MapType) && (target.type == Type.KEYS || 
target.type == Type.KEYS_AND_VALUES ))
             throw ire(CREATE_WITH_NON_MAP_TYPE, target.type, column);
 
         if (column.type.isUDT() && column.type.isMultiCell())
             throw ire(CREATE_ON_NON_FROZEN_UDT, column);
     }
 
+    /**
+     * Checks if the given index attributes represent a Storage Attached Index.
+     */
+    private boolean isSAIIndex(IndexAttributes attrs)
+    {
+        if (!attrs.isCustom || attrs.customClass == null)
+            return false;
+
+        return attrs.customClass.equalsIgnoreCase(StorageAttachedIndex.NAME) ||
+               attrs.customClass.equals(StorageAttachedIndex.class.getName());

Review Comment:
   This information is already codified in `IndexMetadata`, so we might be able 
to deduplicate a bit.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to