OmniSciDB  72c90bc290
 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 2022 HEAVY.AI, 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::ColumnVar> 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,
51  const std::shared_ptr<Analyzer::CaseExpr>,
52  const Analyzer::InValues*) const;
53 
54  static std::shared_ptr<Analyzer::CaseExpr> generateCaseForDomainValues(
55  const Analyzer::InValues*);
56 
57  std::pair<bool, std::set<size_t>> is_all_groupby_exprs_are_col_var(
58  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby_exprs) const;
59 
60  std::shared_ptr<Analyzer::CaseExpr> generateCaseExprForCountDistinctOnGroupByCol(
61  std::shared_ptr<Analyzer::Expr> expr) const;
62 
63  const std::vector<InputTableInfo>& query_infos_;
64  Executor* executor_;
65  mutable std::vector<std::shared_ptr<Analyzer::Expr>> target_exprs_owned_;
66 };
Defines data structures for the semantic analysis phase of query processing.
RelAlgExecutionUnit rewriteColumnarUpdate(const RelAlgExecutionUnit &ra_exe_unit_in, std::shared_ptr< Analyzer::ColumnVar > column_to_update) const
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:64
const std::vector< InputTableInfo > & query_infos_
Definition: QueryRewrite.h:63
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:65