github-actions[bot] commented on code in PR #68011:
URL: https://github.com/apache/doris/pull/68011#discussion_r4028092368
##########
be/test/exprs/function/function_url_test.cpp:
##########
@@ -93,4 +93,69 @@ TEST(FunctionUrlTEST, ProtocolTest) {
static_cast<void>(check_function<DataTypeString, true>(func_name,
input_types, data_set));
}
+TEST(FunctionUrlTEST, ParseUrlQueryKeyTest) {
+ std::string func_name = "parse_url";
+ InputTypeSet input_types = {PrimitiveType::TYPE_VARCHAR,
PrimitiveType::TYPE_VARCHAR,
+ PrimitiveType::TYPE_VARCHAR};
+
+ DataSet data_set = {
+ // The only '?' is inside the fragment, so the url has no query
component.
+ {{STRING("http://h/p#f?k=v"), STRING("QUERY"), STRING("k")},
Null()},
+ // The '#' comes before the '?', so it is a fragment instead of a
query.
+ {{STRING("http://h/p#f/?#k=v"), STRING("QUERY"), STRING("k")},
Null()},
+ {{STRING("http://h/p#?k=v"), STRING("QUERY"), STRING("k")},
Null()},
+ // The url has no query component at all.
+ {{STRING("http://h/p&k=v"), STRING("QUERY"), STRING("k")}, Null()},
+ // The key only exists in the path.
+ {{STRING("http://h/p&k=v?x=1"), STRING("QUERY"), STRING("k")},
Null()},
+ // The query component of this url is 'x=1'.
+ {{STRING("http://h/p&k=v?x=1"), STRING("QUERY"), STRING("x")},
STRING("1")},
+ // The key only exists in the fragment.
+ {{STRING("http://h/p?x=1#f&k=v"), STRING("QUERY"), STRING("k")},
Null()},
+ // The key exists in the path, in the query and in the fragment.
+ {{STRING("http://h/p&k=v?k=1#f&k=2"), STRING("QUERY"),
STRING("k")}, STRING("1")},
+ {{STRING("http://h/p?a=1&k=2"), STRING("QUERY"), STRING("k")},
STRING("2")},
+ // A duplicated key keeps the behaviour of returning the first
value.
+ {{STRING("http://h/p?k=1&k=2#f"), STRING("QUERY"), STRING("k")},
STRING("1")},
+ {{STRING("http://h/p?k=1&k=2&k=3"), STRING("QUERY"), STRING("k")},
STRING("1")},
+ // Only the query component is searched, so the duplicated key in
the fragment is
+ // not part of the result.
+ {{STRING("http://h/p?k=1#k=2&k=3"), STRING("QUERY"), STRING("k")},
STRING("1")},
+ // A key without any '=' is not a valid query parameter.
+ {{STRING("http://h/p?k"), STRING("QUERY"), STRING("k")}, Null()},
+ {{STRING("http://h/p?"), STRING("QUERY"), STRING("k")}, Null()},
Review Comment:
[P2] Exercise successful continuation in the keyed scan
This case only proves that a missing `=` returns NULL when there is no later
candidate, so either new rejection branch could stop early and every added
oracle would still pass. Please add cases such as `?sk=0&k=1` and `?k&k=1`
returning `1`, plus `?k=&k=2` returning the empty string. Those cover rejection
of a false-prefix/missing-`=` match while continuing, and preserve the first
valid empty value that the rewritten offset loop is expected to return.
--
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]