ClickHouse/src/Parsers/ASTFunctionWithKeyValueArguments.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

73 lines
1.9 KiB
C++
Raw Normal View History

2019-10-01 14:54:28 +00:00
#pragma once
#include <Parsers/IAST.h>
2021-10-02 07:13:14 +00:00
#include <base/types.h>
2019-10-01 14:54:28 +00:00
namespace DB
{
2019-10-08 13:26:15 +00:00
/// Pair with name and value in lisp programming langugate style. It contain
/// string as key, but value either can be literal or list of
/// pairs.
2019-10-01 14:54:28 +00:00
class ASTPair : public IAST
{
public:
2019-10-08 13:26:15 +00:00
/// Name or key of pair
2019-10-01 14:54:28 +00:00
String first;
2019-10-08 13:26:15 +00:00
/// Value of pair, which can be also list of pairs
2020-08-05 21:53:35 +00:00
IAST * second = nullptr;
2019-10-08 13:26:15 +00:00
/// Value is closed in brackets (HOST '127.0.0.1')
2019-10-08 09:47:17 +00:00
bool second_with_brackets;
2019-10-01 14:54:28 +00:00
2021-03-24 18:36:31 +00:00
explicit ASTPair(bool second_with_brackets_)
2019-10-08 09:47:17 +00:00
: second_with_brackets(second_with_brackets_)
{
}
2019-10-01 14:54:28 +00:00
String getID(char delim) const override;
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
2022-11-14 18:28:19 +00:00
bool hasSecretParts() const override;
2020-08-20 02:01:40 +00:00
2023-11-10 12:15:23 +00:00
void updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const override;
2023-03-11 19:16:06 +00:00
void forEachPointerToChild(std::function<void(void**)> f) override
{
f(reinterpret_cast<void **>(&second));
}
2019-10-01 14:54:28 +00:00
};
2019-10-08 13:26:15 +00:00
/// Function with key-value arguments is a function which arguments consist of
/// pairs (see above). For example:
/// ->Pair with list of pairs as value<-
/// SOURCE(USER 'clickhouse' PORT 9000 REPLICA(HOST '127.0.0.1' PRIORITY 1) TABLE 'some_table')
2019-10-01 14:54:28 +00:00
class ASTFunctionWithKeyValueArguments : public IAST
{
public:
2019-10-08 13:26:15 +00:00
/// Name of function
2019-10-01 14:54:28 +00:00
String name;
2019-10-08 13:26:15 +00:00
/// Expression list
2019-10-01 14:54:28 +00:00
ASTPtr elements;
/// Has brackets around arguments
bool has_brackets;
2021-03-24 18:36:31 +00:00
explicit ASTFunctionWithKeyValueArguments(bool has_brackets_ = true)
: has_brackets(has_brackets_)
{
}
2019-10-01 14:54:28 +00:00
String getID(char delim) const override;
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
2020-08-20 02:01:40 +00:00
2023-11-10 12:15:23 +00:00
void updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const override;
2019-10-01 14:54:28 +00:00
};
}