You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by sp...@apache.org on 2016/12/11 17:45:25 UTC
[02/51] [abbrv] [partial] incubator-quickstep git commit: remove c++
files
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/resolver/Resolver.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.hpp b/query_optimizer/resolver/Resolver.hpp
deleted file mode 100644
index 855e6ba..0000000
--- a/query_optimizer/resolver/Resolver.hpp
+++ /dev/null
@@ -1,694 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_RESOLVER_RESOLVER_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_RESOLVER_RESOLVER_HPP_
-
-#include <string>
-#include <unordered_map>
-#include <unordered_set>
-#include <vector>
-
-#include "query_optimizer/expressions/Alias.hpp"
-#include "query_optimizer/expressions/ExprId.hpp"
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/expressions/Predicate.hpp"
-#include "query_optimizer/expressions/SubqueryExpression.hpp"
-#include "query_optimizer/expressions/Scalar.hpp"
-#include "query_optimizer/expressions/WindowAggregateFunction.hpp"
-#include "query_optimizer/logical/Logical.hpp"
-#include "utility/Macros.hpp"
-#include "utility/PtrVector.hpp"
-
-namespace quickstep {
-
-class CatalogDatabase;
-class CatalogRelation;
-class Comparison;
-class ParseExpression;
-class ParseFunctionCall;
-class ParseGeneratorTableReference;
-class ParseJoinedTableReference;
-class ParseOrderBy;
-class ParsePredicate;
-class ParseSearchedCaseExpression;
-class ParseSelect;
-class ParseSelectionClause;
-class ParseSimpleCaseExpression;
-class ParseSimpleTableReference;
-class ParseSubqueryTableReference;
-class ParseStatement;
-class ParseStatementCopyFrom;
-class ParseStatementCreateTable;
-class ParseStatementCreateIndex;
-class ParseStatementDelete;
-class ParseStatementDropTable;
-class ParseStatementInsertSelection;
-class ParseStatementInsertTuple;
-class ParseStatementSelect;
-class ParseStatementUpdate;
-class ParseString;
-class ParseSubqueryExpression;
-class ParseTableReference;
-class ParseTableReferenceSignature;
-class ParseTreeNode;
-class ParseWindow;
-template <class T>
-class PtrList;
-class StorageBlockLayoutDescription;
-class Type;
-
-} // namespace quickstep
-
-namespace quickstep {
-namespace optimizer {
-
-class OptimizerContext;
-
-namespace resolver {
-
-class NameResolver;
-
-/** \addtogroup QueryResolver
- * @{
- */
-
-/**
- * @brief Performs semantic analysis and validation on a parse tree for a SELECT
- * statement and outputs an initial logical plan.
- */
-class Resolver {
- public:
- /**
- * @brief Constructor. Does not take ownership of \p context.
- *
- * @param catalog_database The database that the query is executed on.
- * @param context The context of this query.
- */
- Resolver(const CatalogDatabase &catalog_database, OptimizerContext *context)
- : catalog_database_(catalog_database),
- context_(context) {}
-
- /**
- * @brief Validates the query is semantically correct and converts the parse
- * tree to an initial logical plan.
- *
- * @param parse_query
- * @return The converted logical node.
- */
- logical::LogicalPtr resolve(const ParseStatement &parse_query);
-
- private:
- /**
- * @brief Expression-scoped info that contains both constant and non-constant
- * info (e.g. the name resolver, whether an aggregate is allowed)
- * during resolving an expression.
- */
- struct ExpressionResolutionInfo;
-
- /**
- * @brief Query-scoped info that contains the aggregate expressions in a query
- * block.
- */
- struct QueryAggregationInfo;
-
- /**
- * @brief Query-scoped info that contains window aggregate expressions and a
- * window map.
- **/
- struct WindowAggregationInfo;
-
- /**
- * @brief A wrapper for resolved window and the corresponding sorted plan.
- **/
- struct WindowPlan;
-
- /**
- * @brief Query-scoped info that contains select-list expressions
- * and whether an expression is referenced by an
- * ordinal or alias reference.
- */
- struct SelectListInfo;
-
- /**
- * @brief Contains resolution info for subqueries in the WITH clause.
- */
- struct WithQueriesInfo {
- /**
- * @brief The plans for WITH queries.
- */
- std::vector<logical::LogicalPtr> with_query_plans;
-
- /**
- * @brief The query name (the name of the table derived by the query) to
- * the position of the plan in <with_query_plans>.
- */
- std::unordered_map<std::string, int> with_query_name_to_vector_position;
-
- /**
- * @brief Indexes of WITH queries that are not used.
- */
- std::unordered_set<int> unreferenced_query_indexes;
- };
-
- /**
- * @brief Resolves a SELECT (sub)query and returns a logical plan.
- *
- * @param select_statement The SELECT parse tree.
- * @param select_name The name for the SELECT query.
- * @param type_hints Type hints for the expressions in the SELECT clause. Can
- * be NULL if there is no expectation.
- * @param parent_resolver The name resolver of the outer query if exists.
- * @return A logical plan for the SELECT query.
- */
- logical::LogicalPtr resolveSelect(
- const ParseSelect &select_statement,
- const std::string &select_name,
- const std::vector<const Type*> *type_hints,
- const NameResolver *parent_resolver);
-
- /**
- * @brief Resolves a CREATE TABLE query and returns a logical plan.
- *
- * @param create_table_statement The CREATE TABLE parse tree.
- * @return A logical plan for the CREATE TABLE query.
- */
- logical::LogicalPtr resolveCreateTable(
- const ParseStatementCreateTable &create_table_statement);
-
- /**
- * @brief Resolves a CREATE INDEX query and returns a logical plan.
- *
- * @param create_index_statement THE CREATE INDEX parse tree.
- * @return A logical plan for the CREATE INDEX query.
- */
- logical::LogicalPtr resolveCreateIndex(
- const ParseStatementCreateIndex &create_index_statement);
-
- /**
- * @brief Resolves the BLOCK PROPERTIES of a CREATE TABLE statement to a
- * proto message describing the user input.
- *
- * @param create_table_statement The create table statement.
- * @return A pointer to a user-owned Proto message describing the block. Note
- * that this message may be invalid.
- */
- StorageBlockLayoutDescription* resolveBlockProperties(
- const ParseStatementCreateTable &create_table_statement);
-
- /**
- * @brief Resolves a DELETE query and returns a logical plan.
- *
- * @param delete_statement The DELETE parse tree.
- * @return A logical plan for the DELETE query.
- */
- logical::LogicalPtr resolveDelete(
- const ParseStatementDelete &delete_statement);
-
- /**
- * @brief Resolves a DROP TABLE query and returns a logical plan.
- *
- * @param drop_table_statement The DROP TABLE parse tree.
- * @return A logical plan for the DROP TABLE query.
- */
- logical::LogicalPtr resolveDropTable(
- const ParseStatementDropTable &drop_table_statement);
-
- /**
- * @brief Resolves an INSERT VALUES query and returns a logical plan.
- *
- * @param insert_statement The INSERT parse tree.
- * @return A logical plan for the INSERT query.
- */
- logical::LogicalPtr resolveInsertTuple(
- const ParseStatementInsertTuple &insert_statement);
-
- /**
- * @brief Resolves an INSERT SELECT query and returns a logical plan.
- *
- * @param insert_statement The INSERT parse tree.
- * @return A logical plan for the INSERT query.
- */
- logical::LogicalPtr resolveInsertSelection(
- const ParseStatementInsertSelection &insert_statement);
-
- /**
- * @brief Resolves a COPY FROM query and returns a logical plan.
- *
- * @param copy_from_statement The COPY FROM parse tree.
- * @return A logical plan for the COPY FROM query.
- */
- logical::LogicalPtr resolveCopyFrom(
- const ParseStatementCopyFrom ©_from_statement);
-
- /**
- * @brief Resolves a UPDATE query and returns a logical plan.
- *
- * @param update_statement The UPDATE parse tree.
- * @return A logical plan for the UPDATE query.
- */
- logical::LogicalPtr resolveUpdate(
- const ParseStatementUpdate &update_statement);
-
- /**
- * @brief Resolves WITH clause and stores the resolved information into
- * the member object with_query_info_ of this class.
- *
- * @param with_list The list of subqueries in WITH clause.
- */
- void resolveWithClause(
- const PtrVector<ParseSubqueryTableReference> &with_list);
-
- /**
- * @brief Resolves SELECT-list expressions and returns the resolved
- * expressions in \p project_expressions.
- * @warning \p project_expressions will be cleared first.
- *
- * @param parse_selection The SELECT parse tree.
- * @param select_name The name of the SELECT query. It is used to populate the
- * relation name in the expressions.
- * @param type_hints Type hints for the expressions in the SELECT clause. Can
- * be NULL if there is no expectation.
- * @param name_resolver NameResolver to resolve the relation/attribute names.
- * @param query_aggregation_info Passed down to each expression to collects
- * aggregate expressions.
- * @param window_aggregate_expressions Passed down to each expressions to
- * collects window aggregate expressions.
- * @param project_expressions Converted SELECT-list expressions.
- * @param has_aggregate_per_expression For each SELECT-list expression,
- * indicates whether it contains
- * an aggregate.
- */
- void resolveSelectClause(
- const ParseSelectionClause &parse_selection,
- const std::string &select_name,
- const std::vector<const Type*> *type_hints,
- const NameResolver &name_resolver,
- QueryAggregationInfo *query_aggregation_info,
- WindowAggregationInfo *window_aggregation_info,
- std::vector<expressions::NamedExpressionPtr> *project_expressions,
- std::vector<bool> *has_aggregate_per_expression);
-
- /**
- * @brief Resolves FROM clause and converts it to a logical plan. If the FROM
- * clause has multiple items, the returned plan is a MultiwayCartisianJoin
- * on all logical subplans for FROM-list items.
- *
- * @param from_list The FROM-list items.
- * @param name_resolver The resolver to resolve names.
- * @return A logical plan for the FROM clause.
- */
- logical::LogicalPtr resolveFromClause(
- const PtrList<ParseTableReference> &from_list,
- NameResolver *name_resolver);
-
- /**
- * @brief Resolves a table reference item, which can be a base table,
- * a generator table, a subquery table, or a joined table defined by
- * a join chain.
- *
- * @param table_reference The parse table reference to be resolved.
- * @param name_resolver The name resolver to be updated with new tables
- * visible from this table reference item.
- * @return The logical plan to derive the table.
- */
- logical::LogicalPtr resolveTableReference(const ParseTableReference &table_reference,
- NameResolver *name_resolver);
-
- /**
- * @brief Resolves a table reference by name, and converts it to a logical
- * plan. The table is not added into the NameResolver.
- *
- * @param table_name The parse node for the table name string.
- * @param reference_alias The alias of the table reference.
- * @return A logical plan for the table reference.
- */
- logical::LogicalPtr resolveSimpleTableReference(
- const ParseString &table_name, const ParseString *reference_alias);
-
- /**
- * @brief Resolves a generator table reference and links the corresponding
- * generator function. The table is not added into the NameResolver.
- *
- * @param table_reference The parse table reference to be resolved.
- * @return The logical plan for the generator table reference.
- */
- logical::LogicalPtr resolveGeneratorTableReference(
- const ParseGeneratorTableReference &table_reference,
- const ParseString *reference_alias);
-
- /**
- * @brief Resolves a joined table resulting from a join between two table
- * references.
- *
- * @param joined_table_reference The parse joined table reference to be resolved.
- * @param name_resolver The name resolver to be updated with the left and the
- * right tables.
- * @return A logical plan for the joined table reference.
- */
- logical::LogicalPtr resolveJoinedTableReference(
- const ParseJoinedTableReference &joined_table_reference,
- NameResolver *name_resolver);
-
- /**
- * @brief Renames the output columns from \p logical_plan based on the table signature
- * by wrapping it with a Project.
- *
- * @param logical The logical node whose output columns are
- * @param table_signature A table reference signature that specifies column names.
- * @return A logical plan with a wrapper Project.
- */
- logical::LogicalPtr RenameOutputColumns(
- const logical::LogicalPtr &logical_plan,
- const ParseTableReferenceSignature &table_signature);
-
- /**
- * @brief Sort the input table in (p_key, o_key) order specified by the window.
- *
- * @param logical_plan The input logical node.
- * @param window_info The window that the input table has to be sorted accordingly.
- * @return A logical plan that sorts the table according to window_info.
- **/
- logical::LogicalPtr resolveSortInWindow(
- const logical::LogicalPtr &logical_plan,
- const expressions::WindowInfo &window_info);
-
- /**
- * @brief Resolves a parse expression and converts it to a scalar expression
- * in the query optimizer. A non-scalar parse expression is resolved
- * to an AttributeReference to another optimizer expression.
- *
- * @param parse_expression The parse expression to be resolved.
- * @param type_hint A hint about what Type the expression is expected to be
- * (e.g. an attribute's type in an INSERT or UPDATE query). May be
- * NULL if there is no expectation, or the expectation is ambiguous.
- * This is passed through to ParseLiteralValue::concretize().
- * @param expression_resolution_info Resolution info that contains the name
- * resolver and info to be updated after
- * resolution.
- * @return An expression in the query optimizer.
- */
- expressions::ScalarPtr resolveExpression(
- const ParseExpression &parse_expression,
- const Type *type_hint,
- ExpressionResolutionInfo *expression_resolution_info);
-
- /**
- * @brief Resolves a searched CASE expression.
- *
- * @param type_hint The expected result type of this expression.
- * @param parse_searched_case_expression The parsed searched CASE expression
- * to be resolved.
- * @param expresssion_resolution_info Resolution info that contains the name
- * resolver and info to be updated after resolution.
- * @return An optimizer expression for the CASE expression.
- */
- expressions::ScalarPtr resolveSearchedCaseExpression(
- const ParseSearchedCaseExpression &parse_searched_case_expression,
- const Type *type_hint,
- ExpressionResolutionInfo *expression_resolution_info);
-
- /**
- * @brief Resolves a simple CASE expression.
- *
- * @param type_hint The expected result type of this expression.
- * @param parse_simple_case_expression The parsed simple CASE expression
- * to be resolved.
- * @param expresssion_resolution_info Resolution info that contains the name
- * resolver and info to be updated after resolution.
- * @return An optimizer expression for the CASE expression.
- */
- expressions::ScalarPtr resolveSimpleCaseExpression(
- const ParseSimpleCaseExpression &parse_simple_case_expression,
- const Type *type_hint,
- ExpressionResolutionInfo *expression_resolution_info);
-
- /**
- * @brief Resolves a function call. For a non-scalar function, the returned
- * expression is an AttributeReference to the actual resolved expression.
- *
- * @note This currently only handles resolving aggregate functions and window
- * aggregate functions.
- *
- * @param parse_function_call The function call to be resolved.
- * @param expression_resolution_info Resolution info that contains the name
- * resolver and info to be updated after
- * resolution.
- * @return An expression in the query optimizer.
- */
- expressions::ScalarPtr resolveFunctionCall(
- const ParseFunctionCall &parse_function_call,
- ExpressionResolutionInfo *expression_resolution_info);
-
- /**
- * @brief Resolves a window aggregate function.
- *
- * @param parse_function_call The function call to be resolved.
- * @param expression_resolution_info Resolution info that contains the name
- * resolver and info to be updated after
- * resolution.
- * @param aggregate The window aggregate function.
- * @param resolved_arguments The resolved arguments.
- * @return An expression in the query optimizer.
- */
- expressions::ScalarPtr resolveWindowAggregateFunction(
- const ParseFunctionCall &parse_function_call,
- ExpressionResolutionInfo *expression_resolution_info,
- const ::quickstep::WindowAggregateFunction *aggregate,
- const std::vector<expressions::ScalarPtr> &resolved_arguments);
-
- /**
- * @brief Resolves a parse Predicate and converts it to a predicate in the
- * query optimizer.
- *
- * @param parse_predicate The parse predicate to be resolved.
- * @param expression_resolution_info Resolution info that contains the name
- * resolver and info to be updated after
- * resolution.
- * @return A predicate in the query optimizer
- */
- expressions::PredicatePtr resolvePredicate(
- const ParsePredicate &parse_predicate,
- ExpressionResolutionInfo *expression_resolution_info);
-
- /**
- * @brief Convenient method to resolve a list of predicates that uses
- * resolvePredicate as a subroutine.
- *
- * @param parse_predicates Parse predicates to be resolved.
- * @param expression_resolution_info Resolution info that contains the name
- * resolver and info to be updated after
- * resolution.
- * @return Resolved predicates in the query optimizer
- */
- std::vector<expressions::PredicatePtr> resolvePredicates(
- const PtrList<ParsePredicate> &parse_predicates,
- ExpressionResolutionInfo *expression_resolution_info);
-
- /**
- * @brief Resolves a table/scalar subquery expression.
- *
- * @param parse_subquery_expression The parsed subquery expression.
- * @param type_hints The type hints for output columns by the subquery.
- * @param expression_resolution_info Resolution info that contains the name
- * resolver and info to be updated after resolution.
- * @param has_single_column True if the subquery is expected to return only
- * one column in the result.
- */
- expressions::SubqueryExpressionPtr resolveSubqueryExpression(
- const ParseSubqueryExpression &parse_subquery_expression,
- const std::vector<const Type*> *type_hints,
- ExpressionResolutionInfo *expression_resolution_info,
- const bool has_single_column);
-
- /**
- * @brief Resolves a window definition.
- *
- * @param parse_window The parsed window definition.
- * @param name_resolver The resolver to resolve names.
- **/
- expressions::WindowInfo resolveWindow(const ParseWindow &parse_window,
- const NameResolver &name_resolver);
-
- /**
- * @brief Resolves a relation name to a pointer to the corresponding
- * CatalogRelation with the name.
- *
- * @param relation_name The parser node of the relation name.
- * @return The CatalogRelation.
- */
- const CatalogRelation *resolveRelationName(const ParseString *relation_name);
-
- /**
- * @brief Determines whether \p op can apply to \p left_operand and \p
- * right_operand.
- *
- * @param location The location for the error message.
- * @param op The comparison operator.
- * @param left_operand The left operand.
- * @param right_operand The right operand.
- */
- void checkComparisonCanApplyTo(const ParseTreeNode *location,
- const Comparison &op,
- const expressions::ScalarPtr &left_operand,
- const expressions::ScalarPtr &right_operand) const;
-
- /**
- * @brief Generates an internal alias for an aggregate attribute.
- *
- * @param index The index of the aggregate attribute used for generating the
- * name.
- * @return A string for the name.
- */
- static std::string GenerateAggregateAttributeAlias(int index);
-
- /**
- * @brief Generates an internal alias for a window aggregate attribute.
- *
- * @param index The index of the window aggregate attribute used for
- * generating the name.
- * @return A string for the name.
- */
- static std::string GenerateWindowAggregateAttributeAlias(int index);
-
- /**
- * @brief Generates an internal alias for a grouping attribute.
- *
- * @param index The index of the grouping attribute used for generating the
- * name.
- * @return A string for the name.
- */
- static std::string GenerateGroupingAttributeAlias(int index);
-
- /**
- * @brief Generates an internal alias for an ordering attribute.
- *
- * @param index The index of an ordering attribute used for generating
- * the name.
- * @return A string for the name.
- */
- static std::string GenerateOrderingAttributeAlias(int index);
-
- /**
- * @brief Validates each SELECT-list expression to ensure that it does not
- * reference a named expression with an ID not in \p valid_expr_id_set.
- *
- * @param parse_select The parse tree for SELECT.
- * @param select_list_expressions The resolved SELECT-list expressions.
- * @param visible_expr_id_set A set of IDs of expressions visible to the
- * SELECT list.
- */
- void validateSelectExpressionsForAggregation(
- const ParseSelectionClause &parse_selection,
- const std::vector<expressions::NamedExpressionPtr> &
- select_list_expressions,
- const std::unordered_set<expressions::ExprId> &visible_expr_id_set) const;
-
- /**
- * @brief Validates each ordering expression to ensure that it does not
- * reference a named expression with an ID not in \p valid_expr_id_set.
- *
- * @param parse_order_by The parse tree for ORDER BY.
- * @param order_by_expressions The resolved order by expressions.
- * @param visible_expr_id_set A set of IDs of expressions visible to ORDER BY.
- */
- void validateOrderingExpressionsForAggregation(
- const ParseOrderBy &parse_order_by,
- const std::vector<expressions::ScalarPtr> &order_by_expressions,
- const std::unordered_set<expressions::ExprId> &visible_expr_id_set) const;
-
- /**
- * @brief Validates \p expression does not reference a name expression with an
- * ID not in \p valid_expr_id_set.
- *
- * @param location The location where to report an error at.
- * @param expression The expression to be checked.
- * @param visible_expr_id_set A set of IDs of expressions visible to the
- * expression.
- */
- void validateExpressionForAggregation(
- const ParseTreeNode *location,
- const expressions::ExpressionPtr &expression,
- const std::unordered_set<expressions::ExprId> &visible_expr_id_set) const;
-
- /**
- * @brief Rewrites \p expression if it is an integer literal that can be used
- * as an ordinal reference to a SELECT-list expression.
- *
- * @param location The location where to report an error at.
- * @param expr_resolution_info Used to know aggregate functions are allowed.
- * @param select_list_info The SELECT-list expressions info.
- * @param expression The expression to be checked and rewritten.
- */
- void rewriteIfOrdinalReference(
- const ParseTreeNode *location,
- const ExpressionResolutionInfo &expr_resolution_info,
- SelectListInfo *select_list_info, expressions::ScalarPtr *expression);
-
- /**
- * @brief Wraps \p project_plan with a Project if \p select_list_info
- * indicates that there are SELECT-list expressions
- * that do not contain aggregates and need to be precomputed (those
- * that are referenced by aliases), updates those precomputed
- * expressions in \p select_list_expressions with the references.
- *
- * @param select_list_info Select list info to determine precomputed
- * expressions.
- * @param select_list_expressions Select list expressions.
- * @param logical_plan The logical plan to be updated.
- */
- void appendProjectIfNeedPrecomputationBeforeAggregation(
- const SelectListInfo &select_list_info,
- std::vector<expressions::NamedExpressionPtr> *select_list_expressions,
- logical::LogicalPtr *logical_plan);
-
- /**
- * @brief Wraps \p project_plan with a Project if \p select_list_info
- * indicates that there are SELECT-list expressions
- * that contain aggregates and need to be precomputed (those that are
- * referenced by aliases), updates those precomputed expressions in
- * \p select_list_expressions with the references.
- *
- * @param select_list_info Select list info to determine precomputed
- * expressions.
- * @param select_list_expressions Select list expressions.
- * @param logical_plan The logical plan to be updated.
- */
- void appendProjectIfNeedPrecomputationAfterAggregation(
- const SelectListInfo &select_list_info,
- std::vector<expressions::NamedExpressionPtr> *select_list_expressions,
- logical::LogicalPtr *logical_plan);
-
- const CatalogDatabase &catalog_database_;
-
- OptimizerContext *context_;
- WithQueriesInfo with_queries_info_;
-
- logical::LogicalPtr logical_plan_;
-
- DISALLOW_COPY_AND_ASSIGN(Resolver);
-};
-
-/** @} */
-
-} // namespace resolver
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_RESOLVER_RESOLVER_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/rules/AttachLIPFilters.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/AttachLIPFilters.cpp b/query_optimizer/rules/AttachLIPFilters.cpp
deleted file mode 100644
index b3c57ab..0000000
--- a/query_optimizer/rules/AttachLIPFilters.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "query_optimizer/rules/AttachLIPFilters.hpp"
-
-#include <map>
-#include <set>
-#include <unordered_set>
-#include <unordered_map>
-#include <vector>
-#include <utility>
-
-#include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/physical/LIPFilterConfiguration.hpp"
-#include "query_optimizer/physical/Aggregate.hpp"
-#include "query_optimizer/physical/HashJoin.hpp"
-#include "query_optimizer/physical/PatternMatcher.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/physical/PhysicalType.hpp"
-#include "query_optimizer/physical/Selection.hpp"
-#include "query_optimizer/physical/TopLevelPlan.hpp"
-#include "types/TypedValue.hpp"
-#include "utility/lip_filter/LIPFilter.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-
-namespace E = ::quickstep::optimizer::expressions;
-namespace P = ::quickstep::optimizer::physical;
-
-P::PhysicalPtr AttachLIPFilters::apply(const P::PhysicalPtr &input) {
- DCHECK(input->getPhysicalType() == P::PhysicalType::kTopLevelPlan);
-
- const P::TopLevelPlanPtr top_level_plan =
- std::static_pointer_cast<const P::TopLevelPlan>(input);
- cost_model_.reset(
- new cost::StarSchemaSimpleCostModel(
- top_level_plan->shared_subplans()));
- lip_filter_configuration_.reset(new P::LIPFilterConfiguration());
-
- std::set<E::ExprId> already_filtered_attributes;
- attachLIPFilters(NodeList(input), &already_filtered_attributes);
-
- P::PhysicalPtr output;
- if (!lip_filter_configuration_->getBuildInfoMap().empty() ||
- !lip_filter_configuration_->getProbeInfoMap().empty()) {
- output = top_level_plan->copyWithLIPFilterConfiguration(
- P::LIPFilterConfigurationPtr(lip_filter_configuration_.release()));
- } else {
- output = input;
- }
- return output;
-}
-
-void AttachLIPFilters::attachLIPFilters(
- const NodeList &path,
- std::set<expressions::ExprId> *already_filtered_attributes) {
- const P::PhysicalPtr &node = path.node;
-
- // First process child nodes
- for (const auto &child : node->children()) {
- std::set<E::ExprId> child_filtered_attributes;
- attachLIPFilters(path.cons(child), &child_filtered_attributes);
- already_filtered_attributes->insert(child_filtered_attributes.begin(),
- child_filtered_attributes.end());
- }
-
- // Attach LIP filters to HashJoin/Selection/Aggregate nodes
- P::PhysicalPtr probe_child = nullptr;
- switch (node->getPhysicalType()) {
- case P::PhysicalType::kHashJoin:
- probe_child = std::static_pointer_cast<const P::HashJoin>(node)->left();
- break;
- case P::PhysicalType::kSelection:
- probe_child = std::static_pointer_cast<const P::Selection>(node)->input();
- break;
- case P::PhysicalType::kAggregate:
- probe_child = std::static_pointer_cast<const P::Aggregate>(node)->input();
- break;
- default:
- break;
- }
-
- if (probe_child != nullptr &&
- cost_model_->estimateCardinality(probe_child) > 10000000) {
- const auto &candidate_lip_filters = getProbeSideInfo(path.cons(probe_child));
- if (!candidate_lip_filters.empty()) {
- std::map<E::AttributeReferencePtr, LIPFilterInfoPtr> selected_filters;
- for (const auto &info : candidate_lip_filters) {
- auto it = selected_filters.find(info->attribute);
- if (it == selected_filters.end()) {
- selected_filters.emplace(info->attribute, info);
- } else if (LIPFilterInfo::isBetterThan(*info, *it->second)) {
- it->second = info;
- }
- }
-
- for (const auto &pair : selected_filters) {
- const E::ExprId source_attr_id = pair.second->source_attribute->id();
- if (already_filtered_attributes->find(source_attr_id)
- == already_filtered_attributes->end()) {
- lip_filter_configuration_->addBuildInfo(
- pair.second->source_attribute,
- pair.second->source,
- pair.second->estimated_cardinality * 8,
- LIPFilterType::kSingleIdentityHashFilter);
- lip_filter_configuration_->addProbeInfo(
- pair.first,
- node,
- pair.second->source_attribute,
- pair.second->source);
- already_filtered_attributes->emplace(source_attr_id);
- }
- }
- }
- }
-}
-
-const std::vector<AttachLIPFilters::LIPFilterInfoPtr>& AttachLIPFilters
- ::getBuildSideInfo(const NodeList &path) {
- const P::PhysicalPtr &node = path.node;
- if (build_side_info_.find(node) == build_side_info_.end()) {
- std::vector<LIPFilterInfoPtr> lip_filters;
-
- // 1. Gather candidate LIP filters propagated from descendant nodes.
- std::unordered_set<E::ExprId> output_attribute_ids;
- for (const auto &attr : node->getOutputAttributes()) {
- output_attribute_ids.emplace(attr->id());
- }
- switch (node->getPhysicalType()) {
- case P::PhysicalType::kAggregate:
- case P::PhysicalType::kSelection:
- case P::PhysicalType::kHashJoin: {
- for (const P::PhysicalPtr &child : node->children()) {
- for (const LIPFilterInfoPtr &info : getBuildSideInfo(path.cons(child))) {
- lip_filters.emplace_back(info);
- }
- }
- break;
- }
- default:
- break;
- }
-
- // 2. Consider the parent physical node. If it is a HashJoin,
- // then each build-side join attribute is a candidate LIP filter
- // which can be built by the BuildHashOperator that corresponds
- // to the parent HashJoin node.
- P::HashJoinPtr hash_join;
- if (path.cdr() != nullptr &&
- P::SomeHashJoin::MatchesWithConditionalCast(path.cdr()->node, &hash_join)) {
- const P::PhysicalPtr &build_node = hash_join->right();
- // TODO(jianqiao): consider probe-side info to allow cascading propagation.
- double selectivity = cost_model_->estimateSelectivity(build_node);
- // Only consider attributes that are selective.
- if (selectivity < 1.0) {
- std::size_t cardinality = cost_model_->estimateCardinality(build_node);
- for (const auto &attr : hash_join->right_join_attributes()) {
- // NOTE(jianqiao): currently we only consider attributes of primitive
- // fixed-length types.
- if (TypedValue::HashIsReversible(attr->getValueType().getTypeID())) {
- lip_filters.emplace_back(
- std::make_shared<LIPFilterInfo>(attr,
- path.cdr()->node,
- path.depth,
- selectivity,
- cardinality));
- }
- }
- }
- }
- build_side_info_.emplace(node, std::move(lip_filters));
- }
- return build_side_info_.at(node);
-}
-
-const std::vector<AttachLIPFilters::LIPFilterInfoPtr>& AttachLIPFilters
- ::getProbeSideInfo(const NodeList &path) {
- const P::PhysicalPtr &node = path.node;
- if (probe_side_info_.find(node) == probe_side_info_.end()) {
- std::vector<LIPFilterInfoPtr> lip_filters;
- if (path.cdr() != nullptr) {
- // 1. Gather candidate LIP filters propagated from ancestor nodes.
- const auto &parent_lip_filters = getProbeSideInfo(*path.cdr());
- if (!parent_lip_filters.empty()) {
- std::unordered_set<E::ExprId> output_attribute_ids;
- for (const auto &attr : node->getOutputAttributes()) {
- output_attribute_ids.emplace(attr->id());
- }
- for (const auto &info : parent_lip_filters) {
- if (output_attribute_ids.find(info->attribute->id()) != output_attribute_ids.end()) {
- lip_filters.emplace_back(info);
- }
- }
- }
-
- // 2. Consider the parent physical node. If it is an InnerHashJoin or
- // LeftSemiHashJoin, then we can propagate the build-side LIP filters
- // to the probe-side.
- P::HashJoinPtr hash_join;
- if (P::SomeHashJoin::MatchesWithConditionalCast(path.cdr()->node, &hash_join) &&
- (hash_join->join_type() == P::HashJoin::JoinType::kInnerJoin ||
- hash_join->join_type() == P::HashJoin::JoinType::kLeftSemiJoin)) {
- const P::PhysicalPtr &build_side_child = hash_join->right();
- std::unordered_map<E::ExprId, E::AttributeReferencePtr> join_attribute_pairs;
- for (std::size_t i = 0; i < hash_join->left_join_attributes().size(); ++i) {
- const E::AttributeReferencePtr probe_side_join_attribute =
- hash_join->left_join_attributes()[i];
- const E::AttributeReferencePtr build_side_join_attribute =
- hash_join->right_join_attributes()[i];
- join_attribute_pairs.emplace(build_side_join_attribute->id(),
- probe_side_join_attribute);
- }
- for (const auto &info : getBuildSideInfo(path.cdr()->cons(build_side_child))) {
- const auto pair_it = join_attribute_pairs.find(info->attribute->id());
- if (pair_it != join_attribute_pairs.end()) {
- lip_filters.emplace_back(
- std::make_shared<LIPFilterInfo>(pair_it->second,
- info->source,
- info->depth,
- info->estimated_selectivity,
- info->estimated_cardinality,
- info->attribute));
- }
- }
- }
- }
- probe_side_info_.emplace(node, std::move(lip_filters));
- }
- return probe_side_info_.at(node);
-}
-
-} // namespace optimizer
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/rules/AttachLIPFilters.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/AttachLIPFilters.hpp b/query_optimizer/rules/AttachLIPFilters.hpp
deleted file mode 100644
index b8cfc39..0000000
--- a/query_optimizer/rules/AttachLIPFilters.hpp
+++ /dev/null
@@ -1,151 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_ATTACH_LIP_FILTERS_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_RULES_ATTACH_LIP_FILTERS_HPP_
-
-#include <cstddef>
-#include <map>
-#include <memory>
-#include <set>
-#include <string>
-#include <vector>
-
-#include "query_optimizer/cost_model/StarSchemaSimpleCostModel.hpp"
-#include "query_optimizer/expressions/AttributeReference.hpp"
-#include "query_optimizer/expressions/ExprId.hpp"
-#include "query_optimizer/physical/LIPFilterConfiguration.hpp"
-#include "query_optimizer/physical/Physical.hpp"
-#include "query_optimizer/rules/Rule.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-
-/** \addtogroup OptimizerRules
- * @{
- */
-
-/**
- * @brief Rule that applies to a physical plan to attach LIPFilters.
- */
-class AttachLIPFilters : public Rule<physical::Physical> {
- public:
- /**
- * @brief Constructor.
- */
- AttachLIPFilters() {}
-
- ~AttachLIPFilters() override {}
-
- std::string getName() const override {
- return "AttachLIPFilters";
- }
-
- physical::PhysicalPtr apply(const physical::PhysicalPtr &input) override;
-
- private:
- /**
- * @brief Internal data structure for passing around LIPFilter information.
- */
- struct LIPFilterInfo {
- LIPFilterInfo(const expressions::AttributeReferencePtr &attribute_in,
- const physical::PhysicalPtr &source_in,
- const int depth_in,
- const double estimated_selectivity_in,
- const std::size_t estimated_cardinality_in,
- const expressions::AttributeReferencePtr &source_attribute_in = nullptr)
- : attribute(attribute_in),
- source(source_in),
- depth(depth_in),
- estimated_selectivity(estimated_selectivity_in),
- estimated_cardinality(estimated_cardinality_in),
- source_attribute(
- source_attribute_in == nullptr
- ? attribute_in
- : source_attribute_in) {}
-
- static bool isBetterThan(const LIPFilterInfo &a, const LIPFilterInfo &b) {
- if (a.estimated_selectivity == b.estimated_selectivity) {
- return a.depth > b.depth;
- } else {
- return a.estimated_selectivity < b.estimated_selectivity;
- }
- }
-
- expressions::AttributeReferencePtr attribute;
- physical::PhysicalPtr source;
- int depth;
- double estimated_selectivity;
- std::size_t estimated_cardinality;
- expressions::AttributeReferencePtr source_attribute;
- };
-
- typedef std::shared_ptr<const LIPFilterInfo> LIPFilterInfoPtr;
-
- /**
- * @brief Functional list data structure for internal use.
- */
- struct NodeList {
- explicit NodeList(const physical::PhysicalPtr &node_in)
- : node(node_in),
- next(nullptr),
- depth(0) {}
-
- NodeList(const physical::PhysicalPtr &node_in,
- const NodeList *next_in,
- const int depth_in)
- : node(node_in),
- next(next_in),
- depth(depth_in) {}
-
- inline const NodeList *cdr() const {
- return next;
- }
-
- inline const NodeList cons(const physical::PhysicalPtr &new_node) const {
- return NodeList(new_node, this, depth+1);
- }
-
- const physical::PhysicalPtr node;
- const NodeList *next;
- const int depth;
- };
-
- void attachLIPFilters(const NodeList &path,
- std::set<expressions::ExprId> *already_filtered_attributes);
-
- const std::vector<LIPFilterInfoPtr>& getBuildSideInfo(const NodeList &path);
-
- const std::vector<LIPFilterInfoPtr>& getProbeSideInfo(const NodeList &path);
-
- std::unique_ptr<cost::StarSchemaSimpleCostModel> cost_model_;
- std::map<physical::PhysicalPtr, std::vector<LIPFilterInfoPtr>> build_side_info_;
- std::map<physical::PhysicalPtr, std::vector<LIPFilterInfoPtr>> probe_side_info_;
- std::unique_ptr<physical::LIPFilterConfiguration> lip_filter_configuration_;
-
- DISALLOW_COPY_AND_ASSIGN(AttachLIPFilters);
-};
-
-/** @} */
-
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_RULES_ATTACH_LIP_FILTERS_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/rules/BottomUpRule.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/BottomUpRule.hpp b/query_optimizer/rules/BottomUpRule.hpp
deleted file mode 100644
index 53dff0d..0000000
--- a/query_optimizer/rules/BottomUpRule.hpp
+++ /dev/null
@@ -1,104 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_BOTTOM_UP_RULE_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_RULES_BOTTOM_UP_RULE_HPP_
-
-#include <memory>
-#include <vector>
-
-#include "query_optimizer/rules/Rule.hpp"
-#include "utility/Macros.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-
-/** \addtogroup OptimizerRules
- * @{
- */
-
-/**
- * @brief Base class for a rule that performs a bottom-up traverse on a tree.
- */
-template <class TreeType>
-class BottomUpRule : public Rule<TreeType> {
- public:
- typedef std::shared_ptr<const TreeType> TreeNodePtr;
-
- /**
- * @brief Constructor.
- */
- BottomUpRule() {}
-
- /**
- * @brief Destructor.
- */
- ~BottomUpRule() override {}
-
- TreeNodePtr apply(const TreeNodePtr &tree) override {
- DCHECK(tree != nullptr);
-
- init(tree);
- std::vector<std::shared_ptr<const TreeType>> new_children;
- bool has_changed_children = false;
- for (const std::shared_ptr<const TreeType> &child : tree->children()) {
- std::shared_ptr<const TreeType> new_child = apply(child);
- if (child != new_child && !has_changed_children) {
- has_changed_children = true;
- }
- new_children.push_back(new_child);
- }
-
- if (has_changed_children) {
- return applyToNode(tree->copyWithNewChildren(new_children));
- } else {
- return applyToNode(tree);
- }
- }
-
- protected:
- /**
- * @brief Applies the rule to a single node, not the entire tree.
- *
- * @param node The node to apply the rule to.
- * @param The updated node by the rule.
- */
- virtual TreeNodePtr applyToNode(const TreeNodePtr &node) = 0;
-
- /**
- * @brief Override this method to implement the initialization code
- * for the rule.
- *
- * @param input The input tree.
- */
- virtual void init(const TreeNodePtr &input) {
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(BottomUpRule);
-};
-
-/** @} */
-
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_RULES_BOTTOM_UP_RULE_HPP_ */
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/rules/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/CMakeLists.txt b/query_optimizer/rules/CMakeLists.txt
deleted file mode 100644
index 7fffadc..0000000
--- a/query_optimizer/rules/CMakeLists.txt
+++ /dev/null
@@ -1,222 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-add_subdirectory(tests)
-
-# Declare micro-libs:
-add_library(quickstep_queryoptimizer_rules_AttachLIPFilters AttachLIPFilters.cpp AttachLIPFilters.hpp)
-add_library(quickstep_queryoptimizer_rules_BottomUpRule ../../empty_src.cpp BottomUpRule.hpp)
-add_library(quickstep_queryoptimizer_rules_CollapseProject CollapseProject.cpp CollapseProject.hpp)
-add_library(quickstep_queryoptimizer_rules_GenerateJoins GenerateJoins.cpp GenerateJoins.hpp)
-add_library(quickstep_queryoptimizer_rules_PruneColumns PruneColumns.cpp PruneColumns.hpp)
-add_library(quickstep_queryoptimizer_rules_PushDownFilter PushDownFilter.cpp PushDownFilter.hpp)
-add_library(quickstep_queryoptimizer_rules_PushDownSemiAntiJoin PushDownSemiAntiJoin.cpp PushDownSemiAntiJoin.hpp)
-add_library(quickstep_queryoptimizer_rules_Rule ../../empty_src.cpp Rule.hpp)
-add_library(quickstep_queryoptimizer_rules_RuleHelper RuleHelper.cpp RuleHelper.hpp)
-add_library(quickstep_queryoptimizer_rules_StarSchemaHashJoinOrderOptimization
- StarSchemaHashJoinOrderOptimization.cpp
- StarSchemaHashJoinOrderOptimization.hpp)
-add_library(quickstep_queryoptimizer_rules_SwapProbeBuild SwapProbeBuild.cpp SwapProbeBuild.hpp)
-add_library(quickstep_queryoptimizer_rules_TopDownRule ../../empty_src.cpp TopDownRule.hpp)
-add_library(quickstep_queryoptimizer_rules_UpdateExpression UpdateExpression.cpp UpdateExpression.hpp)
-add_library(quickstep_queryoptimizer_rules_UnnestSubqueries UnnestSubqueries.cpp UnnestSubqueries.hpp)
-
-
-# Link dependencies:
-target_link_libraries(quickstep_queryoptimizer_rules_AttachLIPFilters
- quickstep_queryoptimizer_costmodel_StarSchemaSimpleCostModel
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_expressions_ExprId
- quickstep_queryoptimizer_physical_Aggregate
- quickstep_queryoptimizer_physical_HashJoin
- quickstep_queryoptimizer_physical_LIPFilterConfiguration
- quickstep_queryoptimizer_physical_PatternMatcher
- quickstep_queryoptimizer_physical_Physical
- quickstep_queryoptimizer_physical_PhysicalType
- quickstep_queryoptimizer_physical_Selection
- quickstep_queryoptimizer_physical_TopLevelPlan
- quickstep_queryoptimizer_rules_Rule
- quickstep_types_TypedValue
- quickstep_utility_Macros
- quickstep_utility_lipfilter_LIPFilter)
-target_link_libraries(quickstep_queryoptimizer_rules_BottomUpRule
- glog
- quickstep_queryoptimizer_rules_Rule
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_CollapseProject
- glog
- quickstep_queryoptimizer_expressions_NamedExpression
- quickstep_queryoptimizer_logical_Logical
- quickstep_queryoptimizer_logical_PatternMatcher
- quickstep_queryoptimizer_logical_Project
- quickstep_queryoptimizer_rules_BottomUpRule
- quickstep_queryoptimizer_rules_Rule
- quickstep_queryoptimizer_rules_RuleHelper
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_GenerateJoins
- glog
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_expressions_ComparisonExpression
- quickstep_queryoptimizer_expressions_ExpressionUtil
- quickstep_queryoptimizer_expressions_LogicalAnd
- quickstep_queryoptimizer_expressions_PatternMatcher
- quickstep_queryoptimizer_expressions_Predicate
- quickstep_queryoptimizer_logical_Filter
- quickstep_queryoptimizer_logical_HashJoin
- quickstep_queryoptimizer_logical_Logical
- quickstep_queryoptimizer_logical_MultiwayCartesianJoin
- quickstep_queryoptimizer_logical_NestedLoopsJoin
- quickstep_queryoptimizer_logical_PatternMatcher
- quickstep_queryoptimizer_rules_Rule
- quickstep_queryoptimizer_rules_RuleHelper
- quickstep_queryoptimizer_rules_TopDownRule
- quickstep_types_operations_comparisons_ComparisonFactory
- quickstep_types_operations_comparisons_ComparisonID
- quickstep_utility_Macros
- quickstep_utility_SqlError
- quickstep_utility_VectorUtil)
-target_link_libraries(quickstep_queryoptimizer_rules_PruneColumns
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_expressions_ExpressionUtil
- quickstep_queryoptimizer_expressions_NamedExpression
- quickstep_queryoptimizer_physical_PatternMatcher
- quickstep_queryoptimizer_physical_Physical
- quickstep_queryoptimizer_rules_Rule
- quickstep_queryoptimizer_rules_TopDownRule
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_PushDownFilter
- glog
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_expressions_ExpressionUtil
- quickstep_queryoptimizer_logical_Filter
- quickstep_queryoptimizer_logical_HashJoin
- quickstep_queryoptimizer_logical_Logical
- quickstep_queryoptimizer_logical_PatternMatcher
- quickstep_queryoptimizer_rules_Rule
- quickstep_queryoptimizer_rules_RuleHelper
- quickstep_queryoptimizer_rules_TopDownRule
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_PushDownSemiAntiJoin
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_expressions_ExpressionUtil
- quickstep_queryoptimizer_logical_HashJoin
- quickstep_queryoptimizer_logical_Logical
- quickstep_queryoptimizer_logical_PatternMatcher
- quickstep_queryoptimizer_rules_TopDownRule
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_Rule
- glog
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_RuleHelper
- quickstep_queryoptimizer_expressions_Alias
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_expressions_ExprId
- quickstep_queryoptimizer_expressions_Expression
- quickstep_queryoptimizer_expressions_LogicalAnd
- quickstep_queryoptimizer_expressions_NamedExpression
- quickstep_queryoptimizer_expressions_PatternMatcher
- quickstep_queryoptimizer_expressions_Predicate
- quickstep_queryoptimizer_rules_UpdateExpression)
-target_link_libraries(quickstep_queryoptimizer_rules_StarSchemaHashJoinOrderOptimization
- quickstep_queryoptimizer_costmodel_StarSchemaSimpleCostModel
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_expressions_ExprId
- quickstep_queryoptimizer_expressions_NamedExpression
- quickstep_queryoptimizer_expressions_PatternMatcher
- quickstep_queryoptimizer_expressions_Predicate
- quickstep_queryoptimizer_physical_Aggregate
- quickstep_queryoptimizer_physical_HashJoin
- quickstep_queryoptimizer_physical_PatternMatcher
- quickstep_queryoptimizer_physical_Physical
- quickstep_queryoptimizer_physical_PhysicalType
- quickstep_queryoptimizer_physical_TopLevelPlan
- quickstep_queryoptimizer_rules_Rule
- quickstep_utility_DisjointTreeForest
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_SwapProbeBuild
- quickstep_queryoptimizer_costmodel_SimpleCostModel
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_physical_HashJoin
- quickstep_queryoptimizer_physical_PatternMatcher
- quickstep_queryoptimizer_physical_Physical
- quickstep_queryoptimizer_physical_TopLevelPlan
- quickstep_queryoptimizer_rules_BottomUpRule
- quickstep_queryoptimizer_rules_Rule
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_TopDownRule
- quickstep_queryoptimizer_rules_Rule
- quickstep_utility_Macros)
-target_link_libraries(quickstep_queryoptimizer_rules_UnnestSubqueries
- quickstep_queryoptimizer_OptimizerContext
- quickstep_queryoptimizer_expressions_AttributeReference
- quickstep_queryoptimizer_expressions_ComparisonExpression
- quickstep_queryoptimizer_expressions_Exists
- quickstep_queryoptimizer_expressions_ExprId
- quickstep_queryoptimizer_expressions_Expression
- quickstep_queryoptimizer_expressions_ExpressionType
- quickstep_queryoptimizer_expressions_ExpressionUtil
- quickstep_queryoptimizer_expressions_InTableQuery
- quickstep_queryoptimizer_expressions_LogicalAnd
- quickstep_queryoptimizer_expressions_LogicalNot
- quickstep_queryoptimizer_expressions_LogicalOr
- quickstep_queryoptimizer_expressions_NamedExpression
- quickstep_queryoptimizer_expressions_PatternMatcher
- quickstep_queryoptimizer_expressions_Predicate
- quickstep_queryoptimizer_expressions_SubqueryExpression
- quickstep_queryoptimizer_logical_Aggregate
- quickstep_queryoptimizer_logical_Filter
- quickstep_queryoptimizer_logical_HashJoin
- quickstep_queryoptimizer_logical_Logical
- quickstep_queryoptimizer_logical_LogicalType
- quickstep_queryoptimizer_logical_MultiwayCartesianJoin
- quickstep_queryoptimizer_logical_PatternMatcher
- quickstep_queryoptimizer_logical_Project
- quickstep_queryoptimizer_logical_TopLevelPlan
- quickstep_queryoptimizer_rules_BottomUpRule
- quickstep_queryoptimizer_rules_Rule
- quickstep_types_operations_comparisons_Comparison
- quickstep_types_operations_comparisons_ComparisonFactory
- quickstep_types_operations_comparisons_ComparisonID
- quickstep_utility_Macros
- quickstep_utility_SqlError)
-target_link_libraries(quickstep_queryoptimizer_rules_UpdateExpression
- glog
- quickstep_queryoptimizer_expressions_ExprId
- quickstep_queryoptimizer_expressions_Expression
- quickstep_queryoptimizer_expressions_NamedExpression
- quickstep_queryoptimizer_expressions_PatternMatcher
- quickstep_queryoptimizer_rules_BottomUpRule
- quickstep_queryoptimizer_rules_Rule
- quickstep_utility_Macros)
-
-# Module all-in-one library:
-add_library(quickstep_queryoptimizer_rules ../../empty_src.cpp OptimizerRulesModule.hpp)
-target_link_libraries(quickstep_queryoptimizer_rules
- quickstep_queryoptimizer_rules_AttachLIPFilters
- quickstep_queryoptimizer_rules_BottomUpRule
- quickstep_queryoptimizer_rules_CollapseProject
- quickstep_queryoptimizer_rules_GenerateJoins
- quickstep_queryoptimizer_rules_PruneColumns
- quickstep_queryoptimizer_rules_PushDownFilter
- quickstep_queryoptimizer_rules_PushDownSemiAntiJoin
- quickstep_queryoptimizer_rules_Rule
- quickstep_queryoptimizer_rules_RuleHelper
- quickstep_queryoptimizer_rules_StarSchemaHashJoinOrderOptimization
- quickstep_queryoptimizer_rules_SwapProbeBuild
- quickstep_queryoptimizer_rules_TopDownRule
- quickstep_queryoptimizer_rules_UpdateExpression
- quickstep_queryoptimizer_rules_UnnestSubqueries)
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/rules/CollapseProject.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/CollapseProject.cpp b/query_optimizer/rules/CollapseProject.cpp
deleted file mode 100644
index 31aba17..0000000
--- a/query_optimizer/rules/CollapseProject.cpp
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#include "query_optimizer/rules/CollapseProject.hpp"
-
-#include <vector>
-
-#include "query_optimizer/expressions/NamedExpression.hpp"
-#include "query_optimizer/logical/Logical.hpp"
-#include "query_optimizer/logical/PatternMatcher.hpp"
-#include "query_optimizer/logical/Project.hpp"
-#include "query_optimizer/rules/Rule.hpp"
-#include "query_optimizer/rules/RuleHelper.hpp"
-
-#include "glog/logging.h"
-
-namespace quickstep {
-namespace optimizer {
-
-namespace E = ::quickstep::optimizer::expressions;
-namespace L = ::quickstep::optimizer::logical;
-
-L::LogicalPtr CollapseProject::applyToNode(const L::LogicalPtr &input) {
- L::ProjectPtr project;
- L::ProjectPtr child_project;
-
- if (L::SomeProject::MatchesWithConditionalCast(input, &project) &&
- L::SomeProject::MatchesWithConditionalCast(project->input(), &child_project)) {
- std::vector<E::NamedExpressionPtr> project_expressions =
- project->project_expressions();
- PullUpProjectExpressions(child_project->project_expressions(),
- {} /* non_project_expression_lists */,
- {&project_expressions} /* project_expression_lists */);
- L::LogicalPtr output = L::Project::Create(child_project->input(), project_expressions);
- LOG_APPLYING_RULE(input, output);
- return output;
- }
-
- LOG_IGNORING_RULE(input);
- return input;
-}
-
-} // namespace optimizer
-} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/query_optimizer/rules/CollapseProject.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/CollapseProject.hpp b/query_optimizer/rules/CollapseProject.hpp
deleted file mode 100644
index bd1a991..0000000
--- a/query_optimizer/rules/CollapseProject.hpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- **/
-
-#ifndef QUICKSTEP_QUERY_OPTIMIZER_RULES_COLLAPSE_PROJECT_HPP_
-#define QUICKSTEP_QUERY_OPTIMIZER_RULES_COLLAPSE_PROJECT_HPP_
-
-#include <string>
-#include <vector>
-
-#include "query_optimizer/logical/Logical.hpp"
-#include "query_optimizer/rules/BottomUpRule.hpp"
-#include "utility/Macros.hpp"
-
-namespace quickstep {
-namespace optimizer {
-
-/** \addtogroup OptimizerRules
- * @{
- */
-
-/**
- * @brief Merges nested Projects into one single Project.
- */
-class CollapseProject : public BottomUpRule<logical::Logical> {
- public:
- CollapseProject() {}
-
- std::string getName() const override { return "CollapseProject"; }
-
- protected:
- logical::LogicalPtr applyToNode(const logical::LogicalPtr &input) override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CollapseProject);
-};
-
-/** @} */
-
-} // namespace optimizer
-} // namespace quickstep
-
-#endif /* QUICKSTEP_QUERY_OPTIMIZER_RULES_COLLAPSE_PROJECT_HPP_ */