[ASTERIXDB-3525][COMP] Fixing issue when trailing % is after escaping Method
- user model changes: no
- storage format changes: no
- interface changes: no
Details:
Fixing like expression when we have escaping methods.
Ext-ref: MB-56789
Change-Id: I88661621467405cf2b37da6dcb81015467d7d759
Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19064
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Ali Alsuliman <ali.al.solaiman@gmail.com>
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.02.update.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.02.update.sqlpp
index 94642af..8f4a38b 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.02.update.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.02.update.sqlpp
@@ -29,5 +29,14 @@
{"id":7, "name": "fsdxv😁", "age": 17},
{"id":8, "name": "Join", "age": 21},
{"id":9, "name": "sxvfjshfjisciis", "age": 13},
-{"id":10, "name": "syvgjshfjisciis", "age": 123}
+{"id":10, "name": "h\\axx%", "age": 123},
+{"id":11, "name": "h\\\\%axx%", "age": 11},
+{"id":12, "name": "h\\\\_axx%", "age": 43},
+{"id":13, "name": "h\\\\ax\\%", "age": 21},
+{"id":14, "name": "h\\\\ax\\%", "age": 4},
+{"id":15, "name": "ax\\_%", "age": 6},
+{"id":16, "name": "axnvtxb", "age": 53},
+{"id":17, "name": "fvbn\"", "age": 23},
+{"id":18, "name": "fv%%\\bn\"", "age": 99},
+{"id":19, "name": "fv%%\\bn\"", "age": 101}
]);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.23.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.23.query.sqlpp
new file mode 100644
index 0000000..6e0749c
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.23.query.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.
+ */
+
+select * from [{"x":"fvxb%"}] p where x like "fvxb\\%";
+select * from [{"x":"fv%%\\bn\\%"}] p where x like "fv\\%\\%\\\\bn\\\\%";
+select * from [{"x":"fvxbx"}] p where x like "fvxb\\%";
+select * from [{"x":"fv%xbx"}] p where x like "fv\\%xb%";
+select * from [{"x":"a\\%bcd"}] p where x like "a\\\\\\%bcd";
+select * from [{"x":"abc\n%"}] p where x like "abc\n\\%";
+select * from [{"x":"abc\n%"}] p where x like "abc\n%";
+select * from [{"x":"abc%cbz"},{"x":"abc%%x"},{"x":"abc"}] p where x like "abc\\%%";
+select * from [{"x":"vhjdbvsabc_fjdhf"},{"x":"abc%%x"},{"x":"abc"}] p where x like "%abc\\_%";
+select * from [{"x":"abc_fjdhf"},{"x":"abc%%x"},{"x":"abc"}] p where x like "abc\\_%";
+select * from [{"x":"abc_fjdhf"},{"x":"abc%x"},{"x":"abc%yz"}] p where x like "abc\\%_";
+select * from [{"x":"abc_fjdhf"},{"x":"abc%x"},{"x":"abc%yz"},{"x":"abc_"}] p where x like "abc\\_";
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.24.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.24.query.sqlpp
new file mode 100644
index 0000000..3657c3b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.24.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 "h\\\\axx\\%";
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.25.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.25.query.sqlpp
new file mode 100644
index 0000000..0cb91aa
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/index-selection/like-expression/like-expression.25.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 "h\\\\axx\\%";
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.23.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.23.adm
new file mode 100644
index 0000000..30dd010
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.23.adm
@@ -0,0 +1,14 @@
+{ "p": { "x": "fvxb%" } }
+{ "p": { "x": "fv%%\\bn\\%" } }
+
+{ "p": { "x": "fv%xbx" } }
+{ "p": { "x": "a\\%bcd" } }
+{ "p": { "x": "abc\n%" } }
+{ "p": { "x": "abc\n%" } }
+{ "p": { "x": "abc%cbz" } }
+{ "p": { "x": "abc%%x" } }
+
+{ "p": { "x": "vhjdbvsabc_fjdhf" } }
+{ "p": { "x": "abc_fjdhf" } }
+{ "p": { "x": "abc%x" } }
+{ "p": { "x": "abc_" } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.24.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.24.adm
new file mode 100644
index 0000000..2ba2846
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.24.adm
@@ -0,0 +1 @@
+{ "ds1": { "id": 10, "name": "h\\axx%", "age": 123 } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.25.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.25.plan
new file mode 100644
index 0000000..9590f61
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/index-selection/like-expression/like-expression.25.plan
@@ -0,0 +1,34 @@
+distribute result [$$16] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$16]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ select (eq($$ds1.getField(1), "h\axx%")) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_SELECT |PARTITIONED|
+ project ([$$ds1]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$17, $$ds1] <- index-search("ds1", 0, "Default", "test", "ds1", false, false, 1, $$22, 1, $$22, true, true, true) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ order (ASC, $$22) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STABLE_SORT [$$22(ASC)] |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$22]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$21, $$22] <- index-search("ds1_name", 0, "Default", "test", "ds1", false, false, 1, $$19, 1, $$20, true, true, true) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ assign [$$19, $$20] <- ["h\axx%", "h\axx%"] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ empty-tuple-source [cardinality: 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.03.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.03.adm
deleted file mode 100644
index 07e109a..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.03.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 6, "name": "fsdxv😀", "age": 17 } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.04.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.04.plan
index 131d7f2..c32e7c2 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.04.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.04.plan
@@ -1,24 +1,38 @@
-distribute result [$$19] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$19] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$19]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$19]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- select (and(ge($$20, "fsdxv😀"), lt($$20, "fsdxv😁"))) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ select (and(ge($$20, "fsdxv😀"), lt($$20, "fsdxv😁"))) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_SELECT |PARTITIONED|
- assign [$$20] <- [$$ds1.getField(1)] [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$20] <- [$$ds1.getField(1)] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$21, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
- -- DATASOURCE_SCAN |PARTITIONED|
+ unnest-map [$$21, $$ds1] <- index-search("ds1", 0, "Default", "test", "ds1", false, false, 1, $$25, 1, $$25, true, true, true) [cardinality: 1.0, op-cost: 2.0, total-cost: 2.0]
+ -- BTREE_SEARCH |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- empty-tuple-source [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ order (ASC, $$25) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STABLE_SORT [$$25(ASC)] |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$25]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$24, $$25] <- index-search("ds1_name", 0, "Default", "test", "ds1", false, false, 1, $$22, 1, $$23, true, false, false) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ assign [$$22, $$23] <- ["fsdxv😀", "fsdxv😁"] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ empty-tuple-source [cardinality: 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.05.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.05.adm
deleted file mode 100644
index 45d43d5..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.05.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 4, "name": "asdgdh👩👩👧dfsd", "age": 23 } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.06.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.06.plan
index 16cbb40..0268e04 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.06.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.06.plan
@@ -1,24 +1,38 @@
-distribute result [$$19] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$19] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$19]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$19]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- select (and(ge($$20, "asdgdh👩👩👧"), lt($$20, "asdgdh👩👩👨"))) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ select (and(ge($$20, "asdgdh👩👩👧"), lt($$20, "asdgdh👩👩👨"))) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_SELECT |PARTITIONED|
- assign [$$20] <- [$$ds1.getField(1)] [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$20] <- [$$ds1.getField(1)] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$21, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
- -- DATASOURCE_SCAN |PARTITIONED|
+ unnest-map [$$21, $$ds1] <- index-search("ds1", 0, "Default", "test", "ds1", false, false, 1, $$25, 1, $$25, true, true, true) [cardinality: 1.0, op-cost: 2.0, total-cost: 2.0]
+ -- BTREE_SEARCH |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- empty-tuple-source [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ order (ASC, $$25) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STABLE_SORT [$$25(ASC)] |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$25]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$24, $$25] <- index-search("ds1_name", 0, "Default", "test", "ds1", false, false, 1, $$22, 1, $$23, true, false, false) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ assign [$$22, $$23] <- ["asdgdh👩👩👧", "asdgdh👩👩👨"] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ empty-tuple-source [cardinality: 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.07.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.07.adm
deleted file mode 100644
index e4ac10b..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.07.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.08.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.08.plan
index bb00128..5b03e17 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.08.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.08.plan
@@ -1,20 +1,34 @@
-distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ASSIGN |PARTITIONED|
- select (eq($$ds1.getField(1), "sxvciis")) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ select (eq($$ds1.getField(1), "sxvciis")) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_SELECT |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
- -- DATASOURCE_SCAN |PARTITIONED|
+ unnest-map [$$17, $$ds1] <- index-search("ds1", 0, "Default", "test", "ds1", false, false, 1, $$22, 1, $$22, true, true, true) [cardinality: 1.0, op-cost: 2.0, total-cost: 2.0]
+ -- BTREE_SEARCH |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- empty-tuple-source [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ order (ASC, $$22) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STABLE_SORT [$$22(ASC)] |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$22]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$21, $$22] <- index-search("ds1_name", 0, "Default", "test", "ds1", false, false, 1, $$19, 1, $$20, true, true, true) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ assign [$$19, $$20] <- ["sxvciis", "sxvciis"] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ empty-tuple-source [cardinality: 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.09.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.09.adm
deleted file mode 100644
index 4ca49aa..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.09.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 1, "name": "John", "age": 21 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.10.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.10.plan
index 4f7d8c3..71fe9ea 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.10.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.10.plan
@@ -1,24 +1,38 @@
-distribute result [$$19] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$19] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$19]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$19]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- select (and(ge($$20, "Joh"), lt($$20, "Joi"))) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ select (and(ge($$20, "Joh"), lt($$20, "Joi"))) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_SELECT |PARTITIONED|
- assign [$$20] <- [$$ds1.getField(1)] [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$20] <- [$$ds1.getField(1)] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$21, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
- -- DATASOURCE_SCAN |PARTITIONED|
+ unnest-map [$$21, $$ds1] <- index-search("ds1", 0, "Default", "test", "ds1", false, false, 1, $$25, 1, $$25, true, true, true) [cardinality: 1.0, op-cost: 2.0, total-cost: 2.0]
+ -- BTREE_SEARCH |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- empty-tuple-source [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
- -- EMPTY_TUPLE_SOURCE |PARTITIONED|
+ order (ASC, $$25) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STABLE_SORT [$$25(ASC)] |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$25]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$24, $$25] <- index-search("ds1_name", 0, "Default", "test", "ds1", false, false, 1, $$22, 1, $$23, true, false, false) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ assign [$$22, $$23] <- ["Joh", "Joi"] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ empty-tuple-source [cardinality: 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.11.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.11.adm
deleted file mode 100644
index 202bfb1..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.11.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 9, "name": "sxvfjshfjisciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.12.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.12.plan
index d31cb55..e7c1727 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.12.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.12.plan
@@ -1,18 +1,18 @@
-distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- ASSIGN |PARTITIONED|
- select (like($$ds1.getField(1), "s%vfjs__jiscii%")) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ select (like($$ds1.getField(1), "s%vfjs__jiscii%")) [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_SELECT |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
+ data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 19.0, op-cost: 19.0, total-cost: 19.0]
-- DATASOURCE_SCAN |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.13.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.13.adm
deleted file mode 100644
index 6bbea7c..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.13.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.14.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.14.plan
index af9784e..e698fca 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.14.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.14.plan
@@ -1,18 +1,18 @@
-distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- ASSIGN |PARTITIONED|
- select (like($$ds1.getField(1), "sxvc_is")) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ select (like($$ds1.getField(1), "sxvc_is")) [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_SELECT |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
+ data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 19.0, op-cost: 19.0, total-cost: 19.0]
-- DATASOURCE_SCAN |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.15.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.15.adm
deleted file mode 100644
index 6bbea7c..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.15.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.16.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.16.plan
index 5f1ee43..380f0c6 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.16.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.16.plan
@@ -1,18 +1,18 @@
-distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- ASSIGN |PARTITIONED|
- select (like($$ds1.getField(1), "sxvc_i%")) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ select (like($$ds1.getField(1), "sxvc_i%")) [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_SELECT |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
+ data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 19.0, op-cost: 19.0, total-cost: 19.0]
-- DATASOURCE_SCAN |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.17.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.17.adm
deleted file mode 100644
index 202bfb1..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.17.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 9, "name": "sxvfjshfjisciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.18.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.18.plan
index bd31c2e..027f9d0 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.18.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.18.plan
@@ -1,18 +1,18 @@
-distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- ASSIGN |PARTITIONED|
- select (like($$ds1.getField(1), "sxvfjs%jisci%")) [cardinality: 1.0, op-cost: 0.0, total-cost: 10.0]
+ select (like($$ds1.getField(1), "sxvfjs%jisci%")) [cardinality: 1.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_SELECT |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
+ data-scan []<-[$$17, $$ds1] <- test.ds1 [cardinality: 19.0, op-cost: 19.0, total-cost: 19.0]
-- DATASOURCE_SCAN |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.19.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.19.adm
deleted file mode 100644
index 3d747c3..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.19.adm
+++ /dev/null
@@ -1,2 +0,0 @@
-{ "ds1": { "id": 1, "name": "John", "age": 21 } }
-{ "ds1": { "id": 8, "name": "Join", "age": 21 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.20.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.20.plan
index b21c4ee..6938a61 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.20.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.20.plan
@@ -1,22 +1,22 @@
-distribute result [$$19] [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$19] [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$19]) [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$19]) [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- select (and(ge($$20, "J"), lt($$20, "K"))) [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ select (and(ge($$20, "J"), lt($$20, "K"))) [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_SELECT |PARTITIONED|
- assign [$$20] <- [$$ds1.getField(1)] [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$20] <- [$$ds1.getField(1)] [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$21, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
+ data-scan []<-[$$21, $$ds1] <- test.ds1 [cardinality: 19.0, op-cost: 19.0, total-cost: 19.0]
-- DATASOURCE_SCAN |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.21.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.21.adm
deleted file mode 100644
index be3fef3..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.21.adm
+++ /dev/null
@@ -1,2 +0,0 @@
-{ "ds1": { "id": 9, "name": "sxvfjshfjisciis", "age": 13 } }
-{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.22.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.22.plan
index 9922a01..4aae972 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.22.plan
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.22.plan
@@ -1,22 +1,22 @@
-distribute result [$$19] [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+distribute result [$$19] [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- DISTRIBUTE_RESULT |PARTITIONED|
- exchange [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- project ([$$19]) [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$19]) [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$19] <- [{"ds1": $$ds1}] [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- select (and(ge($$20, "sx"), lt($$20, "sy"))) [cardinality: 2.0, op-cost: 0.0, total-cost: 10.0]
+ select (and(ge($$20, "sx"), lt($$20, "sy"))) [cardinality: 2.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_SELECT |PARTITIONED|
- assign [$$20] <- [$$ds1.getField(1)] [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ assign [$$20] <- [$$ds1.getField(1)] [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- ASSIGN |PARTITIONED|
- project ([$$ds1]) [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ project ([$$ds1]) [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- STREAM_PROJECT |PARTITIONED|
- exchange [cardinality: 10.0, op-cost: 0.0, total-cost: 10.0]
+ exchange [cardinality: 19.0, op-cost: 0.0, total-cost: 19.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
- data-scan []<-[$$21, $$ds1] <- test.ds1 [cardinality: 10.0, op-cost: 10.0, total-cost: 10.0]
+ data-scan []<-[$$21, $$ds1] <- test.ds1 [cardinality: 19.0, op-cost: 19.0, total-cost: 19.0]
-- DATASOURCE_SCAN |PARTITIONED|
exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
-- ONE_TO_ONE_EXCHANGE |PARTITIONED|
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.25.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.25.plan
new file mode 100644
index 0000000..d48bb20
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_cbo/index-selection/like-expression/like-expression.25.plan
@@ -0,0 +1,34 @@
+distribute result [$$16] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$16]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
+ -- ASSIGN |PARTITIONED|
+ select (eq($$ds1.getField(1), "h\axx%")) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
+ -- STREAM_SELECT |PARTITIONED|
+ project ([$$ds1]) [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 1.0, op-cost: 0.0, total-cost: 2.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$17, $$ds1] <- index-search("ds1", 0, "Default", "test", "ds1", false, false, 1, $$22, 1, $$22, true, true, true) [cardinality: 1.0, op-cost: 2.0, total-cost: 2.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ order (ASC, $$22) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STABLE_SORT [$$22(ASC)] |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$22]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$21, $$22] <- index-search("ds1_name", 0, "Default", "test", "ds1", false, false, 1, $$19, 1, $$20, true, true, true) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ assign [$$19, $$20] <- ["h\axx%", "h\axx%"] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ empty-tuple-source [cardinality: 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.03.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.03.adm
deleted file mode 100644
index 07e109a..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.03.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 6, "name": "fsdxv😀", "age": 17 } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.05.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.05.adm
deleted file mode 100644
index 45d43d5..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.05.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 4, "name": "asdgdh👩👩👧dfsd", "age": 23 } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.07.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.07.adm
deleted file mode 100644
index e4ac10b..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.07.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.09.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.09.adm
deleted file mode 100644
index 4ca49aa..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.09.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 1, "name": "John", "age": 21 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.11.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.11.adm
deleted file mode 100644
index 202bfb1..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.11.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 9, "name": "sxvfjshfjisciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.13.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.13.adm
deleted file mode 100644
index 6bbea7c..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.13.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.15.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.15.adm
deleted file mode 100644
index 6bbea7c..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.15.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.17.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.17.adm
deleted file mode 100644
index 202bfb1..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.17.adm
+++ /dev/null
@@ -1 +0,0 @@
-{ "ds1": { "id": 9, "name": "sxvfjshfjisciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.19.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.19.adm
deleted file mode 100644
index 3d747c3..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.19.adm
+++ /dev/null
@@ -1,2 +0,0 @@
-{ "ds1": { "id": 1, "name": "John", "age": 21 } }
-{ "ds1": { "id": 8, "name": "Join", "age": 21 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.21.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.21.adm
deleted file mode 100644
index be3fef3..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.21.adm
+++ /dev/null
@@ -1,2 +0,0 @@
-{ "ds1": { "id": 9, "name": "sxvfjshfjisciis", "age": 13 } }
-{ "ds1": { "id": 5, "name": "sxvciis", "age": 13 } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.25.plan b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.25.plan
new file mode 100644
index 0000000..37fbb32
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_column/index-selection/like-expression/like-expression.25.plan
@@ -0,0 +1,34 @@
+distribute result [$$16] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+-- DISTRIBUTE_RESULT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$16]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ assign [$$16] <- [{"ds1": $$ds1}] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ select (eq($$ds1.getField(1), "h\axx%")) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_SELECT |PARTITIONED|
+ project ([$$ds1]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$17, $$ds1] <- index-search("ds1", 0, "Default", "test", "ds1", false, false, 1, $$22, 1, $$22, true, true, true) range-filter on: eq($$ds1.getField(1), "h\axx%") [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ order (ASC, $$22) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STABLE_SORT [$$22(ASC)] |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ project ([$$22]) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- STREAM_PROJECT |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ unnest-map [$$21, $$22] <- index-search("ds1_name", 0, "Default", "test", "ds1", false, false, 1, $$19, 1, $$20, true, true, true) [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- BTREE_SEARCH |PARTITIONED|
+ exchange [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ONE_TO_ONE_EXCHANGE |PARTITIONED|
+ assign [$$19, $$20] <- ["h\axx%", "h\axx%"] [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- ASSIGN |PARTITIONED|
+ empty-tuple-source [cardinality: 0.0, op-cost: 0.0, total-cost: 0.0]
+ -- EMPTY_TUPLE_SOURCE |PARTITIONED|
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ConstantUtil.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ConstantUtil.java
index 8bee6b2..8f1ef19 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ConstantUtil.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/utils/ConstantUtil.java
@@ -20,7 +20,8 @@
package org.apache.asterix.common.utils;
public class ConstantUtil {
+ public static final char LIKE_ESCAPE = '\\';
+ public static final char PERCENT = '%';
+ public static final char UNDERSCORE = '_';
- public static final String PERCENT = "%";
- public static final String UNDERSCORE = "_";
}
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 83ca05f..7f6e0ab 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
@@ -19,8 +19,11 @@
package org.apache.asterix.lang.sqlpp.rewrites.visitor;
+import static org.apache.asterix.common.utils.ConstantUtil.LIKE_ESCAPE;
import static org.apache.asterix.common.utils.ConstantUtil.PERCENT;
import static org.apache.asterix.common.utils.ConstantUtil.UNDERSCORE;
+import static org.apache.asterix.lang.sqlpp.rewrites.visitor.OperatorExpressionVisitor.LikePattern.EQUAL;
+import static org.apache.asterix.lang.sqlpp.rewrites.visitor.OperatorExpressionVisitor.LikePattern.PREFIX;
import java.util.ArrayList;
import java.util.Collections;
@@ -88,29 +91,26 @@
}
private Expression processLikeOperator(OperatorExpr operatorExpr, OperatorType opType) throws CompilationException {
- CallExpr likeExpr =
- new CallExpr(new FunctionSignature(BuiltinFunctions.STRING_LIKE), operatorExpr.getExprList());
- likeExpr.addHints(operatorExpr.getHints());
- likeExpr.setSourceLocation(operatorExpr.getSourceLocation());
switch (opType) {
case LIKE:
Expression target = operatorExpr.getExprList().get(0);
Expression patternExpr = operatorExpr.getExprList().get(1);
String patternStr = ExpressionUtils.getStringLiteral(patternExpr);
- if (patternStr != null && patternStr.endsWith(PERCENT) && patternStr.length() > 1) {
- String prefix = patternStr.substring(0, patternStr.length() - 1);
- if (!prefix.contains(PERCENT) && !prefix.contains(UNDERSCORE)) {
- return convertLikeToRange(operatorExpr, target, prefix);
+ if (patternStr != null) {
+ StringBuilder likePatternStr = new StringBuilder();
+ LikePattern likePattern = processPattern(patternStr, likePatternStr);
+ if (likePattern == PREFIX) {
+ return convertLikeToRange(operatorExpr, target, likePatternStr.toString());
+ } else if (likePattern == EQUAL) {
+ Expression processedExpr = new LiteralExpr(new StringLiteral(likePatternStr.toString()));
+ return createOperatorExpression(OperatorType.EQ, target, processedExpr, operatorExpr.getHints(),
+ operatorExpr.getSourceLocation());
}
}
- if (patternStr != null && !patternStr.contains(PERCENT) && !patternStr.contains(UNDERSCORE)) {
- return createOperatorExpression(OperatorType.EQ, target, patternExpr, operatorExpr.getHints(),
- operatorExpr.getSourceLocation());
- }
return createLikeExpression(operatorExpr);
case NOT_LIKE:
CallExpr notLikeExpr = new CallExpr(new FunctionSignature(BuiltinFunctions.NOT),
- new ArrayList<>(Collections.singletonList(likeExpr)));
+ new ArrayList<>(Collections.singletonList(createLikeExpression(operatorExpr))));
notLikeExpr.setSourceLocation(operatorExpr.getSourceLocation());
return notLikeExpr;
default:
@@ -301,4 +301,34 @@
likeExpr.setSourceLocation(operatorExpr.getSourceLocation());
return likeExpr;
}
+
+ private static LikePattern processPattern(String pattern, StringBuilder likePatternStr) {
+ // note: similar logic is applied in StringLikeDescriptor
+ LikePattern likePattern = EQUAL;
+ for (int i = 0, length = pattern.length(); i < length; i++) {
+ char c = pattern.charAt(i);
+ if (c == LIKE_ESCAPE) {
+ char nextChar;
+ // escape character can't be last, and only %, _ and the escape char are allowed after it
+ if (i >= length - 1 || ((nextChar = pattern.charAt(i + 1)) != PERCENT && nextChar != UNDERSCORE
+ && nextChar != LIKE_ESCAPE)) {
+ return null;
+ }
+ likePatternStr.append(nextChar);
+ ++i;
+ } else if (c == PERCENT && i == pattern.length() - 1) {
+ likePattern = PREFIX;
+ } else if (c == UNDERSCORE || c == PERCENT) {
+ return null;
+ } else {
+ likePatternStr.append(c);
+ }
+ }
+ return likePattern;
+ }
+
+ enum LikePattern {
+ PREFIX,
+ EQUAL
+ }
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLikeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLikeDescriptor.java
index 1c75aa9..6f595b1 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLikeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/StringLikeDescriptor.java
@@ -112,6 +112,7 @@
@Override
public String toRegExpPatternString(String pattern) throws HyracksDataException {
+ // note: similar logic is applied in OperatorExpressionVisitor
tempStringBuilder.setLength(0);
for (int i = 0, length = pattern.length(); i < length; i++) {
char c = pattern.charAt(i);