fix AST debug print with underline symbol

This commit is contained in:
chertus 2018-12-07 15:34:40 +03:00
parent 6fad51d642
commit 75af882cf3
43 changed files with 59 additions and 65 deletions

View File

@ -31,8 +31,6 @@
#include <Interpreters/ExternalDictionaries.h>
#include <Interpreters/Set.h>
#include <Interpreters/Join.h>
#include <Interpreters/TranslateQualifiedNamesVisitor.h>
#include <Interpreters/ExecuteScalarSubqueriesVisitor.h>
#include <AggregateFunctions/AggregateFunctionFactory.h>
#include <AggregateFunctions/parseAggregateFunctionParameters.h>
@ -62,11 +60,9 @@
#include <Interpreters/DatabaseAndTableWithAlias.h>
#include <Interpreters/QueryNormalizer.h>
#include <Interpreters/QueryAliasesVisitor.h>
#include <Interpreters/ActionsVisitor.h>
#include <Interpreters/ExternalTablesVisitor.h>
#include <Interpreters/GlobalSubqueriesVisitor.h>
#include <Interpreters/ArrayJoinedColumnsVisitor.h>
#include <Interpreters/RequiredSourceColumnsVisitor.h>
namespace DB

View File

@ -22,7 +22,7 @@ public:
Aliases & aliases;
};
static constexpr const char * label = __FILE__;
static constexpr const char * label = "QueryAliases";
static std::vector<ASTPtr> visit(ASTPtr & ast, Data & data);
static bool needChildVisit(ASTPtr & node, const ASTPtr & child);

View File

