OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QueryRewrite.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <list>
20 #include <memory>
21 #include <set>
22 #include <utility>
23 #include <vector>
24 #include "Analyzer/Analyzer.h"
25 #include "Fragmenter/Fragmenter.h"
26 #include "QueryEngine/Execute.h"
27 
29  public:
30  QueryRewriter(const std::vector<InputTableInfo>& query_infos, Executor* executor)
31  : query_infos_(query_infos), executor_(executor) {}
32  RelAlgExecutionUnit rewrite(const RelAlgExecutionUnit& ra_exe_unit_in) const;
33 
35  const RelAlgExecutionUnit& ra_exe_unit_in,
36  std::shared_ptr<Analyzer::Expr> column_to_update) const;
37 
39  const RelAlgExecutionUnit& ra_exe_unit_in,
40  std::shared_ptr<Analyzer::ColumnVar> delete_column) const;
41 
43  const RelAlgExecutionUnit& ra_exe_unit_in) const;
44 
45  private:
47  const RelAlgExecutionUnit& ra_exe_unit_in) const;
48 
50  const RelAlgExecutionUnit& ra_exe_unit_in) const;
51 
53  const RelAlgExecutionUnit& ra_exe_unit_in,
54  const std::shared_ptr<Analyzer::CaseExpr>,
55  const Analyzer::InValues*) const;
56 
57  static std::shared_ptr<Analyzer::CaseExpr> generateCaseForDomainValues(
58  const Analyzer::InValues*);
59 
60  std::pair<bool, std::set<size_t>> is_all_groupby_exprs_are_col_var(
61  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby_exprs) const;
62 
63  std::shared_ptr<Analyzer::CaseExpr> generateCaseExprForCountDistinctOnGroupByCol(
64  std::shared_ptr<Analyzer::Expr> expr) const;
65 
66  const std::vector<InputTableInfo>& query_infos_;
67  Executor* executor_;
68  mutable std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_;
69 };
Defines data structures for the semantic analysis phase of query processing.
RelAlgExecutionUnit rewrite(const RelAlgExecutionUnit &ra_exe_unit_in) const
std::pair< bool, std::set< size_t > > is_all_groupby_exprs_are_col_var(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby_exprs) const
Executor * executor_
Definition: QueryRewrite.h:67
RelAlgExecutionUnit rewriteOverlapsJoin(const RelAlgExecutionUnit &ra_exe_unit_in) const
RelAlgExecutionUnit rewriteColumnarUpdate(const RelAlgExecutionUnit &ra_exe_unit_in, std::shared_ptr< Analyzer::Expr > column_to_update) const
const std::vector< InputTableInfo > & query_infos_
Definition: QueryRewrite.h:66
std::shared_ptr< Analyzer::CaseExpr > generateCaseExprForCountDistinctOnGroupByCol(std::shared_ptr< Analyzer::Expr > expr) const
RelAlgExecutionUnit rewriteColumnarDelete(const RelAlgExecutionUnit &ra_exe_unit_in, std::shared_ptr< Analyzer::ColumnVar > delete_column) const
QueryRewriter(const std::vector< InputTableInfo > &query_infos, Executor *executor)
Definition: QueryRewrite.h:30
static std::shared_ptr< Analyzer::CaseExpr > generateCaseForDomainValues(const Analyzer::InValues *)
RelAlgExecutionUnit rewriteConstrainedByIn(const RelAlgExecutionUnit &ra_exe_unit_in) const
RelAlgExecutionUnit rewriteAggregateOnGroupByColumn(const RelAlgExecutionUnit &ra_exe_unit_in) const
RelAlgExecutionUnit rewriteConstrainedByInImpl(const RelAlgExecutionUnit &ra_exe_unit_in, const std::shared_ptr< Analyzer::CaseExpr >, const Analyzer::InValues *) const
std::vector< std::shared_ptr< Analyzer::Expr > > target_exprs_owned_
Definition: QueryRewrite.h:68