csun5285 commented on code in PR #68021:
URL: https://github.com/apache/doris/pull/68021#discussion_r4022280645


##########
regression-test/suites/index_p0/test_ngram_bloomfilter_index_like_escape.groovy:
##########
@@ -0,0 +1,96 @@
+// 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.
+
+suite("test_ngram_bloomfilter_index_like_escape") {
+    // An NGRAM_BF index prunes a page whose bloom filter misses a token of 
the LIKE pattern, so
+    // the tokens have to occur in every string the pattern matches. Deriving 
them means reading
+    // the pattern's escapes exactly the way LIKE does, which the storage 
layer does not attempt;
+    // it leaves the index alone instead. Whatever the reason, turning the 
index on must never
+    // change a result set.
+
+    // One backslash. Backslashes go through SQL string-literal unescaping 
before reaching LIKE,
+    // so each one is written twice in the statement text.
+    def bs = '\\'
+    def quote = { String raw -> raw.replace(bs, bs + bs) }
+
+    def values = [
+            'a' + bs + 'bc',                // one literal backslash
+            'xxab' + bs + bs + 'cdyy',      // two consecutive literal 
backslashes
+            'zab' + bs + 'Zcdz',
+            'a' + bs + 'Zbb',               // backslash in front of an 
ordinary character
+            'a' + bs + '中zz',              // backslash in front of a 
multi-byte character
+            '100%off',                      // literal percent in the data
+            'x_y',                          // literal underscore in the data
+            'qa%bz',                        // for the custom-escape pattern 
below
+            'plain ascii row',
+            '中文测试行',
+    ]
+
+    // [pattern, escape clause]. The escape-free entries must keep using the 
index; the rest are

Review Comment:
   已修改



##########
be/src/storage/tablet/tablet_reader.cpp:
##########
@@ -368,7 +368,8 @@ Status TabletReader::_init_column_predicates(const 
ReaderParams& read_params) {
         }
         const auto& col = *_read_schema->column(predicate->column_id());
         const auto* tablet_index = 
_tablet_schema->get_ngram_bf_index(col.unique_id());
-        if (tablet_index && config::enable_query_like_bloom_filter) {
+        if (tablet_index && config::enable_query_like_bloom_filter &&
+            predicate->can_do_bloom_filter(true)) {

Review Comment:
   接受这种情况下不过索引



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to