Fix even more trash

This commit is contained in:
Alexey Milovidov 2023-02-02 02:11:16 +01:00
parent 9b908a0be0
commit 8e684170fe
33 changed files with 100 additions and 5 deletions

View File

@ -23,6 +23,8 @@ public:
void formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override;
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTAlterNamedCollectionQuery>(clone()); }
QueryKind getQueryKind() const override { return QueryKind::Alter; }
};
}

View File

@ -289,4 +289,9 @@ ASTPtr ASTBackupQuery::getRewrittenASTWithoutOnCluster(const WithoutOnClusterAST
return new_query;
}
IAST::QueryKind ASTBackupQuery::getQueryKind() const
{
return kind == Kind::BACKUP ? QueryKind::Backup : QueryKind::Restore;
}
}

View File

@ -93,5 +93,6 @@ public:
ASTPtr clone() const override;
void formatImpl(const FormatSettings & format, FormatState &, FormatStateStacked) const override;
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override;
QueryKind getQueryKind() const override;
};
}

View File

@ -23,6 +23,8 @@ struct ASTCheckQuery : public ASTQueryWithTableAndOutput
return res;
}
QueryKind getQueryKind() const override { return QueryKind::Check; }
protected:
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
{

View File

@ -25,6 +25,8 @@ public:
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTCreateFunctionQuery>(clone()); }
String getFunctionName() const;
QueryKind getQueryKind() const override { return QueryKind::Create; }
};
}

View File

@ -22,6 +22,8 @@ public:
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTCreateNamedCollectionQuery>(clone()); }
QueryKind getQueryKind() const override { return QueryKind::Create; }
std::string getCollectionName() const;
};

View File

@ -11,6 +11,7 @@ class ASTDeleteQuery : public ASTQueryWithTableAndOutput
public:
String getID(char delim) const final;
ASTPtr clone() const final;
QueryKind getQueryKind() const override { return QueryKind::Delete; }
ASTPtr predicate;

View File

@ -21,6 +21,8 @@ public:
void formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override;
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTDropFunctionQuery>(clone()); }
QueryKind getQueryKind() const override { return QueryKind::Drop; }
};
}

View File

@ -9,7 +9,7 @@ namespace DB
/** Get the text that identifies this element. */
String ASTDropIndexQuery::getID(char delim) const
{
return "CreateIndexQuery" + (delim + getDatabase()) + delim + getTable();
return "DropIndexQuery" + (delim + getDatabase()) + delim + getTable();
}
ASTPtr ASTDropIndexQuery::clone() const

View File

@ -20,6 +20,8 @@ public:
void formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override;
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTDropNamedCollectionQuery>(clone()); }
QueryKind getQueryKind() const override { return QueryKind::Drop; }
};
}

View File

@ -109,6 +109,8 @@ public:
const ASTPtr & getTableFunction() const { return table_function; }
const ASTPtr & getTableOverride() const { return table_override; }
QueryKind getQueryKind() const override { return QueryKind::Explain; }
protected:
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
{

View File

@ -4,6 +4,7 @@
#include <Parsers/ASTFunction.h>
#include <Parsers/IAST.h>
namespace DB
{
@ -38,6 +39,8 @@ public:
from->formatImpl(settings, state, stacked);
external_ddl->formatImpl(settings, state, stacked);
}
QueryKind getQueryKind() const override { return QueryKind::ExternalDDL; }
};
}

View File

@ -42,6 +42,8 @@ public:
{
return removeOnCluster<ASTKillQueryQuery>(clone());
}
QueryKind getQueryKind() const override { return QueryKind::KillQuery; }
};
}

View File

@ -54,6 +54,8 @@ public:
{
return removeOnCluster<ASTOptimizeQuery>(clone(), params.default_database);
}
QueryKind getQueryKind() const override { return QueryKind::Optimize; }
};
}

View File

@ -49,6 +49,8 @@ public:
return res;
}
QueryKind getQueryKind() const override { return QueryKind::Show; }
protected:
void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
{

View File

@ -35,6 +35,8 @@ public:
void formatImpl(const FormatSettings & format, FormatState &, FormatStateStacked) const override;
void updateTreeHashImpl(SipHash & hash_state) const override;
QueryKind getQueryKind() const override { return QueryKind::Set; }
};
}

View File

@ -39,6 +39,8 @@ public:
ASTPtr clone() const override;
QueryKind getQueryKind() const override { return QueryKind::Show; }
protected:
void formatLike(const FormatSettings & settings) const;
void formatLimit(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const;

View File

@ -24,6 +24,21 @@ void ASTTransactionControl::formatImpl(const FormatSettings & format /*state*/,
}
}
IAST::QueryKind ASTTransactionControl::getQueryKind() const
{
switch (action)
{
case BEGIN:
return QueryKind::Begin;
case COMMIT:
return QueryKind::Commit;
case ROLLBACK:
return QueryKind::Rollback;
case SET_SNAPSHOT:
return QueryKind::SetTransactionSnapshot;
}
}
void ASTTransactionControl::updateTreeHashImpl(SipHash & hash_state) const
{
hash_state.update(action);

View File

@ -27,6 +27,8 @@ public:
void formatImpl(const FormatSettings & format, FormatState & /*state*/, FormatStateStacked /*frame*/) const override;
void updateTreeHashImpl(SipHash & hash_state) const override;
QueryKind getQueryKind() const override;
};
}

