summaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Functions/JSONPath/Parsers/ParserJSONPathMemberAccess.cpp
diff options
context:
space:
mode:
authorAlexSm <[email protected]>2024-01-04 15:09:05 +0100
committerGitHub <[email protected]>2024-01-04 15:09:05 +0100
commitdab291146f6cd7d35684e3a1150e5bb1c412982c (patch)
tree36ef35f6cacb6432845a4a33f940c95871036b32 /contrib/clickhouse/src/Functions/JSONPath/Parsers/ParserJSONPathMemberAccess.cpp
parent63660ad5e7512029fd0218e7a636580695a24e1f (diff)
Library import 5, delete go dependencies (#832)
* Library import 5, delete go dependencies * Fix yt client
Diffstat (limited to 'contrib/clickhouse/src/Functions/JSONPath/Parsers/ParserJSONPathMemberAccess.cpp')
-rw-r--r--contrib/clickhouse/src/Functions/JSONPath/Parsers/ParserJSONPathMemberAccess.cpp85
1 files changed, 0 insertions, 85 deletions
diff --git a/contrib/clickhouse/src/Functions/JSONPath/Parsers/ParserJSONPathMemberAccess.cpp b/contrib/clickhouse/src/Functions/JSONPath/Parsers/ParserJSONPathMemberAccess.cpp
deleted file mode 100644
index 141f25bfe4c..00000000000
--- a/contrib/clickhouse/src/Functions/JSONPath/Parsers/ParserJSONPathMemberAccess.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-#include <Functions/JSONPath/ASTs/ASTJSONPathMemberAccess.h>
-#include <Functions/JSONPath/Parsers/ParserJSONPathMemberAccess.h>
-
-#include <Parsers/ASTIdentifier.h>
-#include <Parsers/ASTIdentifier_fwd.h>
-#include <Parsers/ExpressionElementParsers.h>
-#include <Parsers/Lexer.h>
-#include <Common/StringUtils/StringUtils.h>
-
-namespace DB
-{
-/**
- *
- * @param pos token iterator
- * @param node node of ASTJSONPathMemberAccess
- * @param expected stuff for logging
- * @return was parse successful
- */
-bool ParserJSONPathMemberAccess::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
-{
- // There's a special case, that a path member can begin with number
- // some invalid cases as following
- // - ".123" is parsed as a number, not a dot and a number
- // - ".123abc" is parsed as two parts, a number ".123" and a token "abc"
- // - ".abc" is parsed as two parts. a dot and a token "abc"
- // "$..123abc" is parsed into three parts, ".", ".123" and "abc"
- if (pos->type != TokenType::Dot && pos->type != TokenType::Number)
- return false;
- if (pos->type != TokenType::Number)
- {
- ++pos;
- // Check the case "$..123abc"
- if (pos->type == TokenType::Number)
- {
- return false;
- }
- }
-
- ASTPtr member_name;
-
- if (pos->type == TokenType::Number)[[unlikely]]
- {
- for (const auto * c = pos->begin; c != pos->end; ++c)
- {
- if (*c == '.' && c == pos->begin)
- continue;
- if (!isNumericASCII(*c))
- {
- return false;
- }
- }
- const auto * last_begin = *pos->begin == '.' ? pos->begin + 1 : pos->begin;
- const auto * last_end = pos->end;
- ++pos;
-
- if (pos.isValid() && pos->type == TokenType::BareWord && pos->begin == last_end)
- {
- member_name = std::make_shared<ASTIdentifier>(String(last_begin, pos->end));
- ++pos;
- }
- else if (!pos.isValid() && pos->type == TokenType::EndOfStream)
- {
- member_name = std::make_shared<ASTIdentifier>(String(last_begin, last_end));
- }
- else
- {
- return false;
- }
- }
- else
- {
- if (pos->type != TokenType::BareWord && pos->type != TokenType::QuotedIdentifier)
- return false;
-
- ParserIdentifier name_p;
- if (!name_p.parse(pos, member_name, expected))
- return false;
- }
-
- auto member_access = std::make_shared<ASTJSONPathMemberAccess>();
- node = member_access;
- return tryGetIdentifierNameInto(member_name, member_access->member_name);
-}
-
-}