github-actions[bot] commented on code in PR #68579:
URL: https://github.com/apache/doris/pull/68579#discussion_r4241430529


##########
be/src/exprs/function/function_tokenize.cpp:
##########
@@ -43,26 +45,87 @@ using namespace doris::segment_v2::inverted_index;
 
 Status parse(const std::string& str, std::map<std::string, std::string>& 
result) {
     boost::regex pattern(
-            R"delimiter((?:'([^']*)'|"([^"]*)"|([^, 
]*))\s*=\s*(?:'([^']*)'|"([^"]*)"|([^, ]*)))delimiter");
+            R"delimiter((?:'([^']*)'|"([^"]*)"|([^,= 
]+))\s*=\s*(?:'([^']*)'|"([^"]*)"|([^, ]*)))delimiter");
     boost::smatch matches;
 
-    std::string::const_iterator searchStart(str.cbegin());
-    while (boost::regex_search(searchStart, str.cend(), matches, pattern)) {
+    // FE parses literal properties, but properties only BE can evaluate are 
parsed here, so every
+    // character must belong to a comma separated key-value pair.
+    auto skip_spaces = [&](std::string::const_iterator it) {
+        while (it != str.cend() && std::isspace(static_cast<unsigned 
char>(*it))) {
+            ++it;
+        }
+        return it;
+    };
+    std::string::const_iterator searchStart = skip_spaces(str.cbegin());
+    while (searchStart != str.cend()) {

Review Comment:
   [P2] Preserve SQL comments in tokenize property strings. FE accepts 
`tokenize('hello world', '/*note*/ parser=english')`: its property lexer hides 
the comment and parses `parser=english`. The previous unanchored BE search also 
skipped that comment and used the English analyzer. With `match_continuous`, 
parsing starts at `/` and now returns InvalidArgument, so a formerly working 
literal (and an equivalent BE-evaluated constant) fails at execution. Skip 
comment tokens as FE does while still rejecting malformed property text, and 
cover both argument forms.



-- 
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