You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2020/02/13 03:32:58 UTC

[incubator-doris] branch master updated: [Doris on ES] Support escape character (#2865)

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

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new fd492e3  [Doris on ES] Support escape character (#2865)
fd492e3 is described below

commit fd492e3b6fd729e617536842ba4092911f8afae8
Author: 令狐少侠 <bl...@163.com>
AuthorDate: Thu Feb 13 11:32:48 2020 +0800

    [Doris on ES] Support escape character (#2865)
---
 be/src/exec/es/es_query_builder.cpp | 15 +++++++++++++--
 be/src/exec/es_http_scan_node.cpp   |  5 +++++
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/be/src/exec/es/es_query_builder.cpp b/be/src/exec/es/es_query_builder.cpp
index 8ebe90d..863972c 100644
--- a/be/src/exec/es/es_query_builder.cpp
+++ b/be/src/exec/es/es_query_builder.cpp
@@ -110,8 +110,19 @@ void WildCardQueryBuilder::to_json(rapidjson::Document* document, rapidjson::Val
 }
 WildCardQueryBuilder::WildCardQueryBuilder(const ExtLikePredicate& like_predicate) : _field(like_predicate.col.name) {
     _like_value = like_predicate.value.to_string();
-    std::replace(_like_value.begin(), _like_value.end(), '_', '?');
-    std::replace(_like_value.begin(), _like_value.end(), '%', '*');
+    // example of translation :
+    //      abc_123  ===> abc?123
+    //      abc%ykz  ===> abc*123
+    //      abc\\_123 ===> abc\\_123
+    //      abc\\%123 ===> abc\\%123
+    // NOTE. user must input sql like 'abc\\_123' or 'abc\\%ykz'
+    for (int i = 0; i< _like_value.size(); i++) {
+        if ((_like_value[i] == '_' || _like_value[i]== '%') && i > 0) {
+                if (_like_value[i-1] != '\\' ) {
+                    _like_value[i] = (_like_value[i] == '_') ? '?' : '*';
+                }
+        }
+    }
 }
 
 void TermsInSetQueryBuilder::to_json(rapidjson::Document* document, rapidjson::Value* query) {
diff --git a/be/src/exec/es_http_scan_node.cpp b/be/src/exec/es_http_scan_node.cpp
index bd50e32..e1d22e2 100644
--- a/be/src/exec/es_http_scan_node.cpp
+++ b/be/src/exec/es_http_scan_node.cpp
@@ -166,6 +166,11 @@ Status EsHttpScanNode::start_scanners() {
 }
 
 Status EsHttpScanNode::collect_scanners_status() {
+    // NOTE. if open() was called, but set_range() was NOT called for some reason.
+    // then close() was called. 
+    // there would cause a core because _scanners_status's iterator was in [0, _scan_ranges) other than [0, _scanners_status)
+    // it is said that the fragment-call-frame is calling scan-node in this way....
+    // in my options, it's better fixed in fragment-call-frame. e.g. call close() according the return value of open()
     for (int i = 0; i < _scanners_status.size(); i++) {
         std::future<Status> f = _scanners_status[i].get_future();
         RETURN_IF_ERROR(f.get());


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org