11#include < Common/FunctionDocumentation.h>
22
3+ #include < Common/Exception.h>
4+
5+ #include < unordered_map>
6+
37namespace DB
48{
59
10+ namespace ErrorCodes
11+ {
12+ extern const int LOGICAL_ERROR;
13+ }
14+
615std::string FunctionDocumentation::argumentsAsString () const
716{
817 std::string res;
@@ -28,4 +37,56 @@ std::string FunctionDocumentation::examplesAsString() const
2837 return res;
2938}
3039
40+ std::string FunctionDocumentation::categoryAsString () const
41+ {
42+ static const std::unordered_map<Category, std::string> category_to_string = {
43+ {Category::Unknown, " " }, // / Default enum value for default-constructed FunctionDocumentation objects. Be consistent with other default fields (empty).
44+ {Category::Arithmetic, " Arithmetic" },
45+ {Category::Array, " Arrays" },
46+ {Category::Bit, " Bit" },
47+ {Category::Bitmap, " Bitmap" },
48+ {Category::Comparison, " Comparison" },
49+ {Category::Conditional, " Conditional" },
50+ {Category::DateAndTime, " Dates and Times" },
51+ {Category::Dictionary, " Dictionary" },
52+ {Category::Distance, " Distance" },
53+ {Category::EmbeddedDictionary, " Embedded Dictionary" },
54+ {Category::Geo, " Geo" },
55+ {Category::Encoding, " Encoding" },
56+ {Category::Encryption, " Encryption" },
57+ {Category::File, " File" },
58+ {Category::Hash, " Hash" },
59+ {Category::IPAddress, " IP Address" },
60+ {Category::Introspection, " Introspection" },
61+ {Category::JSON, " JSON" },
62+ {Category::Logical, " Logical" },
63+ {Category::MachineLearning, " Machine Learning" },
64+ {Category::Map, " Map" },
65+ {Category::Mathematical, " Mathematical" },
66+ {Category::NLP, " Natural Language Processing" },
67+ {Category::Nullable, " Nullable" },
68+ {Category::Other, " Other" },
69+ {Category::RandomNumber, " Random Number" },
70+ {Category::Rounding, " Rounding" },
71+ {Category::StringReplacement, " String Replacement" },
72+ {Category::StringSearch, " String Search" },
73+ {Category::StringSplitting, " String Splitting" },
74+ {Category::String, " String" },
75+ {Category::TimeSeries, " Time Series" },
76+ {Category::TimeWindow, " Time Window" },
77+ {Category::Tuple, " Tuple" },
78+ {Category::TypeConversion, " Type Conversion" },
79+ {Category::ULID, " ULID" },
80+ {Category::URL, " URL" },
81+ {Category::UUID, " UUID" },
82+ {Category::UniqTheta, " UniqTheta" },
83+ {Category::TableFunction, " Table Functions" }
84+ };
85+
86+ if (auto it = category_to_string.find (category); it != category_to_string.end ())
87+ return it->second ;
88+ else
89+ throw Exception (ErrorCodes::LOGICAL_ERROR, " Category has no mapping to string" );
90+ }
91+
3192}
0 commit comments