2017-12-20 07:39:52 +00:00
|
|
|
#include <Parsers/ASTAlterQuery.h>
|
2021-08-18 22:19:14 +00:00
|
|
|
#include <Parsers/ASTBackupQuery.h>
|
2017-12-20 07:39:52 +00:00
|
|
|
#include <Parsers/ASTCheckQuery.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ASTCreateQuery.h>
|
2021-08-23 14:31:58 +00:00
|
|
|
#include <Parsers/ASTCreateFunctionQuery.h>
|
2022-06-16 09:58:14 +00:00
|
|
|
#include <Parsers/ASTCreateIndexQuery.h>
|
2022-06-07 05:20:46 +00:00
|
|
|
#include <Parsers/ASTDeleteQuery.h>
|
2021-05-14 22:43:04 +00:00
|
|
|
#include <Parsers/ASTDropFunctionQuery.h>
|
2022-06-17 07:46:44 +00:00
|
|
|
#include <Parsers/ASTDropIndexQuery.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ASTDropQuery.h>
|
2023-03-21 12:14:26 +00:00
|
|
|
#include <Parsers/ASTUndropQuery.h>
|
2021-04-16 20:18:39 +00:00
|
|
|
#include <Parsers/ASTExplainQuery.h>
|
2017-12-20 07:39:52 +00:00
|
|
|
#include <Parsers/ASTInsertQuery.h>
|
2021-08-12 11:42:51 +00:00
|
|
|
#include <Parsers/ASTSelectIntersectExceptQuery.h>
|
2017-12-20 07:39:52 +00:00
|
|
|
#include <Parsers/ASTKillQueryQuery.h>
|
|
|
|
#include <Parsers/ASTOptimizeQuery.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ASTRenameQuery.h>
|
2017-12-20 07:39:52 +00:00
|
|
|
#include <Parsers/ASTSelectQuery.h>
|
2018-02-25 06:34:20 +00:00
|
|
|
#include <Parsers/ASTSelectWithUnionQuery.h>
|
2017-04-01 09:19:00 +00:00
|
|
|
#include <Parsers/ASTSetQuery.h>
|
2023-01-31 15:35:10 +00:00
|
|
|
#include <Parsers/ASTShowEngineQuery.h>
|
2023-09-05 02:50:46 +00:00
|
|
|
#include <Parsers/ASTShowFunctionsQuery.h>
|
2020-05-07 02:45:27 +00:00
|
|
|
#include <Parsers/ASTShowProcesslistQuery.h>
|
2017-12-20 07:39:52 +00:00
|
|
|
#include <Parsers/ASTShowTablesQuery.h>
|
2023-03-26 14:36:38 +00:00
|
|
|
#include <Parsers/ASTShowColumnsQuery.h>
|
2023-04-25 18:04:19 +00:00
|
|
|
#include <Parsers/ASTShowIndexesQuery.h>
|
2023-10-24 14:50:33 +00:00
|
|
|
#include <Parsers/ASTShowSettingQuery.h>
|
2017-12-20 07:39:52 +00:00
|
|
|
#include <Parsers/ASTUseQuery.h>
|
2019-05-28 21:17:48 +00:00
|
|
|
#include <Parsers/ASTWatchQuery.h>
|
2022-11-11 21:19:58 +00:00
|
|
|
#include <Parsers/ASTCreateNamedCollectionQuery.h>
|
|
|
|
#include <Parsers/ASTDropNamedCollectionQuery.h>
|
|
|
|
#include <Parsers/ASTAlterNamedCollectionQuery.h>
|
2021-03-31 17:55:04 +00:00
|
|
|
#include <Parsers/ASTTransactionControl.h>
|
2021-04-16 20:18:39 +00:00
|
|
|
#include <Parsers/TablePropertiesQueriesASTs.h>
|
2015-06-18 02:11:05 +00:00
|
|
|
|
2021-10-31 08:51:20 +00:00
|
|
|
#include <Parsers/Access/ASTCreateQuotaQuery.h>
|
|
|
|
#include <Parsers/Access/ASTCreateRoleQuery.h>
|
|
|
|
#include <Parsers/Access/ASTCreateRowPolicyQuery.h>
|
|
|
|
#include <Parsers/Access/ASTCreateSettingsProfileQuery.h>
|
|
|
|
#include <Parsers/Access/ASTCreateUserQuery.h>
|
|
|
|
#include <Parsers/Access/ASTDropAccessEntityQuery.h>
|
|
|
|
#include <Parsers/Access/ASTGrantQuery.h>
|
2023-07-21 02:20:36 +00:00
|
|
|
#include <Parsers/Access/ASTMoveAccessEntityQuery.h>
|
2021-10-31 08:51:20 +00:00
|
|
|
#include <Parsers/Access/ASTSetRoleQuery.h>
|
|
|
|
#include <Parsers/Access/ASTShowAccessEntitiesQuery.h>
|
|
|
|
#include <Parsers/Access/ASTShowAccessQuery.h>
|
|
|
|
#include <Parsers/Access/ASTShowCreateAccessEntityQuery.h>
|
|
|
|
#include <Parsers/Access/ASTShowGrantsQuery.h>
|
|
|
|
#include <Parsers/Access/ASTShowPrivilegesQuery.h>
|
2022-06-21 13:42:36 +00:00
|
|
|
#include <Parsers/ASTDescribeCacheQuery.h>
|
2021-10-31 08:51:20 +00:00
|
|
|
|
2017-12-20 07:39:52 +00:00
|
|
|
#include <Interpreters/InterpreterFactory.h>
|
|
|
|
#include <Interpreters/InterpreterSelectQuery.h>
|
2022-07-14 11:20:16 +00:00
|
|
|
#include <Interpreters/InterpreterSelectQueryAnalyzer.h>
|
2018-02-25 06:34:20 +00:00
|
|
|
#include <Interpreters/InterpreterSelectWithUnionQuery.h>
|
2019-05-28 21:17:48 +00:00
|
|
|
#include <Interpreters/InterpreterWatchQuery.h>
|
2020-11-09 15:07:38 +00:00
|
|
|
#include <Interpreters/OpenTelemetrySpanLog.h>
|
2015-06-18 02:11:05 +00:00
|
|
|
|
2017-08-04 15:54:00 +00:00
|
|
|
#include <Parsers/ASTSystemQuery.h>
|
2020-07-06 13:57:45 +00:00
|
|
|
#include <Parsers/ASTExternalDDLQuery.h>
|
|
|
|
#include <Common/ProfileEvents.h>
|
|
|
|
#include <Common/typeid_cast.h>
|
|
|
|
|
2018-06-08 19:32:35 +00:00
|
|
|
|
|
|
|
namespace ProfileEvents
|
|
|
|
{
|
|
|
|
extern const Event Query;
|
2023-12-27 04:37:06 +00:00
|
|
|
extern const Event InitialQuery;
|
2023-05-24 15:58:42 +00:00
|
|
|
extern const Event QueriesWithSubqueries;
|
2018-06-08 19:32:35 +00:00
|
|
|
extern const Event SelectQuery;
|
|
|
|
extern const Event InsertQuery;
|
|
|
|
}
|
2017-08-04 15:54:00 +00:00
|
|
|
|
2017-07-13 20:58:19 +00:00
|
|
|
|
2015-06-18 02:11:05 +00:00
|
|
|
namespace DB
|
|
|
|
{
|
2016-01-11 21:46:36 +00:00
|
|
|
namespace ErrorCodes
|
|
|
|
{
|
|
|
|
extern const int UNKNOWN_TYPE_OF_QUERY;
|
2024-01-09 06:33:48 +00:00
|
|
|
extern const int LOGICAL_ERROR;
|
2016-01-11 21:46:36 +00:00
|
|
|
}
|
|
|
|
|
2024-01-09 06:33:48 +00:00
|
|
|
InterpreterFactory & InterpreterFactory::instance()
|
|
|
|
{
|
|
|
|
static InterpreterFactory interpreter_fact;
|
|
|
|
return interpreter_fact;
|
|
|
|
}
|
|
|
|
|
|
|
|
void InterpreterFactory::registerInterpreter(const std::string & name, CreatorFn creator_fn)
|
|
|
|
{
|
|
|
|
if (!interpreters.emplace(name, std::move(creator_fn)).second)
|
|
|
|
throw Exception(ErrorCodes::LOGICAL_ERROR, "InterpreterFactory: the interpreter name '{}' is not unique", name);
|
|
|
|
}
|
2015-06-18 02:11:05 +00:00
|
|
|
|
2024-01-09 06:33:48 +00:00
|
|
|
InterpreterFactory::InterpreterPtr InterpreterFactory::get(ASTPtr & query, ContextMutablePtr context, const SelectQueryOptions & options)
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2018-06-08 19:32:35 +00:00
|
|
|
ProfileEvents::increment(ProfileEvents::Query);
|
2023-12-27 04:37:06 +00:00
|
|
|
if (context->getClientInfo().query_kind == ClientInfo::QueryKind::INITIAL_QUERY)
|
|
|
|
ProfileEvents::increment(ProfileEvents::InitialQuery);
|
2023-05-24 15:58:42 +00:00
|
|
|
/// SELECT and INSERT query will handle QueriesWithSubqueries on their own.
|
|
|
|
if (!(query->as<ASTSelectQuery>() ||
|
|
|
|
query->as<ASTSelectWithUnionQuery>() ||
|
|
|
|
query->as<ASTSelectIntersectExceptQuery>() ||
|
|
|
|
query->as<ASTInsertQuery>()))
|
|
|
|
{
|
|
|
|
ProfileEvents::increment(ProfileEvents::QueriesWithSubqueries);
|
|
|
|
}
|
|
|
|
|
2024-02-27 13:37:21 +00:00
|
|
|
Arguments arguments
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
.query = query,
|
|
|
|
.context = context,
|
|
|
|
.options = options
|
|
|
|
};
|
|
|
|
|
|
|
|
String interpreter_name;
|
|
|
|
|
2019-03-11 13:22:51 +00:00
|
|
|
if (query->as<ASTSelectQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2022-10-25 10:35:25 +00:00
|
|
|
if (context->getSettingsRef().allow_experimental_analyzer)
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterSelectQueryAnalyzer";
|
2018-06-08 19:32:35 +00:00
|
|
|
/// This is internal part of ASTSelectWithUnionQuery.
|
|
|
|
/// Even if there is SELECT without union, it is represented by ASTSelectWithUnionQuery with single ASTSelectQuery as a child.
|
2024-01-09 06:33:48 +00:00
|
|
|
else
|
|
|
|
interpreter_name = "InterpreterSelectQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTSelectWithUnionQuery>())
|
2018-02-25 06:34:20 +00:00
|
|
|
{
|
2018-06-08 19:32:35 +00:00
|
|
|
ProfileEvents::increment(ProfileEvents::SelectQuery);
|
2022-07-14 11:20:16 +00:00
|
|
|
|
2022-10-25 10:35:25 +00:00
|
|
|
if (context->getSettingsRef().allow_experimental_analyzer)
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterSelectQueryAnalyzer";
|
|
|
|
else
|
|
|
|
interpreter_name = "InterpreterSelectWithUnionQuery";
|
2018-02-25 06:34:20 +00:00
|
|
|
}
|
2021-08-12 11:42:51 +00:00
|
|
|
else if (query->as<ASTSelectIntersectExceptQuery>())
|
2021-04-16 20:18:39 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterSelectIntersectExceptQuery";
|
2021-04-16 20:18:39 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTInsertQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2018-06-08 19:32:35 +00:00
|
|
|
ProfileEvents::increment(ProfileEvents::InsertQuery);
|
2021-04-10 23:33:54 +00:00
|
|
|
bool allow_materialized = static_cast<bool>(context->getSettingsRef().insert_allow_materialized_columns);
|
2024-01-09 06:33:48 +00:00
|
|
|
arguments.allow_materialized = allow_materialized;
|
|
|
|
interpreter_name = "InterpreterInsertQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTCreateQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTDropQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterDropQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2023-03-21 12:14:26 +00:00
|
|
|
else if (query->as<ASTUndropQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterUndropQuery";
|
2023-03-21 12:14:26 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTRenameQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterRenameQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTShowTablesQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowTablesQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2023-03-26 14:36:38 +00:00
|
|
|
else if (query->as<ASTShowColumnsQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowColumnsQuery";
|
2023-03-26 14:36:38 +00:00
|
|
|
}
|
2023-04-25 18:04:19 +00:00
|
|
|
else if (query->as<ASTShowIndexesQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowIndexesQuery";
|
2023-04-25 18:04:19 +00:00
|
|
|
}
|
2023-10-24 14:50:33 +00:00
|
|
|
else if (query->as<ASTShowSettingQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowSettingQuery";
|
2023-10-24 14:50:33 +00:00
|
|
|
}
|
2023-01-31 15:35:10 +00:00
|
|
|
else if (query->as<ASTShowEnginesQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowEnginesQuery";
|
2023-01-31 15:35:10 +00:00
|
|
|
}
|
2023-09-05 02:50:46 +00:00
|
|
|
else if (query->as<ASTShowFunctionsQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowFunctionsQuery";
|
2023-09-05 02:50:46 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTUseQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterUseQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTSetQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2017-04-02 17:37:49 +00:00
|
|
|
/// readonly is checked inside InterpreterSetQuery
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterSetQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2020-02-17 02:59:56 +00:00
|
|
|
else if (query->as<ASTSetRoleQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterSetRoleQuery";
|
2020-02-17 02:59:56 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTOptimizeQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterOptimizeQuery";
|
2018-03-12 14:14:56 +00:00
|
|
|
}
|
2024-01-09 06:33:48 +00:00
|
|
|
else if (query->as<ASTExistsDatabaseQuery>() || query->as<ASTExistsTableQuery>() || query->as<ASTExistsViewQuery>() || query->as<ASTExistsDictionaryQuery>())
|
2020-12-14 14:37:25 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterExistsQuery";
|
2020-12-14 14:37:25 +00:00
|
|
|
}
|
2024-01-09 06:33:48 +00:00
|
|
|
else if (query->as<ASTShowCreateTableQuery>() || query->as<ASTShowCreateViewQuery>() || query->as<ASTShowCreateDatabaseQuery>() || query->as<ASTShowCreateDictionaryQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowCreateQuery";
|
2019-10-11 13:21:52 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTDescribeQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterDescribeQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2022-06-21 13:42:36 +00:00
|
|
|
else if (query->as<ASTDescribeCacheQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterDescribeCacheQuery";
|
2022-06-21 13:42:36 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTExplainQuery>())
|
2018-09-21 15:20:23 +00:00
|
|
|
{
|
2024-03-21 15:27:39 +00:00
|
|
|
const auto kind = query->as<ASTExplainQuery>()->getKind();
|
|
|
|
if (kind == ASTExplainQuery::ParsedAST || kind == ASTExplainQuery::AnalyzedSyntax)
|
|
|
|
context->setSetting("allow_experimental_analyzer", false);
|
|
|
|
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterExplainQuery";
|
2018-09-21 15:20:23 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTShowProcesslistQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowProcesslistQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTAlterQuery>())
|
2015-06-18 02:11:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterAlterQuery";
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
2022-11-11 21:19:58 +00:00
|
|
|
else if (query->as<ASTAlterNamedCollectionQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterAlterNamedCollectionQuery";
|
2022-11-11 21:19:58 +00:00
|
|
|
}
|
2023-10-24 12:50:24 +00:00
|
|
|
else if (query->as<ASTCheckTableQuery>() || query->as<ASTCheckAllTablesQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCheckQuery";
|
2023-10-24 12:50:24 +00:00
|
|
|
}
|
|
|
|
else if (query->as<ASTKillQueryQuery>())
|
2016-11-30 17:31:05 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterKillQueryQuery";
|
2016-11-30 17:31:05 +00:00
|
|
|
}
|
2019-03-11 13:22:51 +00:00
|
|
|
else if (query->as<ASTSystemQuery>())
|
2017-08-04 15:54:00 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterSystemQuery";
|
2017-08-04 15:54:00 +00:00
|
|
|
}
|
2019-05-28 21:17:48 +00:00
|
|
|
else if (query->as<ASTWatchQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterWatchQuery";
|
2019-05-28 21:17:48 +00:00
|
|
|
}
|
2020-02-04 22:37:04 +00:00
|
|
|
else if (query->as<ASTCreateUserQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateUserQuery";
|
2020-02-04 22:37:04 +00:00
|
|
|
}
|
2020-02-17 02:59:56 +00:00
|
|
|
else if (query->as<ASTCreateRoleQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateRoleQuery";
|
2020-02-17 02:59:56 +00:00
|
|
|
}
|
2019-12-01 22:01:05 +00:00
|
|
|
else if (query->as<ASTCreateQuotaQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateQuotaQuery";
|
2019-12-01 22:01:05 +00:00
|
|
|
}
|
2019-11-29 17:22:56 +00:00
|
|
|
else if (query->as<ASTCreateRowPolicyQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateRowPolicyQuery";
|
2019-11-29 17:22:56 +00:00
|
|
|
}
|
2020-03-18 14:11:44 +00:00
|
|
|
else if (query->as<ASTCreateSettingsProfileQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateSettingsProfileQuery";
|
2020-03-18 14:11:44 +00:00
|
|
|
}
|
2019-12-01 22:01:05 +00:00
|
|
|
else if (query->as<ASTDropAccessEntityQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterDropAccessEntityQuery";
|
2019-12-01 22:01:05 +00:00
|
|
|
}
|
2023-07-21 02:20:36 +00:00
|
|
|
else if (query->as<ASTMoveAccessEntityQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterMoveAccessEntityQuery";
|
2023-07-21 02:20:36 +00:00
|
|
|
}
|
2022-11-11 21:19:58 +00:00
|
|
|
else if (query->as<ASTDropNamedCollectionQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterDropNamedCollectionQuery";
|
2022-11-11 21:19:58 +00:00
|
|
|
}
|
2020-02-04 22:37:04 +00:00
|
|
|
else if (query->as<ASTGrantQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterGrantQuery";
|
2020-02-04 22:37:04 +00:00
|
|
|
}
|
2019-12-01 22:01:05 +00:00
|
|
|
else if (query->as<ASTShowCreateAccessEntityQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowCreateAccessEntityQuery";
|
2019-12-01 22:01:05 +00:00
|
|
|
}
|
2020-02-04 22:37:04 +00:00
|
|
|
else if (query->as<ASTShowGrantsQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowGrantsQuery";
|
2020-02-04 22:37:04 +00:00
|
|
|
}
|
2020-05-07 02:45:27 +00:00
|
|
|
else if (query->as<ASTShowAccessEntitiesQuery>())
|
2019-11-29 17:22:56 +00:00
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowAccessEntitiesQuery";
|
2019-11-29 17:22:56 +00:00
|
|
|
}
|
2020-06-10 23:08:37 +00:00
|
|
|
else if (query->as<ASTShowAccessQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name= "InterpreterShowAccessQuery";
|
2020-06-10 23:08:37 +00:00
|
|
|
}
|
2020-05-12 21:46:14 +00:00
|
|
|
else if (query->as<ASTShowPrivilegesQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterShowPrivilegesQuery";
|
2020-05-12 21:46:14 +00:00
|
|
|
}
|
2020-07-06 13:57:45 +00:00
|
|
|
else if (query->as<ASTExternalDDLQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterExternalDDLQuery";
|
2020-07-06 13:57:45 +00:00
|
|
|
}
|
2021-03-31 17:55:04 +00:00
|
|
|
else if (query->as<ASTTransactionControl>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterTransactionControlQuery";
|
2021-03-31 17:55:04 +00:00
|
|
|
}
|
2021-05-09 09:47:29 +00:00
|
|
|
else if (query->as<ASTCreateFunctionQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateFunctionQuery";
|
2021-05-09 09:47:29 +00:00
|
|
|
}
|
2021-05-14 22:43:04 +00:00
|
|
|
else if (query->as<ASTDropFunctionQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterDropFunctionQuery";
|
2021-05-14 22:43:04 +00:00
|
|
|
}
|
2022-06-16 09:58:14 +00:00
|
|
|
else if (query->as<ASTCreateIndexQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateIndexQuery";
|
2022-06-16 09:58:14 +00:00
|
|
|
}
|
2022-11-11 21:19:58 +00:00
|
|
|
else if (query->as<ASTCreateNamedCollectionQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterCreateNamedCollectionQuery";
|
2022-11-11 21:19:58 +00:00
|
|
|
}
|
2022-06-17 07:46:44 +00:00
|
|
|
else if (query->as<ASTDropIndexQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterDropIndexQuery";
|
2022-06-17 07:46:44 +00:00
|
|
|
}
|
2021-08-18 22:19:14 +00:00
|
|
|
else if (query->as<ASTBackupQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterBackupQuery";
|
2021-08-18 22:19:14 +00:00
|
|
|
}
|
2022-06-07 05:20:46 +00:00
|
|
|
else if (query->as<ASTDeleteQuery>())
|
|
|
|
{
|
2024-01-09 06:33:48 +00:00
|
|
|
interpreter_name = "InterpreterDeleteQuery";
|
2022-06-07 05:20:46 +00:00
|
|
|
}
|
2024-01-09 06:33:48 +00:00
|
|
|
|
|
|
|
if (!interpreters.contains(interpreter_name))
|
2023-01-23 21:13:58 +00:00
|
|
|
throw Exception(ErrorCodes::UNKNOWN_TYPE_OF_QUERY, "Unknown type of query: {}", query->getID());
|
2024-01-09 06:33:48 +00:00
|
|
|
|
|
|
|
// creator_fn creates and returns a InterpreterPtr with the supplied arguments
|
|
|
|
auto creator_fn = interpreters.at(interpreter_name);
|
|
|
|
|
|
|
|
return creator_fn(arguments);
|
2015-06-18 02:11:05 +00:00
|
|
|
}
|
|
|
|
}
|