>From Michael Blow <[email protected]>:

Michael Blow has submitted this change. ( 
https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20583?usp=email )

Change subject: [ASTERIXDB-3525][COMP] Fix handling of WHERE conditions LIKE "%"
......................................................................

[ASTERIXDB-3525][COMP] Fix handling of WHERE conditions LIKE "%"

- user model changes: no
- storage format changes: no
- interface changes: no

Ext-ref: MB-69416
Change-Id: I7ed97c9f1f2f5a624efeb8bb2ea92f76ccda4048
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20583
Integration-Tests: Jenkins <[email protected]>
Tested-by: Murtadha Hubail <[email protected]>
Reviewed-by: Murtadha Hubail <[email protected]>
---
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.26.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.27.query.sqlpp
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.26.adm
A 
asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.27.plan
A 
asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.27.plan
A 
asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.27.plan
M 
asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
7 files changed, 120 insertions(+), 0 deletions(-)

Approvals:
  Jenkins: Verified
  Murtadha Hubail: Looks good to me, approved; Verified

Objections:
  Anon. E. Moose #1000171: Violations found




diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.26.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.26.query.sqlpp
new file mode 100644
index 0000000..02a83d2
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.26.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+use test;
+
+select * from ds1 where name like "%" order by id;
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.27.query.sqlpp
 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.27.query.sqlpp
new file mode 100644
index 0000000..68037d9
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.27.query.sqlpp
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+use test;
+
+explain select * from ds1 where name like "%";
\ No newline at end of file
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.26.adm
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.26.adm
new file mode 100644
index 0000000..36e19ae
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.26.adm
@@ -0,0 +1,19 @@
+{ "ds1": { "id": 1, "name": "John", "age": 21 } }
+{ "ds1": { "id": 2, "name": "asd gdh", "age": 23 } }
+{ "ds1": { "id": 3, "name": "xossted", "age": 102 } }
+{ "ds1": { "id": 4, "name": "asdgdh👩‍👩‍👧dfsd", "age": 23 } }
+{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
+{ "ds1": { "id": 6, "name": "fsdxv😀", "age": 17 } }
+{ "ds1": { "id": 7, "name": "fsdxv😁", "age": 17 } }
+{ "ds1": { "id": 8, "name": "Join", "age": 21 } }
+{ "ds1": { "id": 9, "name": "sxvfjshfjisciis", "age": 13 } }
+{ "ds1": { "id": 10, "name": "h\\axx%", "age": 123 } }
+{ "ds1": { "id": 11, "name": "h\\\\%axx%", "age": 11 } }
+{ "ds1": { "id": 12, "name": "h\\\\_axx%", "age": 43 } }
+{ "ds1": { "id": 13, "name": "h\\\\ax\\%", "age": 21 } }
+{ "ds1": { "id": 14, "name": "h\\\\ax\\%", "age": 4 } }
+{ "ds1": { "id": 15, "name": "ax\\_%", "age": 6 } }
+{ "ds1": { "id": 16, "name": "axnvtxb", "age": 53 } }
+{ "ds1": { "id": 17, "name": "fvbn\"", "age": 23 } }
+{ "ds1": { "id": 18, "name": "fv%%\\bn\"", "age": 99 } }
+{ "ds1": { "id": 19, "name": "fv%%\\bn\"", "age": 101 } }
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.27.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.27.plan
new file mode 100644
index 0000000..948fe11
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.27.plan
@@ -0,0 +1,18 @@
+distribute result [$$16] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    assign [$$16] <- [{"ds1": $$ds1}] project: [$$16] [cardinality: 0.0, 
doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+    -- ASSIGN  |PARTITIONED|
+      select (like($$ds1.getField(1), "%")) [cardinality: 0.0, doc-size: 0.0, 
op-cost: 0.0, total-cost: 0.0]
+      -- STREAM_SELECT  |PARTITIONED|
+        project ([$$ds1]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 
0.0]
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 0.0, 
doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 
0.0, total-cost: 0.0]
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.27.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.27.plan
new file mode 100644
index 0000000..01c15c7
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.27.plan
@@ -0,0 +1,18 @@
+distribute result [$$16] [cardinality: 19.0, doc-size: 47.89, op-cost: 0.0, 
total-cost: 19.0]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange [cardinality: 19.0, doc-size: 47.89, op-cost: 0.0, total-cost: 19.0]
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    assign [$$16] <- [{"ds1": $$ds1}] project: [$$16] [cardinality: 19.0, 
doc-size: 47.89, op-cost: 0.0, total-cost: 19.0]
+    -- ASSIGN  |PARTITIONED|
+      select (like($$ds1.getField(1), "%")) [cardinality: 19.0, doc-size: 
47.89, op-cost: 0.0, total-cost: 19.0]
+      -- STREAM_SELECT  |PARTITIONED|
+        project ([$$ds1]) [cardinality: 19.0, doc-size: 47.89, op-cost: 0.0, 
total-cost: 19.0]
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange [cardinality: 19.0, doc-size: 47.89, op-cost: 0.0, 
total-cost: 19.0]
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 19.0, 
doc-size: 47.89, op-cost: 0.0, total-cost: 19.0]
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 
0.0, total-cost: 0.0]
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.27.plan
 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.27.plan
