be/src/exprs/function/url/function_url.cpp
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | // This file is copied from |
18 | | // https://github.com/ClickHouse/ClickHouse/blob/master/src/Functions/URL/domain.cpp |
19 | | // and modified by Doris |
20 | | |
21 | | #include "core/column/column.h" |
22 | | #include "core/data_type/data_type.h" |
23 | | #include "exprs/function/function_string_to_string.h" |
24 | | #include "exprs/function/simple_function_factory.h" |
25 | | #include "exprs/function/url/domain.h" |
26 | | #include "exprs/function/url/functions_url.h" |
27 | | #include "exprs/function/url/protocol.h" |
28 | | |
29 | | namespace doris { |
30 | | |
31 | | struct NameDomain { |
32 | | static constexpr auto name = "domain"; |
33 | | }; |
34 | | using FunctionDomain = |
35 | | FunctionStringToString<ExtractSubstringImpl<ExtractDomain<false>>, NameDomain>; |
36 | | |
37 | | struct NameDomainWithoutWWW { |
38 | | static constexpr auto name = "domain_without_www"; |
39 | | }; |
40 | | using FunctionDomainWithoutWWW = |
41 | | FunctionStringToString<ExtractSubstringImpl<ExtractDomain<true>>, NameDomainWithoutWWW>; |
42 | | |
43 | | struct NameProtocol { |
44 | | static constexpr auto name = "protocol"; |
45 | | }; |
46 | | using FunctionProtocol = |
47 | | FunctionStringToString<ExtractSubstringImpl<ExtractProtocol>, NameProtocol>; |
48 | | |
49 | | struct NameTopLevelDomain { |
50 | | static constexpr auto name = "top_level_domain"; |
51 | | }; |
52 | | using FunctionTopLevelDomain = |
53 | | FunctionStringToString<ExtractSubstringImpl<ExtractTopLevelDomain>, NameTopLevelDomain>; |
54 | | |
55 | | struct NameFirstSignificantSubdomain { |
56 | | static constexpr auto name = "first_significant_subdomain"; |
57 | | }; |
58 | | using FunctionFirstSignificantSubdomain = |
59 | | FunctionStringToString<ExtractSubstringImpl<ExtractFirstSignificantSubdomain>, |
60 | | NameFirstSignificantSubdomain>; |
61 | | |
62 | | struct NameCutToFirstSignificantSubdomain { |
63 | | static constexpr auto name = "cut_to_first_significant_subdomain"; |
64 | | }; |
65 | | using FunctionCutToFirstSignificantSubdomain = |
66 | | FunctionStringToString<ExtractSubstringImpl<CutToFirstSignificantSubdomain>, |
67 | | NameCutToFirstSignificantSubdomain>; |
68 | | |
69 | 8 | void register_function_url(SimpleFunctionFactory& factory) { |
70 | 8 | factory.register_function<FunctionDomain>(); |
71 | 8 | factory.register_function<FunctionDomainWithoutWWW>(); |
72 | 8 | factory.register_function<FunctionProtocol>(); |
73 | 8 | factory.register_function<FunctionTopLevelDomain>(); |
74 | 8 | factory.register_function<FunctionFirstSignificantSubdomain>(); |
75 | 8 | factory.register_function<FunctionCutToFirstSignificantSubdomain>(); |
76 | 8 | } |
77 | | |
78 | | } // namespace doris |