mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Attempt to remove a lot of trash
This commit is contained in:
parent
17e7c7a0cc
commit
c6d75d1486
@ -621,10 +621,11 @@ void ASTAlterQuery::formatQueryImpl(const FormatSettings & settings, FormatState
|
|||||||
{
|
{
|
||||||
if (database)
|
if (database)
|
||||||
{
|
{
|
||||||
settings.ostr << indent_str << backQuoteIfNeed(getDatabase());
|
database->formatImpl(settings, state, frame);
|
||||||
settings.ostr << ".";
|
settings.ostr << '.';
|
||||||
}
|
}
|
||||||
settings.ostr << indent_str << backQuoteIfNeed(getTable());
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
}
|
}
|
||||||
else if (alter_object == AlterObjectType::DATABASE && database)
|
else if (alter_object == AlterObjectType::DATABASE && database)
|
||||||
{
|
{
|
||||||
|
@ -49,10 +49,11 @@ protected:
|
|||||||
{
|
{
|
||||||
if (database)
|
if (database)
|
||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << backQuoteIfNeed(getDatabase()) << (settings.hilite ? hilite_none : "");
|
database->formatImpl(settings, state, frame);
|
||||||
settings.ostr << ".";
|
settings.ostr << '.';
|
||||||
}
|
}
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << indent_str << backQuoteIfNeed(getTable()) << (settings.hilite ? hilite_none : "");
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (partition)
|
if (partition)
|
||||||
|
@ -48,10 +48,11 @@ void ASTCreateIndexQuery::formatQueryImpl(const FormatSettings & settings, Forma
|
|||||||
{
|
{
|
||||||
if (database)
|
if (database)
|
||||||
{
|
{
|
||||||
settings.ostr << indent_str << backQuoteIfNeed(getDatabase());
|
database->formatImpl(settings, state, frame);
|
||||||
settings.ostr << ".";
|
settings.ostr << '.';
|
||||||
}
|
}
|
||||||
settings.ostr << indent_str << backQuoteIfNeed(getTable());
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
formatOnCluster(settings);
|
formatOnCluster(settings);
|
||||||
|
@ -298,8 +298,15 @@ void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
|
|||||||
<< (temporary ? "TEMPORARY " : "")
|
<< (temporary ? "TEMPORARY " : "")
|
||||||
<< what << " "
|
<< what << " "
|
||||||
<< (if_not_exists ? "IF NOT EXISTS " : "")
|
<< (if_not_exists ? "IF NOT EXISTS " : "")
|
||||||
<< (settings.hilite ? hilite_none : "")
|
<< (settings.hilite ? hilite_none : "");
|
||||||
<< (database ? backQuoteIfNeed(getDatabase()) + "." : "") << backQuoteIfNeed(getTable());
|
|
||||||
|
if (database)
|
||||||
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
settings.ostr << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
|
|
||||||
if (uuid != UUIDHelpers::Nil)
|
if (uuid != UUIDHelpers::Nil)
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " UUID " << (settings.hilite ? hilite_none : "")
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " UUID " << (settings.hilite ? hilite_none : "")
|
||||||
@ -331,8 +338,16 @@ void ASTCreateQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
|
|||||||
|
|
||||||
/// Always DICTIONARY
|
/// Always DICTIONARY
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << action << " DICTIONARY "
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << action << " DICTIONARY "
|
||||||
<< (if_not_exists ? "IF NOT EXISTS " : "") << (settings.hilite ? hilite_none : "")
|
<< (if_not_exists ? "IF NOT EXISTS " : "") << (settings.hilite ? hilite_none : "");
|
||||||
<< (database ? backQuoteIfNeed(getDatabase()) + "." : "") << backQuoteIfNeed(getTable());
|
|
||||||
|
if (database)
|
||||||
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
settings.ostr << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
|
|
||||||
if (uuid != UUIDHelpers::Nil)
|
if (uuid != UUIDHelpers::Nil)
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " UUID " << (settings.hilite ? hilite_none : "")
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " UUID " << (settings.hilite ? hilite_none : "")
|
||||||
<< quoteString(toString(uuid));
|
<< quoteString(toString(uuid));
|
||||||
|
@ -36,10 +36,11 @@ void ASTDeleteQuery::formatQueryImpl(const FormatSettings & settings, FormatStat
|
|||||||
|
|
||||||
if (database)
|
if (database)
|
||||||
{
|
{
|
||||||
settings.ostr << backQuoteIfNeed(getDatabase());
|
database->formatImpl(settings, state, frame);
|
||||||
settings.ostr << ".";
|
settings.ostr << '.';
|
||||||
}
|
}
|
||||||
settings.ostr << backQuoteIfNeed(getTable());
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
|
|
||||||
formatOnCluster(settings);
|
formatOnCluster(settings);
|
||||||
|
|
||||||
|
@ -43,10 +43,11 @@ void ASTDropIndexQuery::formatQueryImpl(const FormatSettings & settings, FormatS
|
|||||||
{
|
{
|
||||||
if (database)
|
if (database)
|
||||||
{
|
{
|
||||||
settings.ostr << indent_str << backQuoteIfNeed(getDatabase());
|
database->formatImpl(settings, state, frame);
|
||||||
settings.ostr << ".";
|
settings.ostr << '.';
|
||||||
}
|
}
|
||||||
settings.ostr << indent_str << backQuoteIfNeed(getTable());
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
formatOnCluster(settings);
|
formatOnCluster(settings);
|
||||||
|
@ -32,7 +32,7 @@ ASTPtr ASTDropQuery::clone() const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTDropQuery::formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const
|
void ASTDropQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "");
|
settings.ostr << (settings.hilite ? hilite_keyword : "");
|
||||||
if (kind == ASTDropQuery::Kind::Drop)
|
if (kind == ASTDropQuery::Kind::Drop)
|
||||||
@ -47,7 +47,6 @@ void ASTDropQuery::formatQueryImpl(const FormatSettings & settings, FormatState
|
|||||||
if (temporary)
|
if (temporary)
|
||||||
settings.ostr << "TEMPORARY ";
|
settings.ostr << "TEMPORARY ";
|
||||||
|
|
||||||
|
|
||||||
if (!table && database)
|
if (!table && database)
|
||||||
settings.ostr << "DATABASE ";
|
settings.ostr << "DATABASE ";
|
||||||
else if (is_dictionary)
|
else if (is_dictionary)
|
||||||
@ -66,9 +65,19 @@ void ASTDropQuery::formatQueryImpl(const FormatSettings & settings, FormatState
|
|||||||
settings.ostr << (settings.hilite ? hilite_none : "");
|
settings.ostr << (settings.hilite ? hilite_none : "");
|
||||||
|
|
||||||
if (!table && database)
|
if (!table && database)
|
||||||
settings.ostr << backQuoteIfNeed(getDatabase());
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
settings.ostr << (database ? backQuoteIfNeed(getDatabase()) + "." : "") << backQuoteIfNeed(getTable());
|
{
|
||||||
|
if (database)
|
||||||
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
settings.ostr << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
|
}
|
||||||
|
|
||||||
formatOnCluster(settings);
|
formatOnCluster(settings);
|
||||||
|
|
||||||
|
@ -68,8 +68,13 @@ void ASTInsertQuery::formatImpl(const FormatSettings & settings, FormatState & s
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_none : "")
|
if (database)
|
||||||
<< (database ? backQuoteIfNeed(getDatabase()) + "." : "") << backQuoteIfNeed(getTable());
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
settings.ostr << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (columns)
|
if (columns)
|
||||||
|
@ -7,8 +7,15 @@ namespace DB
|
|||||||
|
|
||||||
void ASTOptimizeQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
void ASTOptimizeQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << "OPTIMIZE TABLE " << (settings.hilite ? hilite_none : "")
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "OPTIMIZE TABLE " << (settings.hilite ? hilite_none : "");
|
||||||
<< (database ? backQuoteIfNeed(getDatabase()) + "." : "") << backQuoteIfNeed(getTable());
|
|
||||||
|
if (database)
|
||||||
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
settings.ostr << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
|
|
||||||
formatOnCluster(settings);
|
formatOnCluster(settings);
|
||||||
|
|
||||||
|
@ -64,11 +64,5 @@ void ASTQueryWithTableAndOutput::cloneTableOptions(ASTQueryWithTableAndOutput &
|
|||||||
cloned.children.push_back(cloned.table);
|
cloned.children.push_back(cloned.table);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ASTQueryWithTableAndOutput::formatHelper(const FormatSettings & settings, const char * name) const
|
|
||||||
{
|
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << name << " " << (settings.hilite ? hilite_none : "");
|
|
||||||
settings.ostr << (database ? backQuoteIfNeed(getDatabase()) + "." : "") << backQuoteIfNeed(getTable());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,9 +28,6 @@ public:
|
|||||||
void setTable(const String & name);
|
void setTable(const String & name);
|
||||||
|
|
||||||
void cloneTableOptions(ASTQueryWithTableAndOutput & cloned) const;
|
void cloneTableOptions(ASTQueryWithTableAndOutput & cloned) const;
|
||||||
|
|
||||||
protected:
|
|
||||||
void formatHelper(const FormatSettings & settings, const char * name) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -52,9 +49,19 @@ public:
|
|||||||
QueryKind getQueryKind() const override { return QueryKind::Show; }
|
QueryKind getQueryKind() const override { return QueryKind::Show; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
||||||
{
|
{
|
||||||
formatHelper(settings, temporary ? AstIDAndQueryNames::QueryTemporary : AstIDAndQueryNames::Query);
|
settings.ostr << (settings.hilite ? hilite_keyword : "")
|
||||||
|
<< (temporary ? AstIDAndQueryNames::QueryTemporary : AstIDAndQueryNames::Query)
|
||||||
|
<< " " << (settings.hilite ? hilite_none : "");
|
||||||
|
|
||||||
|
if (database)
|
||||||
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
settings.ostr << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,18 +19,29 @@ ASTPtr ASTUndropQuery::clone() const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ASTUndropQuery::formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const
|
void ASTUndropQuery::formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const
|
||||||
{
|
{
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "");
|
settings.ostr << (settings.hilite ? hilite_keyword : "");
|
||||||
settings.ostr << "UNDROP ";
|
settings.ostr << "UNDROP ";
|
||||||
settings.ostr << "TABLE ";
|
settings.ostr << "TABLE ";
|
||||||
settings.ostr << (settings.hilite ? hilite_none : "");
|
settings.ostr << (settings.hilite ? hilite_none : "");
|
||||||
|
|
||||||
assert (table);
|
chassert(table);
|
||||||
|
|
||||||
if (!database)
|
if (!database)
|
||||||
settings.ostr << backQuoteIfNeed(getTable());
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
settings.ostr << backQuoteIfNeed(getDatabase()) + "." << backQuoteIfNeed(getTable());
|
{
|
||||||
|
if (database)
|
||||||
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
settings.ostr << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
|
}
|
||||||
|
|
||||||
if (uuid != UUIDHelpers::Nil)
|
if (uuid != UUIDHelpers::Nil)
|
||||||
settings.ostr << (settings.hilite ? hilite_keyword : "") << " UUID " << (settings.hilite ? hilite_none : "")
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << " UUID " << (settings.hilite ? hilite_none : "")
|
||||||
|
@ -40,22 +40,29 @@ public:
|
|||||||
QueryKind getQueryKind() const override { return QueryKind::Create; }
|
QueryKind getQueryKind() const override { return QueryKind::Create; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void formatQueryImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override
|
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
|
||||||
{
|
{
|
||||||
std::string indent_str = s.one_line ? "" : std::string(4 * frame.indent, ' ');
|
std::string indent_str = settings.one_line ? "" : std::string(4 * frame.indent, ' ');
|
||||||
|
|
||||||
s.ostr << (s.hilite ? hilite_keyword : "") << "WATCH " << (s.hilite ? hilite_none : "")
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << "WATCH " << (settings.hilite ? hilite_none : "");
|
||||||
<< (database ? backQuoteIfNeed(getDatabase()) + "." : "") << backQuoteIfNeed(getTable());
|
|
||||||
|
if (database)
|
||||||
|
{
|
||||||
|
database->formatImpl(settings, state, frame);
|
||||||
|
settings.ostr << '.';
|
||||||
|
}
|
||||||
|
|
||||||
|
table->formatImpl(settings, state, frame);
|
||||||
|
|
||||||
if (is_watch_events)
|
if (is_watch_events)
|
||||||
{
|
{
|
||||||
s.ostr << " " << (s.hilite ? hilite_keyword : "") << "EVENTS" << (s.hilite ? hilite_none : "");
|
settings.ostr << " " << (settings.hilite ? hilite_keyword : "") << "EVENTS" << (settings.hilite ? hilite_none : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (limit_length)
|
if (limit_length)
|
||||||
{
|
{
|
||||||
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "LIMIT " << (s.hilite ? hilite_none : "");
|
settings.ostr << (settings.hilite ? hilite_keyword : "") << settings.nl_or_ws << indent_str << "LIMIT " << (settings.hilite ? hilite_none : "");
|
||||||
limit_length->formatImpl(s, state, frame);
|
limit_length->formatImpl(settings, state, frame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user