1#pragma once
2
3#include <Parsers/IAST.h>
4
5
6namespace re2
7{
8 class RE2;
9}
10
11
12namespace DB
13{
14
15class WriteBuffer;
16
17namespace ErrorCodes
18{
19 extern const int CANNOT_COMPILE_REGEXP;
20}
21
22struct AsteriskSemantic;
23struct AsteriskSemanticImpl;
24
25
26/** SELECT COLUMNS('regexp') is expanded to multiple columns like * (asterisk).
27 */
28class ASTColumnsMatcher : public IAST
29{
30public:
31 String getID(char) const override { return "ColumnsMatcher"; }
32 ASTPtr clone() const override;
33
34 void appendColumnName(WriteBuffer & ostr) const override;
35 void setPattern(String pattern);
36 bool isColumnMatching(const String & column_name) const;
37
38protected:
39 void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
40
41private:
42 std::shared_ptr<re2::RE2> column_matcher;
43 String original_pattern;
44 std::shared_ptr<AsteriskSemanticImpl> semantic; /// pimpl
45
46 friend struct AsteriskSemantic;
47};
48
49
50}
51