2019-07-12 11:17:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <Parsers/IAST.h>
|
2019-07-16 20:05:00 +00:00
|
|
|
|
2019-07-12 11:17:38 +00:00
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2019-07-16 20:05:00 +00:00
|
|
|
class WriteBuffer;
|
|
|
|
|
|
|
|
/** SELECT COLUMNS('regexp') is expanded to multiple columns like * (asterisk).
|
2020-08-29 05:33:46 +00:00
|
|
|
* Optional transformers can be attached to further manipulate these expanded columns.
|
2019-07-16 20:05:00 +00:00
|
|
|
*/
|
2022-04-19 17:22:04 +00:00
|
|
|
class ASTColumnsRegexpMatcher : public IAST
|
2019-07-12 11:17:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-04-19 17:22:04 +00:00
|
|
|
String getID(char) const override { return "ColumnsRegexpMatcher"; }
|
2019-07-12 11:17:38 +00:00
|
|
|
ASTPtr clone() const override;
|
2019-07-16 20:05:00 +00:00
|
|
|
|
2019-07-12 11:17:38 +00:00
|
|
|
void appendColumnName(WriteBuffer & ostr) const override;
|
2019-07-16 20:05:00 +00:00
|
|
|
void setPattern(String pattern);
|
2022-11-02 06:11:37 +00:00
|
|
|
const String & getPattern() const;
|
2023-11-10 12:15:23 +00:00
|
|
|
void updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const override;
|
2019-07-12 11:17:38 +00:00
|
|
|
|
2022-11-02 06:11:37 +00:00
|
|
|
ASTPtr expression;
|
|
|
|
ASTPtr transformers;
|
2019-07-12 11:17:38 +00:00
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
|
|
|
|
|
|
|
private:
|
2024-03-18 17:40:03 +00:00
|
|
|
String pattern;
|
2022-04-19 17:22:04 +00:00
|
|
|
};
|
2019-07-12 11:17:38 +00:00
|
|
|
|
2022-04-19 17:22:04 +00:00
|
|
|
/// 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;
|
|
|
|
|
2022-11-02 06:11:37 +00:00
|
|
|
ASTPtr expression;
|
2022-04-19 17:22:04 +00:00
|
|
|
ASTPtr column_list;
|
2022-11-02 06:11:37 +00:00
|
|
|
ASTPtr transformers;
|
2022-04-19 17:22:04 +00:00
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
2019-07-12 11:17:38 +00:00
|
|
|
};
|
|
|
|
|
2022-07-14 11:20:16 +00:00
|
|
|
/// 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;
|
2024-03-18 17:40:03 +00:00
|
|
|
void setPattern(String pattern_);
|
|
|
|
const String & getPattern() const;
|
2023-11-10 12:15:23 +00:00
|
|
|
void updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const override;
|
2022-07-14 11:20:16 +00:00
|
|
|
|
2022-11-02 06:11:37 +00:00
|
|
|
ASTPtr qualifier;
|
|
|
|
ASTPtr transformers;
|
2022-07-14 11:20:16 +00:00
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
|
|
|
|
|
|
|
private:
|
2024-03-18 17:40:03 +00:00
|
|
|
String pattern;
|
2022-07-14 11:20:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/// 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;
|
|
|
|
|
2022-11-02 06:11:37 +00:00
|
|
|
ASTPtr qualifier;
|
2022-07-14 11:20:16 +00:00
|
|
|
ASTPtr column_list;
|
2022-11-02 06:11:37 +00:00
|
|
|
ASTPtr transformers;
|
2022-07-14 11:20:16 +00:00
|
|
|
protected:
|
|
|
|
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
|
|
|
|
};
|
2019-07-12 11:17:38 +00:00
|
|
|
|
|
|
|
}
|