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

alsuliman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new e42600383e [ASTERIXDB-3525][COMP] Capture index hints for LIKE operator
e42600383e is described below

commit e42600383e596246c0fb9b8946aa920e619b967f
Author: Ali Alsuliman <[email protected]>
AuthorDate: Fri Dec 13 19:40:40 2024 -0800

    [ASTERIXDB-3525][COMP] Capture index hints for LIKE operator
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Ext-ref: MB-56789
    Change-Id: I75613c0c3df8ede32619338254e6c71c604de2c0
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19204
    Integration-Tests: Jenkins <[email protected]>
    Tested-by: Ali Alsuliman <[email protected]>
    Reviewed-by: Ali Alsuliman <[email protected]>
    Reviewed-by: Peeyush Gupta <[email protected]>
---
 .../skip-index/skip-secondary-btree-index-4.sqlpp  | 31 ++++++++++++++++++++++
 .../skip-index/skip-secondary-btree-index-4.plan   | 10 +++++++
 .../asterix-lang-sqlpp/src/main/javacc/SQLPP.jj    | 19 +++++++++----
 3 files changed, 55 insertions(+), 5 deletions(-)

diff --git 
a/asterixdb/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index-4.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index-4.sqlpp
new file mode 100644
index 0000000000..35ca9f9b85
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/optimizerts/queries/skip-index/skip-secondary-btree-index-4.sqlpp
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+/*
+ * Description  : Skip secondary index for LIKE operator
+ * Expected Res : Success
+ */
+
+drop  dataverse test if exists;
+create  dataverse test;
+
+use test;
+
+create collection c primary key (id: int);
+create index idx1 on c(f:string);
+select * from c where f /*+skip-index*/ like "abc%";
diff --git 
a/asterixdb/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index-4.plan
 
b/asterixdb/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index-4.plan
new file mode 100644
index 0000000000..1435e63ba4
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/optimizerts/results/skip-index/skip-secondary-btree-index-4.plan
@@ -0,0 +1,10 @@
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    -- ASSIGN  |PARTITIONED|
+      -- STREAM_SELECT  |PARTITIONED|
+        -- ASSIGN  |PARTITIONED|
+          -- STREAM_PROJECT  |PARTITIONED|
+            -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+              -- DATASOURCE_SCAN (test.c)  |PARTITIONED|
+                -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                  -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
\ No newline at end of file
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 
b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index e65568e52d..6b3aa54380 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -4184,6 +4184,7 @@ Expression LikeExpr() throws ParseException:
   OperatorExpr op = null;
   Expression operand = null;
   IExpressionAnnotation annotation = null;
+  List<IExpressionAnnotation> annotationList = null;
 }
 {
     operand = ConcatExpr()
@@ -4191,9 +4192,17 @@ Expression LikeExpr() throws ParseException:
         LOOKAHEAD(2)
         (<NOT> { not = true; })? <LIKE>
         {
-          Token hintToken = fetchHint(token, 
SqlppHint.SINGLE_DATASET_PREDICATE_SELECTIVITY_HINT);
-          if (hintToken != null) {
-               annotation = parseExpressionAnnotation(hintToken);
+          List<Token> hintTokens = fetchHints(token, 
SqlppHint.SINGLE_DATASET_PREDICATE_SELECTIVITY_HINT,
+            SqlppHint.SKIP_SECONDARY_INDEX_SEARCH_HINT, 
SqlppHint.USE_SECONDARY_INDEX_SEARCH_HINT);
+          if (hintTokens != null && !hintTokens.isEmpty()) {
+            annotationList = new ArrayList<IExpressionAnnotation>();
+          }
+          for (Token hintToken : hintTokens) {
+            annotation = parseExpressionAnnotation(hintToken);
+            if (annotation != null) {
+              // annotation may be null if hints are malformed
+              annotationList.add(annotation);
+            }
           }
           op = new OperatorExpr();
           op.addOperand(operand);
@@ -4209,8 +4218,8 @@ Expression LikeExpr() throws ParseException:
           } catch (CompilationException e){
             throw new SqlppParseException(getSourceLocation(token), 
e.getMessage());
           }
-          if (annotation != null) {
-             op.addHint(annotation);
+          if (annotationList != null && !annotationList.isEmpty()) {
+            op.addHints(annotationList);
           }
         }
 

Reply via email to