Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion be/src/vec/functions/function_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ struct StringOP {

static void push_value_string(const std::string_view& string_value, size_t index,
ColumnString::Chars& chars, ColumnString::Offsets& offsets) {
DCHECK(string_value.data() != nullptr);
ColumnString::check_chars_length(chars.size() + string_value.size(), offsets.size());

chars.insert(string_value.data(), string_value.data() + string_value.size());
Expand Down Expand Up @@ -2802,11 +2803,14 @@ class FunctionStringParseUrl : public IFunction {
StringRef url_val = url_col->get_data_at(index_check_const<url_const>(i));
StringRef parse_res;
if (UrlParser::parse_url(url_val, url_part, &parse_res)) {
if (parse_res.empty()) [[unlikely]] {
StringOP::push_empty_string(i, res_chars, res_offsets);
continue;
}
StringOP::push_value_string(std::string_view(parse_res.data, parse_res.size), i,
res_chars, res_offsets);
} else {
StringOP::push_null_string(i, res_chars, res_offsets, null_map_data);
continue;
}
}
return Status::OK();
Expand Down
3 changes: 2 additions & 1 deletion be/test/vec/function/function_string_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2284,7 +2284,8 @@ TEST(function_string_test, function_parse_url_test) {
{{std::string(
"https://www.facebook.com/aa/bb?returnpage=https://www.facebook.com/"),
std::string("HosT")},
std::string("www.facebook.com")}};
std::string("www.facebook.com")},
{{std::string("http://www.baidu.com"), std::string("FILE")}, {std::string("")}}};

check_function_all_arg_comb<DataTypeString, true>(func_name, input_types, data_set);
}
Expand Down
4 changes: 4 additions & 0 deletions regression-test/data/function_p0/test_function_string.out
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,7 @@ a
a
a

-- !sql --
www.facebook.com
www.google.com /test?name=abc&age=20

24 changes: 24 additions & 0 deletions regression-test/suites/function_p0/test_function_string.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,28 @@ suite("test_function_string") {
drop table if exists test_tb_function_space;
"""


sql """
drop table if exists test_parse_url;
"""

sql """
CREATE TABLE `test_parse_url` (
`id` int NULL,
`url` text NULL
) ENGINE=OLAP
DUPLICATE KEY(`id`)
DISTRIBUTED BY RANDOM BUCKETS AUTO
PROPERTIES (
"replication_allocation" = "tag.location.default: 1"
);
"""

sql """
insert into test_parse_url values (1, 'http://www.facebook.com'), (2, "http://www.google.com/test?name=abc&age=20");
"""

qt_sql """
select parse_url(url, 'HOST') as host, parse_url(url, 'FILE') as file from test_parse_url order by id;
"""
}
Loading