@ -46,7 +46,7 @@ namespace
{
using LogAST = DebugASTLog<false>; /// set to true to enable logs
using Aliases = std::unordered_map<String, ASTPtr>;
using Aliases = SyntaxAnalyzerResult::Aliases;
/// Add columns from storage to source_columns list.
void collectSourceColumns(ASTSelectQuery * select_query, const Context & context,

View File

@ -23,7 +23,7 @@ public:
const std::vector<DatabaseAndTableWithAlias> & tables;
};
static constexpr const char * label = __FILE__;
static constexpr const char * label = "TranslateQualifiedNames";
static std::vector<ASTPtr> visit(ASTPtr & ast, Data & data);
static bool needChildVisit(ASTPtr & node, const ASTPtr & child);

View File

@ -196,9 +196,9 @@ void ASTAlterCommandList::formatImpl(const FormatSettings & settings, FormatStat
/** Get the text that identifies this element. */
String ASTAlterQuery::getID() const
String ASTAlterQuery::getID(char delim) const
{
return "AlterQuery_" + database + "_" + table;
return "AlterQuery" + (delim + database) + delim + table;
}
ASTPtr ASTAlterQuery::clone() const

View File

@ -97,7 +97,7 @@ public:
/// To distinguish REPLACE and ATTACH PARTITION partition FROM db.table
bool replace = true;
String getID() const override { return "AlterCommand_" + std::to_string(static_cast<int>(type)); }
String getID(char delim) const override { return "AlterCommand" + (delim + std::to_string(static_cast<int>(type))); }
ASTPtr clone() const override;
@ -116,7 +116,7 @@ public:
children.push_back(command);
}
String getID() const override { return "AlterCommandList"; }
String getID(char) const override { return "AlterCommandList"; }
ASTPtr clone() const override;
@ -129,7 +129,7 @@ class ASTAlterQuery : public ASTQueryWithTableAndOutput, public ASTQueryWithOnCl
public:
ASTAlterCommandList * command_list = nullptr;
String getID() const override;
String getID(char) const override;
ASTPtr clone() const override;

View File

@ -12,7 +12,7 @@ public:
String column_name;
ASTPtr expression;
String getID() const override { return "Assignment_" + column_name; }
String getID(char delim) const override { return "Assignment" + (delim + column_name); }
ASTPtr clone() const override
{

View File

@ -9,7 +9,7 @@ namespace DB
class ASTAsterisk : public IAST
{
public:
String getID() const override { return "Asterisk"; }
String getID(char) const override { return "Asterisk"; }
ASTPtr clone() const override;
void appendColumnName(WriteBuffer & ostr) const override;

View File

@ -8,7 +8,7 @@ namespace DB
struct ASTCheckQuery : public ASTQueryWithTableAndOutput
{
/** Get the text that identifies this element. */
String getID() const override { return ("CheckQuery_" + database + "_" + table); }
String getID(char delim) const override { return "CheckQuery" + (delim + database) + delim + table; }
ASTPtr clone() const override
{

View File

@ -17,7 +17,7 @@ public:
ASTPtr default_expression;
ASTPtr comment;
String getID() const override { return "ColumnDeclaration_" + name; }
String getID(char delim) const override { return "ColumnDeclaration" + (delim + name); }
ASTPtr clone() const override
{

View File

@ -21,7 +21,7 @@ public:
IAST * sample_by = nullptr;
ASTSetQuery * settings = nullptr;
String getID() const override { return "Storage definition"; }
String getID(char) const override { return "Storage definition"; }
ASTPtr clone() const override
{
@ -99,7 +99,7 @@ public:
ASTSelectWithUnionQuery * select = nullptr;
/** Get the text that identifies this element. */
String getID() const override { return (attach ? "AttachQuery_" : "CreateQuery_") + database + "_" + table; }
String getID(char delim) const override { return (attach ? "AttachQuery" : "CreateQuery") + (delim + database) + delim + table; }
ASTPtr clone() const override
{

View File

@ -10,14 +10,14 @@ namespace ErrorCodes
}
String ASTDropQuery::getID() const
String ASTDropQuery::getID(char delim) const
{
if (kind == ASTDropQuery::Kind::Drop)
return "DropQuery_" + database + "_" + table;
return "DropQuery" + (delim + database) + delim + table;
else if (kind == ASTDropQuery::Kind::Detach)
return "DetachQuery_" + database + "_" + table;
return "DetachQuery" + (delim + database) + delim + table;
else if (kind == ASTDropQuery::Kind::Truncate)
return "TruncateQuery_" + database + "_" + table;
return "TruncateQuery" + (delim + database) + delim + table;
else
throw Exception("Not supported kind of drop query.", ErrorCodes::SYNTAX_ERROR);
}

View File

@ -23,7 +23,7 @@ public:
bool if_exists{false};
/** Get the text that identifies this element. */
String getID() const override;
String getID(char) const override;
ASTPtr clone() const override;
ASTPtr getRewrittenASTWithoutOnCluster(const std::string & new_database) const override

View File

@ -20,7 +20,7 @@ public:
: kind(kind_)
{}
String getID() const override { return "Explain_" + toString(kind); }
String getID(char delim) const override { return "Explain" + (delim + toString(kind)); }
ASTPtr clone() const override { return std::make_shared<ASTExplainQuery>(*this); }
protected:

View File

@ -11,7 +11,7 @@ namespace DB
class ASTExpressionList : public IAST
{
public:
String getID() const override { return "ExpressionList"; }
String getID(char ) const override { return "ExpressionList"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;

View File

@ -36,9 +36,9 @@ void ASTFunction::appendColumnNameImpl(WriteBuffer & ostr) const
}
/** Get the text that identifies this element. */
String ASTFunction::getID() const
String ASTFunction::getID(char delim) const
{
return "Function_" + name;
return "Function" + (delim + name);
}
ASTPtr ASTFunction::clone() const

View File

@ -19,7 +19,7 @@ public:
public:
/** Get text identifying the AST node. */
String getID() const override;
String getID(char delim) const override;
ASTPtr clone() const override;

View File

@ -24,7 +24,7 @@ public:
: name(name_), kind(kind_) { range = StringRange(name.data(), name.data() + name.size()); }
/** Get the text that identifies this element. */
String getID() const override { return "Identifier_" + name; }
String getID(char delim) const override { return "Identifier" + (delim + name); }
ASTPtr clone() const override { return std::make_shared<ASTIdentifier>(*this); }

View File

@ -27,7 +27,7 @@ public:
const char * end = nullptr;
/** Get the text that identifies this element. */
String getID() const override { return "InsertQuery_" + database + "_" + table; }
String getID(char delim) const override { return "InsertQuery" + (delim + database) + delim + table; }
ASTPtr clone() const override
{

View File

@ -3,9 +3,9 @@
namespace DB
{
String ASTKillQueryQuery::getID() const
String ASTKillQueryQuery::getID(char delim) const
{
return "KillQueryQuery_" + (where_expression ? where_expression->getID() : "") + "_" + String(sync ? "SYNC" : "ASYNC");
return String("KillQueryQuery") + delim + (where_expression ? where_expression->getID() : "") + delim + String(sync ? "SYNC" : "ASYNC");
}
void ASTKillQueryQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const

View File

@ -20,7 +20,7 @@ public:
return clone;
}
String getID() const override;
String getID(char) const override;
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;

View File

@ -18,7 +18,7 @@ public:
ASTLiteral(const Field & value_) : value(value_) {}
/** Get the text that identifies this element. */
String getID() const override { return "Literal_" + applyVisitor(FieldVisitorDump(), value); }
String getID(char delim) const override { return "Literal" + (delim + applyVisitor(FieldVisitorDump(), value)); }
ASTPtr clone() const override { return std::make_shared<ASTLiteral>(*this); }

View File

@ -17,7 +17,7 @@ public:
ASTPtr type;
/** Get the text that identifies this element. */
String getID() const override { return "NameTypePair_" + name; }
String getID(char delim) const override { return "NameTypePair" + (delim + name); }
ASTPtr clone() const override
{

View File

@ -21,8 +21,10 @@ public:
bool deduplicate;
/** Get the text that identifies this element. */
String getID() const override
{ return "OptimizeQuery_" + database + "_" + table + (final ? "_final" : "") + (deduplicate ? "_deduplicate" : ""); }
String getID(char delim) const override
{
return "OptimizeQuery" + (delim + database) + delim + table + (final ? "_final" : "") + (deduplicate ? "_deduplicate" : "");
}
ASTPtr clone() const override
{

View File

@ -27,10 +27,7 @@ public:
{
}
String getID() const override
{
return "OrderByElement";
}
String getID(char) const override { return "OrderByElement"; }
ASTPtr clone() const override
{

View File

@ -4,12 +4,12 @@
namespace DB
{
String ASTPartition::getID() const
String ASTPartition::getID(char delim) const
{
if (value)
return "Partition";
else
return "Partition_ID_" + id;
return "Partition_ID" + (delim + id);
}
ASTPtr ASTPartition::clone() const

View File

@ -17,7 +17,7 @@ public:
String id;
String getID() const override;
String getID(char) const override;
ASTPtr clone() const override;
protected:

View File

@ -12,7 +12,7 @@ namespace DB
class ASTQualifiedAsterisk : public IAST
{
public:
String getID() const override { return "QualifiedAsterisk"; }
String getID(char) const override { return "QualifiedAsterisk"; }
ASTPtr clone() const override
{
auto clone = std::make_shared<ASTQualifiedAsterisk>(*this);

View File

@ -34,7 +34,7 @@ template <typename ASTIDAndQueryNames>
class ASTQueryWithOutputImpl : public ASTQueryWithOutput
{
public:
String getID() const override { return ASTIDAndQueryNames::ID; }
String getID(char) const override { return ASTIDAndQueryNames::ID; }
ASTPtr clone() const override
{

View File

@ -30,7 +30,7 @@ template <typename AstIDAndQueryNames>
class ASTQueryWithTableAndOutputImpl : public ASTQueryWithTableAndOutput
{
public:
String getID() const override { return AstIDAndQueryNames::ID + ("_" + database) + "_" + table; }
String getID(char delim) const override { return AstIDAndQueryNames::ID + (delim + database) + delim + table; }
ASTPtr clone() const override
{

View File

@ -29,7 +29,7 @@ public:
Elements elements;
/** Get the text that identifies this element. */
String getID() const override { return "Rename"; }
String getID(char) const override { return "Rename"; }
ASTPtr clone() const override
{

View File

@ -28,7 +28,7 @@ public:
ASTSampleRatio(Rational & ratio_) : ratio(ratio_) {}
String getID() const override { return "SampleRatio_" + toString(ratio); }
String getID(char delim) const override { return "SampleRatio" + (delim + toString(ratio)); }
ASTPtr clone() const override { return std::make_shared<ASTSampleRatio>(*this); }

View File

@ -16,7 +16,7 @@ class ASTSelectQuery : public IAST
{
public:
/** Get the text that identifies this element. */
String getID() const override { return "SelectQuery"; }
String getID(char) const override { return "SelectQuery"; }
ASTPtr clone() const override;

View File

@ -12,7 +12,7 @@ namespace DB
class ASTSelectWithUnionQuery : public ASTQueryWithOutput
{
public:
String getID() const override { return "SelectWithUnionQuery"; }
String getID(char) const override { return "SelectWithUnionQuery"; }
ASTPtr clone() const override;
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;

View File

@ -26,7 +26,7 @@ public:
Changes changes;
/** Get the text that identifies this element. */
String getID() const override { return "Set"; }
String getID(char) const override { return "Set"; }
ASTPtr clone() const override { return std::make_shared<ASTSetQuery>(*this); }

View File

@ -21,7 +21,7 @@ public:
bool not_like{false};
/** Get the text that identifies this element. */
String getID() const override { return "ShowTables"; }
String getID(char) const override { return "ShowTables"; }
ASTPtr clone() const override
{

View File

@ -13,7 +13,7 @@ class ASTSubquery : public ASTWithAlias
{
public:
/** Get the text that identifies this element. */
String getID() const override { return "Subquery"; }
String getID(char) const override { return "Subquery"; }
ASTPtr clone() const override
{

View File

@ -51,7 +51,7 @@ public:
String target_database;
String target_table;
String getID() const override { return "SYSTEM query"; }
String getID(char) const override { return "SYSTEM query"; }
ASTPtr clone() const override { return std::make_shared<ASTSystemQuery>(*this); }

View File

@ -53,7 +53,7 @@ struct ASTTableExpression : public IAST
ASTPtr sample_offset;
using IAST::IAST;
String getID() const override { return "TableExpression"; }
String getID(char) const override { return "TableExpression"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
};
@ -98,7 +98,7 @@ struct ASTTableJoin : public IAST
ASTPtr on_expression;
using IAST::IAST;
String getID() const override { return "TableJoin"; }
String getID(char) const override { return "TableJoin"; }
ASTPtr clone() const override;
void formatImplBeforeTable(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const;
@ -122,7 +122,7 @@ struct ASTArrayJoin : public IAST
ASTPtr expression_list;
using IAST::IAST;
String getID() const override { return "ArrayJoin"; }
String getID(char) const override { return "ArrayJoin"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
};
@ -139,7 +139,7 @@ struct ASTTablesInSelectQueryElement : public IAST
ASTPtr array_join; /// Arrays to JOIN.
using IAST::IAST;
String getID() const override { return "TablesInSelectQueryElement"; }
String getID(char) const override { return "TablesInSelectQueryElement"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
};
@ -149,7 +149,7 @@ struct ASTTablesInSelectQueryElement : public IAST
struct ASTTablesInSelectQuery : public IAST
{
using IAST::IAST;
String getID() const override { return "TablesInSelectQuery"; }
String getID(char) const override { return "TablesInSelectQuery"; }
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override;
};

View File

@ -15,7 +15,7 @@ public:
String database;
/** Get the text that identifies this element. */
String getID() const override { return "UseQuery_" + database; }
String getID(char delim) const override { return "UseQuery" + (delim + database); }
ASTPtr clone() const override { return std::make_shared<ASTUseQuery>(*this); }

View File

@ -64,8 +64,7 @@ private:
String nodeId() const
{
String id = ast.getID();
std::replace(id.begin(), id.end(), '_', ' ');
String id = ast.getID(' ');
return id;
}

View File

@ -67,7 +67,7 @@ public:
}
/** Get the text that identifies this element. */
virtual String getID() const = 0;
virtual String getID(char delimiter = '_') const = 0;
ASTPtr ptr() { return shared_from_this(); }

View File

@ -48,7 +48,7 @@ class ASTDescribeQuery : public ASTQueryWithOutput
public:
ASTPtr table_expression;
String getID() const override { return "DescribeQuery"; }
String getID(char) const override { return "DescribeQuery"; }
ASTPtr clone() const override
{