View File

@ -21,6 +21,8 @@ public:
ASTPtr clone() const override { return std::make_shared<ASTUseQuery>(*this); }
QueryKind getQueryKind() const override { return QueryKind::Use; }
protected:
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override
{

View File

@ -37,6 +37,8 @@ public:
return res;
}
QueryKind getQueryKind() const override { return QueryKind::Create; }
protected:
void formatQueryImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const override
{

View File

@ -55,5 +55,7 @@ public:
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
void replaceCurrentUserTag(const String & current_user_name) const;
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTCreateQuotaQuery>(clone()); }
QueryKind getQueryKind() const override { return QueryKind::Create; }
};
}

View File

@ -35,5 +35,7 @@ public:
ASTPtr clone() const override;
void formatImpl(const FormatSettings & format, FormatState &, FormatStateStacked) const override;
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTCreateRoleQuery>(clone()); }
QueryKind getQueryKind() const override { return QueryKind::Create; }
};
}

View File

@ -51,5 +51,7 @@ public:
void replaceCurrentUserTag(const String & current_user_name) const;
void replaceEmptyDatabase(const String & current_database) const;
QueryKind getQueryKind() const override { return QueryKind::Create; }
};
}

View File

@ -41,5 +41,6 @@ public:
void formatImpl(const FormatSettings & format, FormatState &, FormatStateStacked) const override;
void replaceCurrentUserTag(const String & current_user_name) const;
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTCreateSettingsProfileQuery>(clone()); }
QueryKind getQueryKind() const override { return QueryKind::Create; }
};
}

View File

@ -63,5 +63,7 @@ public:
void formatImpl(const FormatSettings & format, FormatState &, FormatStateStacked) const override;
bool hasSecretParts() const override;
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTCreateUserQuery>(clone()); }
QueryKind getQueryKind() const override { return QueryKind::Create; }
};
}

View File

@ -29,5 +29,7 @@ public:
ASTPtr getRewrittenASTWithoutOnCluster(const WithoutOnClusterASTRewriteParams &) const override { return removeOnCluster<ASTDropAccessEntityQuery>(clone()); }
void replaceEmptyDatabase(const String & current_database) const;
QueryKind getQueryKind() const override { return QueryKind::Drop; }
};
}

View File

@ -27,5 +27,7 @@ public:
String getID(char) const override;
ASTPtr clone() const override;
void formatImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
QueryKind getQueryKind() const override { return QueryKind::Set; }
};
}

View File

@ -31,6 +31,8 @@ public:
void replaceEmptyDatabase(const String & current_database);
QueryKind getQueryKind() const override { return QueryKind::Show; }
protected:
void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;

View File

@ -40,6 +40,8 @@ public:
void replaceEmptyDatabase(const String & current_database);
QueryKind getQueryKind() const override { return QueryKind::Show; }
protected:
String getKeyword() const;
void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;

View File

@ -17,5 +17,7 @@ public:
String getID(char) const override;
ASTPtr clone() const override;
void formatQueryImpl(const FormatSettings & settings, FormatState &, FormatStateStacked) const override;
QueryKind getQueryKind() const override { return QueryKind::Show; }
};
}

View File

@ -253,15 +253,32 @@ public:
enum class QueryKind : uint8_t
{
None = 0,
Alter,
Select,
Insert,
Delete,
Create,
Drop,
Grant,
Insert,
Rename,
Optimize,
Check,
Alter,
Grant,
Revoke,
Select,
System,
Set,
Use,
Show,
Exists,
Describe,
Explain,
Backup,
Restore,
KillQuery,
ExternalDDL,
Begin,
Commit,
Rollback,
SetTransactionSnapshot,
};
/// Return QueryKind of this AST query.
virtual QueryKind getQueryKind() const { return QueryKind::None; }

View File

@ -91,6 +91,8 @@ protected:
settings.ostr << (settings.hilite ? hilite_keyword : "") << ASTExistsDatabaseQueryIDAndQueryNames::Query
<< " " << (settings.hilite ? hilite_none : "") << backQuoteIfNeed(getDatabase());
}
QueryKind getQueryKind() const override { return QueryKind::Exists; }
};
class ASTShowCreateDatabaseQuery : public ASTQueryWithTableAndOutputImpl<ASTShowCreateDatabaseQueryIDAndQueryNames>
@ -123,6 +125,8 @@ public:
return res;
}
QueryKind getQueryKind() const override { return QueryKind::Describe; }
protected:
void formatQueryImpl(const FormatSettings & settings, FormatState & state, FormatStateStacked frame) const override
{