mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 23:21:59 +00:00
Fix according to review
This commit is contained in:
parent
7892e44467
commit
520c4a8f8a
@ -11,7 +11,7 @@
|
||||
#include <Functions/DummyJSONParser.h>
|
||||
#include <Functions/IFunction.h>
|
||||
#include <Functions/JSONPath/ASTs/ASTJSONPath.h>
|
||||
#include <Functions/JSONPath/Generators/GeneratorJSONPath.h>
|
||||
#include <Functions/JSONPath/Generator/GeneratorJSONPath.h>
|
||||
#include <Functions/JSONPath/Parsers/ParserJSONPath.h>
|
||||
#include <Functions/RapidJSONParser.h>
|
||||
#include <Functions/SimdJSONParser.h>
|
||||
@ -257,6 +257,8 @@ public:
|
||||
else if (status == VisitorStatus::Error)
|
||||
{
|
||||
/// ON ERROR
|
||||
/// Here it is possible to handle errors with ON ERROR (as described in ISO/IEC TR 19075-6),
|
||||
/// however this functionality is not implemented yet
|
||||
}
|
||||
current_element = root;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
add_subdirectory(ASTs)
|
||||
target_link_libraries(clickhouse_functions PRIVATE clickhouse_functions_jsonpath_asts)
|
||||
|
||||
add_subdirectory(Generators)
|
||||
target_link_libraries(clickhouse_functions PRIVATE clickhouse_functions_jsonpath_generators)
|
||||
add_subdirectory(Generator)
|
||||
target_link_libraries(clickhouse_functions PRIVATE clickhouse_functions_jsonpath_generator)
|
||||
|
||||
add_subdirectory(Parsers)
|
||||
target_link_libraries(clickhouse_functions PRIVATE clickhouse_functions_jsonpath_parsers)
|
||||
|
8
src/Functions/JSONPath/Generator/CMakeLists.txt
Normal file
8
src/Functions/JSONPath/Generator/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
||||
include("${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake")
|
||||
add_headers_and_sources(clickhouse_functions_jsonpath_generator .)
|
||||
add_library(clickhouse_functions_jsonpath_generator ${clickhouse_functions_jsonpath_generator_sources} ${clickhouse_functions_jsonpath_generator_headers})
|
||||
target_link_libraries(clickhouse_functions_jsonpath_generator PRIVATE dbms)
|
||||
|
||||
if (STRIP_DEBUG_SYMBOLS_FUNCTIONS)
|
||||
target_compile_options(clickhouse_functions_jsonpath_generator PRIVATE "-g0")
|
||||
endif()
|
@ -1,11 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <Functions/JSONPath/Generators/IGenerator.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorJSONPathMemberAccess.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorJSONPathRange.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorJSONPathRoot.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorJSONPathStar.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorStatus.h>
|
||||
#include <Functions/JSONPath/Generator/IGenerator.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorJSONPathMemberAccess.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorJSONPathRange.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorJSONPathRoot.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorJSONPathStar.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorStatus.h>
|
||||
|
||||
#include <Functions/JSONPath/ASTs/ASTJSONPath.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Functions/JSONPath/Generators/IGenerator_fwd.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorStatus.h>
|
||||
#include <Functions/JSONPath/Generator/IGenerator_fwd.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorStatus.h>
|
||||
#include <Parsers/IAST.h>
|
||||
|
||||
namespace DB
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Functions/JSONPath/Generators/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generator/IVisitor.h>
|
||||
|
||||
namespace DB
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Functions/JSONPath/Generators/VisitorStatus.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorStatus.h>
|
||||
|
||||
namespace DB
|
||||
{
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Functions/JSONPath/ASTs/ASTJSONPathMemberAccess.h>
|
||||
#include <Functions/JSONPath/Generators/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorStatus.h>
|
||||
#include <Functions/JSONPath/Generator/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorStatus.h>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
@ -25,19 +25,17 @@ public:
|
||||
|
||||
VisitorStatus visit(typename JSONParser::Element & element) override
|
||||
{
|
||||
this->setExhausted(true);
|
||||
if (!element.isObject())
|
||||
{
|
||||
this->setExhausted(true);
|
||||
return VisitorStatus::Error;
|
||||
}
|
||||
typename JSONParser::Element result;
|
||||
if (!element.getObject().find(std::string_view(member_access_ptr->member_name), result))
|
||||
{
|
||||
this->setExhausted(true);
|
||||
return VisitorStatus::Error;
|
||||
}
|
||||
apply(element);
|
||||
this->setExhausted(true);
|
||||
return VisitorStatus::Ok;
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Functions/JSONPath/ASTs/ASTJSONPathRange.h>
|
||||
#include <Functions/JSONPath/Generators/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorStatus.h>
|
||||
#include <Functions/JSONPath/Generator/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorStatus.h>
|
||||
|
||||
namespace DB
|
||||
{
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Functions/JSONPath/ASTs/ASTJSONPathRoot.h>
|
||||
#include <Functions/JSONPath/Generators/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorStatus.h>
|
||||
#include <Functions/JSONPath/Generator/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorStatus.h>
|
||||
|
||||
namespace DB
|
||||
{
|
@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <Functions/JSONPath/ASTs/ASTJSONPathStar.h>
|
||||
#include <Functions/JSONPath/Generators/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generators/VisitorStatus.h>
|
||||
#include <Functions/JSONPath/Generator/IVisitor.h>
|
||||
#include <Functions/JSONPath/Generator/VisitorStatus.h>
|
||||
|
||||
namespace DB
|
||||
{
|
@ -1,8 +0,0 @@
|
||||
include("${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake")
|
||||
add_headers_and_sources(clickhouse_functions_jsonpath_generators .)
|
||||
add_library(clickhouse_functions_jsonpath_generators ${clickhouse_functions_jsonpath_generators_sources} ${clickhouse_functions_jsonpath_generators_headers})
|
||||
target_link_libraries(clickhouse_functions_jsonpath_generators PRIVATE dbms)
|
||||
|
||||
if (STRIP_DEBUG_SYMBOLS_FUNCTIONS)
|
||||
target_compile_options(clickhouse_functions_jsonpath_generators PRIVATE "-g0")
|
||||
endif()
|
@ -36,11 +36,7 @@ bool ParserJSONPathMemberAccess::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
|
||||
auto member_access = std::make_shared<ASTJSONPathMemberAccess>();
|
||||
node = member_access;
|
||||
if (!tryGetIdentifierNameInto(member_name, member_access->member_name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return tryGetIdentifierNameInto(member_name, member_access->member_name);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -9,9 +9,6 @@ class ParserJSONPathQuery : public IParserBase
|
||||
{
|
||||
protected:
|
||||
const char * getName() const override { return "ParserJSONPathQuery"; }
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
||||
|
||||
private:
|
||||
/// backlog: strict or lax mode
|
||||
bool parseImpl(Pos & pos, ASTPtr & query, Expected & expected) override;
|
||||
};
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ null
|
||||
[["world","world2"]]
|
||||
[{"world":"!"}]
|
||||
|
||||
[0, 1, 4, 0, -1, -4]
|
||||
|
||||
--JSON_EXISTS--
|
||||
1
|
||||
|
@ -21,6 +21,7 @@ SELECT JSON_QUERY('$.hello', '{"hello":["world","world2"]}');
|
||||
SELECT JSON_QUERY('$.hello', '{"hello":{"world":"!"}}');
|
||||
SELECT JSON_QUERY('$.hello', '{hello:{"world":"!"}}}'); -- invalid json => default value (empty string)
|
||||
SELECT JSON_QUERY('$.hello', '');
|
||||
SELECT JSON_QUERY('$.array[*][0 to 2, 4]', '{"array":[[0, 1, 2, 3, 4, 5], [0, -1, -2, -3, -4, -5]]}');
|
||||
|
||||
SELECT '--JSON_EXISTS--';
|
||||
SELECT JSON_EXISTS('$', '{"hello":1}');
|
||||
|
Loading…
Reference in New Issue
Block a user