2019-08-04 14:15:47 +00:00
|
|
|
#include <Functions/FunctionFactory.h>
|
|
|
|
#include <Functions/FunctionsVisitParam.h>
|
2020-03-29 17:04:16 +00:00
|
|
|
#include <Functions/FunctionsStringSearchToString.h>
|
2019-08-04 14:15:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
struct ExtractString
|
|
|
|
{
|
|
|
|
static void extract(const UInt8 * pos, const UInt8 * end, ColumnString::Chars & res_data)
|
|
|
|
{
|
|
|
|
size_t old_size = res_data.size();
|
|
|
|
ReadBufferFromMemory in(pos, end - pos);
|
|
|
|
if (!tryReadJSONStringInto(res_data, in))
|
|
|
|
res_data.resize(old_size);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct NameVisitParamExtractString { static constexpr auto name = "visitParamExtractString"; };
|
|
|
|
using FunctionVisitParamExtractString = FunctionsStringSearchToString<ExtractParamToStringImpl<ExtractString>, NameVisitParamExtractString>;
|
|
|
|
|
2021-04-01 20:07:01 +00:00
|
|
|
struct NameSimpleJSONExtractString { static constexpr auto name = "simpleJSONExtractString"; };
|
2021-03-30 16:25:56 +00:00
|
|
|
using FunctionSimpleJSONExtractString = FunctionsStringSearchToString<ExtractParamToStringImpl<ExtractString>, NameSimpleJSONExtractString>;
|
2019-08-04 14:15:47 +00:00
|
|
|
|
2022-07-04 07:01:39 +00:00
|
|
|
REGISTER_FUNCTION(VisitParamExtractString)
|
2019-08-04 14:15:47 +00:00
|
|
|
{
|
|
|
|
factory.registerFunction<FunctionVisitParamExtractString>();
|
2021-03-30 16:25:56 +00:00
|
|
|
factory.registerFunction<FunctionSimpleJSONExtractString>();
|
2019-08-04 14:15:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|