This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch cassandra-5.0
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-5.0 by this push:
     new 97037496f2 SAI fails queries when multiple columns exist and a 
non-indexed column is a composite with a map
97037496f2 is described below

commit 97037496f2975ac9216071283584bf514b944996
Author: Sunil Ramchandra Pawar <pawar...@apple.com>
AuthorDate: Wed Apr 16 13:35:41 2025 -0700

    SAI fails queries when multiple columns exist and a non-indexed column is a 
composite with a map
    
    patch by Sunil Ramchandra Pawar; reviewed by Caleb Rackliffe, David Capwell 
for CASSANDRA-19891
---
 CHANGES.txt                                        |  1 +
 .../cassandra/index/sai/utils/IndexTermType.java   |  3 +-
 .../cassandra/index/sai/cql/ComplexQueryTest.java  | 44 ++++++++++++++++++++++
 3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/CHANGES.txt b/CHANGES.txt
index 462d3ed74f..2682765f1c 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 5.0.5
+ * SAI fails queries when multiple columns exist and a non-indexed column is a 
composite with a map (CASSANDRA-19891)
  * Grant permission on keyspaces system_views and system_virtual_schema not 
possible (CASSANDRA-20171)
  * Fix marking an SSTable as suspected and BufferPool leakage in case of a 
corrupted SSTable read during a compaction (CASSANDRA-20396)
  * Introduce SSTableSimpleScanner for compaction (CASSANDRA-20092)
diff --git a/src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java 
b/src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java
index 7fa226e958..f3c7e2c05f 100644
--- a/src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java
+++ b/src/java/org/apache/cassandra/index/sai/utils/IndexTermType.java
@@ -144,7 +144,8 @@ public class IndexTermType
 
         AbstractType<?> baseType = indexType.unwrap();
 
-        if (baseType.subTypes().isEmpty())
+        // We only need to inspect subtypes when it is possible for them to be 
queried individually.
+        if (baseType.subTypes().isEmpty() || indexTargetType == 
IndexTarget.Type.SIMPLE || indexTargetType == IndexTarget.Type.FULL)
         {
             this.subTypes = Collections.emptyList();
         }
diff --git a/test/unit/org/apache/cassandra/index/sai/cql/ComplexQueryTest.java 
b/test/unit/org/apache/cassandra/index/sai/cql/ComplexQueryTest.java
index 0b4a053d12..2aa334c29d 100644
--- a/test/unit/org/apache/cassandra/index/sai/cql/ComplexQueryTest.java
+++ b/test/unit/org/apache/cassandra/index/sai/cql/ComplexQueryTest.java
@@ -65,4 +65,48 @@ public class ComplexQueryTest extends SAITester
         var result = execute("SELECT pk FROM %s WHERE str_val = 'A' AND val = 
'A'");
         assertRows(result, row(3));
     }
+
+    @Test
+    public void compositeTypeWithMapInsideQuery()
+    {
+        createTable(KEYSPACE, "CREATE TABLE %s (" +
+                              "pk1 
frozen<map<'CompositeType(IntegerType,SimpleDateType)', 
'DynamicCompositeType(Q=>LongType,I=>ByteType,6=>LexicalUUIDType)'>>," +
+                              "pk2 frozen<tuple<frozen<tuple<float>>>>," +
+                              "ck1 frozen<list<frozen<map<'LexicalUUIDType', 
ascii>>>>," +
+                              "ck2 tinyint," +
+                              "r1 
frozen<list<'DynamicCompositeType(X=>DecimalType,y=>TimestampType,f=>BooleanType)'>>
 static," +
+                              "r2 'DynamicCompositeType(P=>ShortType)'," +
+                              "r3 
'CompositeType(FrozenType(ListType(DoubleType)),FrozenType(MapType(LongType,DoubleType)),DoubleType)',"
 +
+                              "r4 frozen<list<frozen<list<time>>>>," +
+                              "r5 
'CompositeType(CompositeType(ShortType,SimpleDateType,BooleanType),CompositeType(FloatType),MapType(ByteType,TimeType))',"
 +
+                              "r6 set<smallint>," +
+                              "PRIMARY KEY ((pk1, pk2), ck1, ck2))");
+
+
+
+        createIndex("CREATE INDEX ON %s (FULL(ck1)) USING 'SAI'");
+        createIndex("CREATE INDEX ON %s (FULL(pk1)) USING 'SAI'");
+        createIndex("CREATE INDEX ON %s (FULL(r4)) USING 'SAI'");
+        createIndex("CREATE INDEX ON %s (r2) USING 'SAI'");
+        createIndex("CREATE INDEX ON %s (r3) USING 'SAI'");
+
+
+        UntypedResultSet withMultipleColumns = execute("SELECT pk1 FROM " +
+                                                       "%s " +
+                                                       "WHERE r5 = 
0x0010000230bd00000457f0bd31000001000000000700049f647252000000260000000200000001f300000008000001c4e14bba4b00000001260000000800003f2b300d385d00"
 +
+                                                       " AND r3 = 
0x001c00000002000000083380d171eace676900000008e153bb97fdd5c22e00006d000000030000000897c5493857999fc000000013f08cc4fad0f04d0de51cff28d4ae743d2da1c40000000857108e8c372c868400000013f0cc6bca55f0ee240b27ff12c77a7b7dc3c665000000086c07d25fcdd3403500000013f0745922bdf0ac44c9b5ffd80f025ded9a211d000008200547f5da7a43aa00"
 +
+                                                       " AND  r2 = 
0x8050000255e200 " +
+                                                       " AND pk2 = 
((-1.2651989E-23))" +
+                                                       " ALLOW FILTERING;");
+
+        assertRowCount(withMultipleColumns, 0);
+
+        UntypedResultSet withoutSAI = execute("SELECT pk1 FROM " +
+                                              "%s " +
+                                              " WHERE r5 = 
0x001c00000002000000083380d171eace676900000008e153bb97fdd5c22e00006d000000030000000897c5493857999fc000000013f08cc4fad0f04d0de51cff28d4ae743d2da1c40000000857108e8c372c868400000013f0cc6bca55f0ee240b27ff12c77a7b7dc3c665000000086c07d25fcdd3403500000013f0745922bdf0ac44c9b5ffd80f025ded9a211d000008200547f5da7a43aa00"
 +
+                                              " ALLOW FILTERING;");
+
+
+        assertRowCount(withoutSAI, 0);
+    }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to