adelapena commented on code in PR #4249:
URL: https://github.com/apache/cassandra/pull/4249#discussion_r2235962668


##########
test/unit/org/apache/cassandra/db/filter/IndexHintsTest.java:
##########
@@ -0,0 +1,1196 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cassandra.db.filter;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.cql3.CQLTester;
+import org.apache.cassandra.cql3.Operator;
+import org.apache.cassandra.cql3.QualifiedName;
+import org.apache.cassandra.cql3.statements.PropertyDefinitions;
+import org.apache.cassandra.cql3.statements.SelectOptions;
+import org.apache.cassandra.cql3.statements.schema.IndexTarget;
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.ReadCommand;
+import org.apache.cassandra.db.SinglePartitionReadCommand;
+import org.apache.cassandra.exceptions.InvalidRequestException;
+import org.apache.cassandra.exceptions.SyntaxException;
+import org.apache.cassandra.index.CustomIndexTest;
+import org.apache.cassandra.index.Index;
+import org.apache.cassandra.index.TargetParser;
+import org.apache.cassandra.io.util.DataInputBuffer;
+import org.apache.cassandra.io.util.DataOutputBuffer;
+import org.apache.cassandra.net.MessagingService;
+import org.apache.cassandra.schema.ColumnMetadata;
+import org.apache.cassandra.schema.IndexMetadata;
+import org.apache.cassandra.utils.Pair;
+import org.assertj.core.api.Assertions;
+import org.assertj.core.api.ThrowableAssert;
+
+import static java.lang.String.format;
+import static 
org.apache.cassandra.cql3.restrictions.StatementRestrictions.REQUIRES_ALLOW_FILTERING_MESSAGE;
+import static 
org.apache.cassandra.db.filter.IndexHints.CONFLICTING_INDEXES_ERROR;
+import static org.apache.cassandra.db.filter.IndexHints.MISSING_INDEX_ERROR;
+import static org.apache.cassandra.db.filter.IndexHints.TOO_MANY_INDEXES_ERROR;
+import static org.apache.cassandra.db.filter.IndexHints.WRONG_KEYSPACE_ERROR;
+
+/**
+ * Tests the {@link IndexHints} independently of the specific underlying index 
implementation details.
+ * </p>
+ * Regarding its effects on the {@link Index.QueryPlan} that is generated for 
the query:
+ * <ul>
+ *    <li>Included indexes should be included in the {@link Index.QueryPlan} 
for the query or fail.</li>
+ *    <li>Excluded indexes should not be included in the {@link 
Index.QueryPlan} for the query.</li>
+ * </ul>
+ */
+public class IndexHintsTest extends CQLTester

Review Comment:
   Maybe we could add a test showing how query behaviour changes with 
analyzers, even if they are non-tokenizing. For example:
   ```java
   @Test
   public void testMultipleIndexesPerColumnAndCaseSensitivity()
   {
       createTable("CREATE TABLE %s (k int PRIMARY KEY, v text)");
       String sensitive = createIndex("CREATE INDEX sensitive ON %s(v)");
       String insensitive = createIndex("CREATE CUSTOM INDEX insensitive ON 
%s(v) USING 'sai' WITH OPTIONS = { 'case_sensitive' : false }");
   
       String insert = "INSERT INTO %s (k, v) VALUES (?, ?)";
       Object[] row1 = new Object[]{ 1, "A" };
       Object[] row2 = new Object[]{ 2, "a" };
       execute(insert, row1);
       execute(insert, row2);
   
       String query = "SELECT * FROM %s WHERE v='A'";
       assertThatIndexQueryPlanFor(query, row1, row2).selects(insensitive); // 
SAI has priority over legacy
       assertThatIndexQueryPlanFor(query + " WITH 
included_indexes={sensitive}", row1).selects(sensitive);
       assertThatIndexQueryPlanFor(query + " WITH 
included_indexes={insensitive}", row1, row2).selects(insensitive);
       assertThatIndexQueryPlanFor(query + " WITH 
excluded_indexes={sensitive}", row1, row2).selects(insensitive);
       assertThatIndexQueryPlanFor(query + " WITH 
excluded_indexes={insensitive}", row1).selects(sensitive);
       assertNeedsAllowFiltering(query + " WITH excluded_indexes={sensitive, 
insensitive}");
       assertThatIndexQueryPlanFor(query + " ALLOW FILTERING WITH 
excluded_indexes={sensitive, insensitive}", row1).selectsNone();
   }
   ```



-- 
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: pr-unsubscr...@cassandra.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to