2012-08-22 18:46:09 +00:00
|
|
|
#pragma once
|
|
|
|
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ASTWithAlias.h>
|
2012-08-22 18:46:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** SELECT subquery
|
2012-08-22 18:46:09 +00:00
|
|
|
*/
|
2015-07-26 07:55:48 +00:00
|
|
|
class ASTSubquery : public ASTWithAlias
|
2012-08-22 18:46:09 +00:00
|
|
|
{
|
|
|
|
public:
|
2021-01-13 14:28:36 +00:00
|
|
|
// Stored the name when the subquery is defined in WITH clause. For example:
|
|
|
|
// WITH (SELECT 1) AS a SELECT * FROM a AS b; cte_name will be `a`.
|
2023-11-10 12:15:23 +00:00
|
|
|
String cte_name;
|
2021-01-02 04:51:13 +00:00
|
|
|
|
2017-05-27 17:27:16 +00:00
|
|
|
/** Get the text that identifies this element. */
|
2018-12-07 12:34:40 +00:00
|
|
|
String getID(char) const override { return "Subquery"; }
|
2014-12-15 20:43:24 +00:00
|
|
|
|
|
|
|
ASTPtr clone() const override
|
|
|
|
{
|
2023-04-10 02:20:57 +00:00
|
|
|
auto clone = std::make_shared<ASTSubquery>(*this);
|
|
|
|
clone->cloneChildren();
|
|
|
|
return clone;
|
2014-12-15 20:43:24 +00:00
|
|
|
}
|
2012-08-22 23:09:26 +00:00
|
|
|
|
2024-02-18 04:38:34 +00:00
|
|
|
ASTSubquery() = default;
|
|
|
|
|
|
|
|
ASTSubquery(ASTPtr child)
|
|
|
|
{
|
|
|
|
children.emplace_back(std::move(child));
|
|
|
|
}
|
|
|
|
|
2023-11-10 12:15:23 +00:00
|
|
|
void updateTreeHashImpl(SipHash & hash_state, bool ignore_aliases) const override;
|
2022-06-14 13:42:30 +00:00
|
|
|
String getAliasOrColumnName() const override;
|
|
|
|
String tryGetAlias() const override;
|
2021-01-02 04:51:13 +00:00
|
|
|
|
2015-08-06 03:26:27 +00:00
|
|
|
protected:
|
2018-06-27 16:34:11 +00:00
|
|
|
void formatImplWithoutAlias(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
|
|
|
|
void appendColumnNameImpl(WriteBuffer & ostr) const override;
|
2012-08-22 18:46:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|