From c4f58f776b1693dd11a7502cbe218357c40b6181 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 23 May 2017 21:53:11 +0300 Subject: [PATCH] Preparations, part 7: Analyzers use const Context (and could be used in ExpressionAnalyzer) [#CLICKHOUSE-31]. --- dbms/src/Analyzers/AnalyzeResultOfQuery.cpp | 2 +- dbms/src/Analyzers/AnalyzeResultOfQuery.h | 2 +- dbms/src/Analyzers/CollectAliases.h | 6 +++--- dbms/src/Analyzers/CollectTables.cpp | 6 +++--- dbms/src/Analyzers/CollectTables.h | 2 +- dbms/src/Analyzers/TypeAndConstantInference.cpp | 12 ++++++------ dbms/src/Analyzers/TypeAndConstantInference.h | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/dbms/src/Analyzers/AnalyzeResultOfQuery.cpp b/dbms/src/Analyzers/AnalyzeResultOfQuery.cpp index 1a5bce62a65..a0a65830b0c 100644 --- a/dbms/src/Analyzers/AnalyzeResultOfQuery.cpp +++ b/dbms/src/Analyzers/AnalyzeResultOfQuery.cpp @@ -20,7 +20,7 @@ namespace ErrorCodes } -void AnalyzeResultOfQuery::process(ASTPtr & ast, Context & context) +void AnalyzeResultOfQuery::process(ASTPtr & ast, const Context & context) { const ASTSelectQuery * select = typeid_cast(ast.get()); if (!select) diff --git a/dbms/src/Analyzers/AnalyzeResultOfQuery.h b/dbms/src/Analyzers/AnalyzeResultOfQuery.h index 5d902353a6f..218c2c8c339 100644 --- a/dbms/src/Analyzers/AnalyzeResultOfQuery.h +++ b/dbms/src/Analyzers/AnalyzeResultOfQuery.h @@ -19,7 +19,7 @@ class Context; */ struct AnalyzeResultOfQuery { - void process(ASTPtr & ast, Context & context); + void process(ASTPtr & ast, const Context & context); /// Block will have non-nullptr columns for constant expressions. Block result; diff --git a/dbms/src/Analyzers/CollectAliases.h b/dbms/src/Analyzers/CollectAliases.h index 021ce8fb5d8..0c6046bc509 100644 --- a/dbms/src/Analyzers/CollectAliases.h +++ b/dbms/src/Analyzers/CollectAliases.h @@ -31,9 +31,9 @@ struct CollectAliases enum class Kind { - Expression, /// Example: SELECT a AS b, f(x) AS y - Table, /// Example: SELECT t.* FROM (SELECT 1) AS t - ArrayJoin /// Example: SELECT t.x.a FROM t ARRAY JOIN arr AS x + Expression, /// Example: SELECT a AS b, f(x) AS y + Table, /// Example: SELECT t.* FROM (SELECT 1) AS t + ArrayJoin /// Example: SELECT t.x.a FROM t ARRAY JOIN arr AS x }; struct AliasInfo diff --git a/dbms/src/Analyzers/CollectTables.cpp b/dbms/src/Analyzers/CollectTables.cpp index eba86a081f4..2d70f62be5f 100644 --- a/dbms/src/Analyzers/CollectTables.cpp +++ b/dbms/src/Analyzers/CollectTables.cpp @@ -49,7 +49,7 @@ static CollectTables::TableInfo processOrdinaryTable(const ASTPtr & ast_database } -static CollectTables::TableInfo processTableFunction(const ASTPtr & ast_table_function, Context & context) +static CollectTables::TableInfo processTableFunction(const ASTPtr & ast_table_function, const Context & context) { const ASTFunction & function = typeid_cast(*ast_table_function); @@ -78,7 +78,7 @@ static CollectTables::TableInfo processNoTables(const Context & context) } -static CollectTables::TableInfo processSubquery(ASTPtr & ast_subquery, Context & context) +static CollectTables::TableInfo processSubquery(ASTPtr & ast_subquery, const Context & context) { AnalyzeResultOfQuery analyzer; analyzer.process(typeid_cast(*ast_subquery).children.at(0), context); @@ -91,7 +91,7 @@ static CollectTables::TableInfo processSubquery(ASTPtr & ast_subquery, Context & } -void CollectTables::process(ASTPtr & ast, Context & context, const CollectAliases & aliases) +void CollectTables::process(ASTPtr & ast, const Context & context, const CollectAliases & aliases) { const ASTSelectQuery * select = typeid_cast(ast.get()); if (!select) diff --git a/dbms/src/Analyzers/CollectTables.h b/dbms/src/Analyzers/CollectTables.h index a860934e56b..6cd11510296 100644 --- a/dbms/src/Analyzers/CollectTables.h +++ b/dbms/src/Analyzers/CollectTables.h @@ -24,7 +24,7 @@ class WriteBuffer; */ struct CollectTables { - void process(ASTPtr & ast, Context & context, const CollectAliases & aliases); + void process(ASTPtr & ast, const Context & context, const CollectAliases & aliases); enum class Kind { diff --git a/dbms/src/Analyzers/TypeAndConstantInference.cpp b/dbms/src/Analyzers/TypeAndConstantInference.cpp index 39b85811f56..6b5e23896a3 100644 --- a/dbms/src/Analyzers/TypeAndConstantInference.cpp +++ b/dbms/src/Analyzers/TypeAndConstantInference.cpp @@ -56,7 +56,7 @@ using LambdaParameters = std::unordered_map; void processImpl( - ASTPtr & ast, Context & context, + ASTPtr & ast, const Context & context, CollectAliases & aliases, const AnalyzeColumns & columns, TypeAndConstantInference::Info & info, const AnalyzeLambdas & lambdas); @@ -76,7 +76,7 @@ void processLiteral(const String & column_name, const ASTPtr & ast, TypeAndConst void processIdentifier(const String & column_name, const ASTPtr & ast, TypeAndConstantInference::Info & info, - Context & context, CollectAliases & aliases, const AnalyzeColumns & columns, + const Context & context, CollectAliases & aliases, const AnalyzeColumns & columns, const AnalyzeLambdas & lambdas) { /// Column from table @@ -258,7 +258,7 @@ void processFunction(const String & column_name, ASTPtr & ast, TypeAndConstantIn void processScalarSubquery(const String & column_name, ASTPtr & ast, TypeAndConstantInference::Info & info, - Context & context) + const Context & context) { ASTSubquery * subquery = static_cast(ast.get()); @@ -316,7 +316,7 @@ void processScalarSubquery(const String & column_name, ASTPtr & ast, TypeAndCons void processHigherOrderFunction(const String & column_name, - ASTPtr & ast, Context & context, + ASTPtr & ast, const Context & context, CollectAliases & aliases, const AnalyzeColumns & columns, TypeAndConstantInference::Info & info, const AnalyzeLambdas & lambdas) @@ -395,7 +395,7 @@ void processHigherOrderFunction(const String & column_name, void processImpl( - ASTPtr & ast, Context & context, + ASTPtr & ast, const Context & context, CollectAliases & aliases, const AnalyzeColumns & columns, TypeAndConstantInference::Info & info, const AnalyzeLambdas & lambdas) @@ -468,7 +468,7 @@ void processImpl( } -void TypeAndConstantInference::process(ASTPtr & ast, Context & context, +void TypeAndConstantInference::process(ASTPtr & ast, const Context & context, CollectAliases & aliases, const AnalyzeColumns & columns, const AnalyzeLambdas & lambdas) { processImpl(ast, context, aliases, columns, info, lambdas); diff --git a/dbms/src/Analyzers/TypeAndConstantInference.h b/dbms/src/Analyzers/TypeAndConstantInference.h index 8f4aad38231..6ca6ea4bdb2 100644 --- a/dbms/src/Analyzers/TypeAndConstantInference.h +++ b/dbms/src/Analyzers/TypeAndConstantInference.h @@ -30,7 +30,7 @@ class IAggregateFunction; */ struct TypeAndConstantInference { - void process(ASTPtr & ast, Context & context, + void process(ASTPtr & ast, const Context & context, CollectAliases & aliases, const AnalyzeColumns & columns, const AnalyzeLambdas & analyze_lambdas);