new file mode 100644
index 0000000..f1f856f
--- /dev/null
+++ 
b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.27.plan
@@ -0,0 +1,18 @@
+distribute result [$$16] [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+-- DISTRIBUTE_RESULT  |PARTITIONED|
+  exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+  -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+    assign [$$16] <- [{"ds1": $$ds1}] project: [$$16] [cardinality: 0.0, 
doc-size: 0.0, op-cost: 0.0, total-cost: 0.0]
+    -- ASSIGN  |PARTITIONED|
+      select (like($$ds1.getField(1), "%")) [cardinality: 0.0, doc-size: 0.0, 
op-cost: 0.0, total-cost: 0.0]
+      -- STREAM_SELECT  |PARTITIONED|
+        project ([$$ds1]) [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+        -- STREAM_PROJECT  |PARTITIONED|
+          exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, total-cost: 
0.0]
+          -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+            data-scan []<-[$$17, $$ds1] <- test.ds1 filter on: 
like($$ds1.getField(1), "%") [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+            -- DATASOURCE_SCAN  |PARTITIONED|
+              exchange [cardinality: 0.0, doc-size: 0.0, op-cost: 0.0, 
total-cost: 0.0]
+              -- ONE_TO_ONE_EXCHANGE  |PARTITIONED|
+                empty-tuple-source [cardinality: 0.0, doc-size: 0.0, op-cost: 
0.0, total-cost: 0.0]
+                -- EMPTY_TUPLE_SOURCE  |PARTITIONED|
diff --git 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
index 7f6e0ab..50c4ac9 100644
--- 
a/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
+++ 
b/asterixdb/asterix-lang-sqlpp/src/main/java/org/apache/asterix/lang/sqlpp/rewrites/visitor/OperatorExpressionVisitor.java
@@ -304,6 +304,9 @@

     private static LikePattern processPattern(String pattern, StringBuilder 
likePatternStr) {
         // note: similar logic is applied in StringLikeDescriptor
+        if (pattern.equals(String.valueOf(PERCENT))) {
+            return null;
+        }
         LikePattern likePattern = EQUAL;
         for (int i = 0, length = pattern.length(); i < length; i++) {
             char c = pattern.charAt(i);

--
To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/20583?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://asterix-gerrit.ics.uci.edu/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: asterixdb
Gerrit-Branch: phoenix
Gerrit-Change-Id: I7ed97c9f1f2f5a624efeb8bb2ea92f76ccda4048
Gerrit-Change-Number: 20583
Gerrit-PatchSet: 5
Gerrit-Owner: Preetham Poluparthi <[email protected]>
Gerrit-Reviewer: Ali Alsuliman <[email protected]>
Gerrit-Reviewer: Anon. E. Moose #1000171
Gerrit-Reviewer: Jenkins <[email protected]>
Gerrit-Reviewer: Michael Blow <[email protected]>
Gerrit-Reviewer: Murtadha Hubail <[email protected]>
Gerrit-Reviewer: Preetham Poluparthi <[email protected]>

Reply via email to