mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-01 03:52:15 +00:00
4930683aa8
This reverts commit 2958c5f0f1
.
96 lines
2.7 KiB
C++
96 lines
2.7 KiB
C++
#pragma once
|
|
|
|
#include <Parsers/IAST.h>
|
|
|
|
namespace re2
|
|
{
|
|
class RE2;
|
|
}
|
|
|
|
|
|
namespace DB
|
|
{
|
|
|
|
class WriteBuffer;
|
|
|
|
/** SELECT COLUMNS('regexp') is expanded to multiple columns like * (asterisk).
|
|
* Optional transformers can be attached to further manipulate these expanded columns.
|
|
*/
|
|
class ASTColumnsRegexpMatcher : public IAST
|
|
{
|
|
public:
|
|
String getID(char) const override { return "ColumnsRegexpMatcher"; }
|
|
ASTPtr clone() const override;
|
|
|
|
void appendColumnName(WriteBuffer & ostr) const override;
|
|
void setPattern(String pattern);
|
|
const String & getPattern() const;
|
|
const std::shared_ptr<re2::RE2> & getMatcher() const;
|
|
bool isColumnMatching(const String & column_name) const;
|
|
void updateTreeHashImpl(SipHash & hash_state) const override;
|
|
|
|
ASTPtr expression;
|
|
ASTPtr transformers;
|
|
protected:
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
|
|
|
private:
|
|
std::shared_ptr<re2::RE2> column_matcher;
|
|
String original_pattern;
|
|
};
|
|
|
|
/// Same as the above but use a list of column names to do matching.
|
|
class ASTColumnsListMatcher : public IAST
|
|
{
|
|
public:
|
|
String getID(char) const override { return "ColumnsListMatcher"; }
|
|
ASTPtr clone() const override;
|
|
void appendColumnName(WriteBuffer & ostr) const override;
|
|
|
|
ASTPtr expression;
|
|
ASTPtr column_list;
|
|
ASTPtr transformers;
|
|
protected:
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
|
};
|
|
|
|
/// Same as ASTColumnsRegexpMatcher. Qualified identifier is first child.
|
|
class ASTQualifiedColumnsRegexpMatcher : public IAST
|
|
{
|
|
public:
|
|
String getID(char) const override { return "QualifiedColumnsRegexpMatcher"; }
|
|
ASTPtr clone() const override;
|
|
|
|
void appendColumnName(WriteBuffer & ostr) const override;
|
|
const std::shared_ptr<re2::RE2> & getMatcher() const;
|
|
void setPattern(String pattern, bool set_matcher = true);
|
|
void setMatcher(std::shared_ptr<re2::RE2> matcher);
|
|
void updateTreeHashImpl(SipHash & hash_state) const override;
|
|
|
|
ASTPtr qualifier;
|
|
ASTPtr transformers;
|
|
protected:
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
|
|
|
private:
|
|
std::shared_ptr<re2::RE2> column_matcher;
|
|
String original_pattern;
|
|
};
|
|
|
|
/// Same as ASTColumnsListMatcher. Qualified identifier is first child.
|
|
class ASTQualifiedColumnsListMatcher : public IAST
|
|
{
|
|
public:
|
|
String getID(char) const override { return "QualifiedColumnsListMatcher"; }
|
|
ASTPtr clone() const override;
|
|
void appendColumnName(WriteBuffer & ostr) const override;
|
|
|
|
ASTPtr qualifier;
|
|
ASTPtr column_list;
|
|
ASTPtr transformers;
|
|
protected:
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
|
};
|
|
|
|
}
|