You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "gavinchou (via GitHub)" <gi...@apache.org> on 2024/03/18 09:42:29 UTC
[PR] Fix unrecognized column name delete handler [doris]
gavinchou opened a new pull request, #32404:
URL: https://github.com/apache/doris/pull/32404
* doris 2.0.x 版本还有遗留的问题, delete handler 将 predicate 表达式转成一个字
符串持久化了, 然后在使用的时候通过正则提取字段名 比较符号 以及值来还原
predicate. 这个序列化和正则匹配的过程是非常tricky并且是不鲁棒的.
* doris 2.0.x 不允许使用中文列名, 否则有delete 语句可能会导致BE coredump
* 2.1 引入了 sub_predicate_v2 解决了转成字符串再持久化的问题,
但是为了保证兼容, master分支最好也修一下(需要单独提PR, 因为不一样了)
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] Fix unrecognized column name delete handler [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #32404:
URL: https://github.com/apache/doris/pull/32404#issuecomment-2003351403
Thank you for your contribution to Apache Doris.
Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR)
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix] Fix unrecognized column name delete handler #32429 [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #32404:
URL: https://github.com/apache/doris/pull/32404#issuecomment-2006061499
PR approved by anyone and no changes requested.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix] Fix unrecognized column name delete handler #32429 [doris]
Posted by "dataroaring (via GitHub)" <gi...@apache.org>.
dataroaring merged PR #32404:
URL: https://github.com/apache/doris/pull/32404
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix] Fix unrecognized column name delete handler #32429 [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #32404:
URL: https://github.com/apache/doris/pull/32404#issuecomment-2004646462
TeamCity be ut coverage result:
Function Coverage: 37.81% (8040/21265)
Line Coverage: 29.47% (65612/222611)
Region Coverage: 28.95% (33768/116637)
Branch Coverage: 24.80% (17333/69900)
Coverage Report: http://coverage.selectdb-in.cc/coverage/eb82e352cc6c4aff1d551231dd9791931a817e78_eb82e352cc6c4aff1d551231dd9791931a817e78/report/index.html
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] Fix unrecognized column name delete handler [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #32404:
URL: https://github.com/apache/doris/pull/32404#discussion_r1528472757
##########
be/test/olap/delete_handler_test.cpp:
##########
@@ -1232,4 +1232,44 @@ TEST_F(TestDeleteHandler, FilterDataVersion) {
_delete_handler.finalize();
}
+// clang-format off
+TEST_F(TestDeleteHandler, TestParseDeleteCondition) {
+ auto test = [](const std::tuple<std::string, bool, TCondition>& in) {
+ auto& [cond_str, exp_succ, exp_cond] = in;
+ TCondition parsed_cond;
+ EXPECT_EQ(DeleteHandler::parse_delete_condition(cond_str, &parsed_cond), exp_succ) << " unexpected result, cond_str: " << cond_str;
+ if (exp_succ) EXPECT_EQ(parsed_cond, exp_cond) << " unexpected result, cond_str: " << cond_str;
+ };
+
+ auto gen_cond = [](const std::string& col, const std::string& op, const std::string& val) {
+ TCondition cond;
+ cond.__set_column_name(col);
+ cond.__set_condition_op(op);
+ cond.__set_condition_values(std::vector<std::string>{val});
+ return cond;
+ };
+
+ // <cond_str, parsed, expect_value>>
+ std::vector<std::tuple<std::string, bool, TCondition>> test_input {
+ {R"(abc=b)" , true, gen_cond(R"(abc)" , "=" , R"(b)" )}, // normal case
+ {R"(abc!=b)" , true, gen_cond(R"(abc)" , "!=", R"(b)" )}, // normal case
+ {R"(abc<=b)" , true, gen_cond(R"(abc)" , "<=", R"(b)" )}, // normal case
+ {R"(abc>=b)" , true, gen_cond(R"(abc)" , ">=", R"(b)" )}, // normal case
+ {R"(abc>>b)" , true, gen_cond(R"(abc)" , ">>", R"(b)" )}, // normal case
+ {R"(abc<<b)" , true, gen_cond(R"(abc)" , "<<", R"(b)" )}, // normal case
+ {R"(abc!='b')" , true, gen_cond(R"(abc)" , "!=", R"(b)" )}, // value surrounded by '
+ {R"(abc=)" , true, gen_cond(R"(abc)" , "=" , R"()" )}, // missing value, it means not to be parsed succefully, how every it's a ignorable bug
Review Comment:
warning: statement should be inside braces [readability-braces-around-statements]
```suggestion
exp_succ) { EXPECT_EQ(parsed_cond, exp_cond) << " unexpected result, cond_str: " << cond_str;
}
```
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] Fix unrecognized column name delete handler [doris]
Posted by "xiaokang (via GitHub)" <gi...@apache.org>.
xiaokang commented on PR #32404:
URL: https://github.com/apache/doris/pull/32404#issuecomment-2004237375
run buildall
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix] Fix unrecognized column name delete handler #32429 [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #32404:
URL: https://github.com/apache/doris/pull/32404#issuecomment-2006061423
PR approved by at least one committer and no changes requested.
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] Fix unrecognized column name delete handler [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #32404:
URL: https://github.com/apache/doris/pull/32404#discussion_r1528221916
##########
be/src/olap/delete_handler.cpp:
##########
@@ -195,43 +203,48 @@ Status DeleteHandler::check_condition_valid(const TabletSchema& schema, const TC
return Status::OK();
}
-bool DeleteHandler::_parse_condition(const std::string& condition_str, TCondition* condition) {
- bool matched = true;
+// clang-format off
+// Condition string format, the format is (column_name)(op)(value)
+// eg: condition_str="c1 = 1597751948193618247 and length(source)<1;\n;\n"
+// column_name: matches "c1", must include FeNameFormat.java COLUMN_NAME_REGEX
+// and compactible with any the lagacy
+// operator: matches "="
+// value: matches "1597751948193618247 and length(source)<1;\n;\n"
+//
+// For more info, see DeleteHandler::construct_sub_predicates
+// FIXME(gavin): support unicode. And this is a tricky implementation, it should
+// not be the final resolution, refactor it.
+const char* const CONDITION_STR_PATTERN =
+ // .----------------- column-name --------------------. .----------------------- operator ------------------------. .------------ value ----------.
+ R"(([_a-zA-Z@0-9\s<>/][.a-zA-Z0-9_+-/><?@#$%^&*"\s,:]*)\s*((?:=)|(?:!=)|(?:>>)|(?:<<)|(?:>=)|(?:<=)|(?:\*=)|(?: IS ))\s*('((?:[\s\S]+)?)'|(?:[\s\S]+)?))";
+ // '----------------- group 1 ------------------------' '--------------------- group 2 ---------------------------' | '-- group 4--' |
+ // match any of: = != >> << >= <= *= " IS " '----------- group 3 ---------'
+ // match **ANY THING** without(4)
+ // or with(3) single quote
+boost::regex DELETE_HANDLER_REGEX(CONDITION_STR_PATTERN);
+// clang-format on
+
+bool DeleteHandler::parse_delete_condition(const std::string& condition_str,
+ TCondition* condition) {
+ bool matched = false;
boost::smatch what;
-
try {
- // Condition string format, the format is (column_name)(op)(value)
- // eg: condition_str="c1 = 1597751948193618247 and length(source)<1;\n;\n"
- // group1: (\w+) matches "c1"
- // group2: ((?:=)|(?:!=)|(?:>>)|(?:<<)|(?:>=)|(?:<=)|(?:\*=)|(?:IS)) matches "="
- // group3: ((?:[\s\S]+)?) matches "1597751948193618247 and length(source)<1;\n;\n"
- const char* const CONDITION_STR_PATTERN =
- R"(([\w$#%]+)\s*((?:=)|(?:!=)|(?:>>)|(?:<<)|(?:>=)|(?:<=)|(?:\*=)|(?:IS))\s*('((?:[\s\S]+)?)'|(?:[\s\S]+)?))";
- boost::regex ex(CONDITION_STR_PATTERN);
- if (boost::regex_match(condition_str, what, ex)) {
- if (condition_str.size() != what[0].str().size()) {
- matched = false;
- }
- } else {
- matched = false;
- }
+ VLOG_NOTICE << "condition_str: " << condition_str;
+ matched = boost::regex_match(condition_str, what, DELETE_HANDLER_REGEX) &&
+ condition_str.size() == what[0].str().size(); // exact match
} catch (boost::regex_error& e) {
VLOG_NOTICE << "fail to parse expr. [expr=" << condition_str << "; error=" << e.what()
<< "]";
- matched = false;
}
+ if (!matched) return false;
Review Comment:
warning: statement should be inside braces [readability-braces-around-statements]
```suggestion
if (!matched) { return false;
}
```
##########
be/test/olap/delete_handler_test.cpp:
##########
@@ -1232,4 +1232,39 @@ TEST_F(TestDeleteHandler, FilterDataVersion) {
_delete_handler.finalize();
}
+// clang-format off
+TEST_F(TestDeleteHandler, test_parse_delete_condition) {
+ auto test = [](const std::tuple<std::string, bool, TCondition>& in) {
+ auto& [cond_str, exp_succ, exp_cond] = in;
+ TCondition parsed_cond;
+ EXPECT_EQ(DeleteHandler::parse_delete_condition(cond_str, &parsed_cond), exp_succ) << " unexpected result, cond_str: " << cond_str;
+ if (exp_succ) EXPECT_EQ(parsed_cond, exp_cond) << " unexpected result, cond_str: " << cond_str;
+ };
+
+ auto gen_cond = [](const std::string& col, const std::string& op, const std::string& val) {
+ TCondition cond;
+ cond.__set_column_name(col);
+ cond.__set_condition_op(op);
+ cond.__set_condition_values(std::vector<std::string>{val});
+ return cond;
+ };
+
+ // <cond_str, parsed, expect_value>>
+ std::vector<std::tuple<std::string, bool, TCondition>> test_input {
+ {R"(abc=b)" , true, gen_cond(R"(abc)" , "=" , R"(b)" )}, // normal case
+ {R"(abc=)" , true, gen_cond(R"(abc)" , "=" , R"()" )}, // missing value, it means not to be parsed succefully, how every it's a ignorable bug
+ {R"(abc!='b')" , true, gen_cond(R"(abc)" , "!=", R"(b)" )}, // value surrounded by '
+ {R"(@a*<<10086)" , true, gen_cond(R"(@a*)" , "<<", R"(10086)" )}, // column ends with *
+ {R"(*a=b)" , false, gen_cond(R"(*a)" , "=" , R"(b)" )}, // starts with *
+ {R"(a*a>>WTF(10086))" , true, gen_cond(R"(a*a)" , ">>", R"(WTF(10086))")}, // function
+ {R"(a-b IS NULL)" , true, gen_cond(R"(a-b)" , "IS", R"(NULL)" )}, // - in col name and test IS NULL
Review Comment:
warning: statement should be inside braces [readability-braces-around-statements]
```suggestion
<< cond_str; {
}
```
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] Fix unrecognized column name delete handler [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on code in PR #32404:
URL: https://github.com/apache/doris/pull/32404#discussion_r1528463207
##########
be/test/olap/delete_handler_test.cpp:
##########
@@ -1232,4 +1232,43 @@ TEST_F(TestDeleteHandler, FilterDataVersion) {
_delete_handler.finalize();
}
+// clang-format off
+TEST_F(TestDeleteHandler, TestParseDeleteCondition) {
+ auto test = [](const std::tuple<std::string, bool, TCondition>& in) {
+ auto& [cond_str, exp_succ, exp_cond] = in;
+ TCondition parsed_cond;
+ EXPECT_EQ(DeleteHandler::parse_delete_condition(cond_str, &parsed_cond), exp_succ) << " unexpected result, cond_str: " << cond_str;
+ if (exp_succ) EXPECT_EQ(parsed_cond, exp_cond) << " unexpected result, cond_str: " << cond_str;
+ };
+
+ auto gen_cond = [](const std::string& col, const std::string& op, const std::string& val) {
+ TCondition cond;
+ cond.__set_column_name(col);
+ cond.__set_condition_op(op);
+ cond.__set_condition_values(std::vector<std::string>{val});
+ return cond;
+ };
+
+ // <cond_str, parsed, expect_value>>
+ std::vector<std::tuple<std::string, bool, TCondition>> test_input {
+ {R"(abc=b)" , true, gen_cond(R"(abc)" , "=" , R"(b)" )}, // normal case
+ {R"(abc!=b)" , true, gen_cond(R"(abc)" , "!=", R"(b)" )}, // normal case
+ {R"(abc<=b)" , true, gen_cond(R"(abc)" , "<=", R"(b)" )}, // normal case
+ {R"(abc>=b)" , true, gen_cond(R"(abc)" , ">=", R"(b)" )}, // normal case
+ {R"(abc>>b)" , true, gen_cond(R"(abc)" , ">>", R"(b)" )}, // normal case
+ {R"(abc<<b)" , true, gen_cond(R"(abc)" , "<<", R"(b)" )}, // normal case
+ {R"(abc!='b')" , true, gen_cond(R"(abc)" , "!=", R"(b)" )}, // value surrounded by '
+ {R"(@a*<<10086)" , true, gen_cond(R"(@a*)" , "<<", R"(10086)" )}, // column ends with *
Review Comment:
warning: statement should be inside braces [readability-braces-around-statements]
```suggestion
exp_succ) { EXPECT_EQ(parsed_cond, exp_cond) << " unexpected result, cond_str: " << cond_str;
}
```
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix] Fix unrecognized column name delete handler #32429 [doris]
Posted by "gavinchou (via GitHub)" <gi...@apache.org>.
gavinchou commented on PR #32404:
URL: https://github.com/apache/doris/pull/32404#issuecomment-2004510186
run buildall
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix] Fix unrecognized column name delete handler #32429 [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #32404:
URL: https://github.com/apache/doris/pull/32404#issuecomment-2004577937
TeamCity be ut coverage result:
Function Coverage: 37.81% (8040/21265)
Line Coverage: 29.47% (65610/222611)
Region Coverage: 28.95% (33764/116637)
Branch Coverage: 24.79% (17331/69900)
Coverage Report: http://coverage.selectdb-in.cc/coverage/2df21c78195a0c10e3840f3f55193fc3f7b3d7a5_2df21c78195a0c10e3840f3f55193fc3f7b3d7a5/report/index.html
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [fix] Fix unrecognized column name delete handler #32429 [doris]
Posted by "gavinchou (via GitHub)" <gi...@apache.org>.
gavinchou commented on PR #32404:
URL: https://github.com/apache/doris/pull/32404#issuecomment-2004595960
run buildall
--
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: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org