#pragma once #include 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 & 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 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 & getMatcher() const; void setPattern(String pattern, bool set_matcher = true); void setMatcher(std::shared_ptr 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 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; }; }