Merge pull request #30228 from kitaisreal/functions-json-updated

FunctionsJSON updated
This commit is contained in:
Maksim Kita 2021-10-16 02:06:34 +03:00 committed by GitHub
commit d3cb99701d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 19 deletions

View File

@ -1,3 +1,4 @@
#include <type_traits>
#include <boost/tti/has_member_function.hpp>
#include <base/range.h>
@ -38,7 +39,6 @@
#include <Functions/SimdJSONParser.h>
#include <Functions/RapidJSONParser.h>
#include <Functions/FunctionHelpers.h>
#include <Functions/FunctionsJSON.h>
#include <Interpreters/Context.h>
@ -58,6 +58,11 @@ namespace ErrorCodes
extern const int NUMBER_OF_ARGUMENTS_DOESNT_MATCH;
}
template <typename T>
concept HasIndexOperator = requires (T t)
{
t[0];
};
/// Functions to parse JSONs and extract values from it.
/// The first argument of all these functions gets a JSON,
@ -279,7 +284,7 @@ private:
return true;
}
if constexpr (FunctionJSONHelpersDetails::has_index_operator<typename JSONParser::Object>::value)
if constexpr (HasIndexOperator<typename JSONParser::Object>)
{
if (element.isObject())
{

View File

@ -1,17 +0,0 @@
#pragma once
#include <type_traits>
namespace DB
{
namespace FunctionJSONHelpersDetails
{
template <class T, class = void>
struct has_index_operator : std::false_type {};
template <class T>
struct has_index_operator<T, std::void_t<decltype(std::declval<T>()[0])>> : std::true_type {};
}
}