OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParserWrapper.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 
23 // TODO(sy): We already use Calcite, which is a powerful general-purpose parser tool, so
24 // ParserWrapper has no good reason to exist. Any work happening in here should be moved
25 // into our Java Calcite classes and ParserWrapper should be removed from HeavyDB.
26 
27 #pragma once
28 
29 #include <string>
30 #include <vector>
31 
33 
34 class ExplainInfo {
35  public:
36  enum class ExplainType {
37  None,
38  IR,
40  Calcite,
43  Other
44  };
45 
48  ExplainInfo(std::string query_string);
49 
50  bool isExplain() const { return explain_type_ != ExplainType::None; }
51 
52  bool isJustExplain() const {
53  return explain_type_ == ExplainType::IR ||
56  }
57 
58  bool isSelectExplain() const {
59  return explain_type_ == ExplainType::IR ||
64  }
65 
66  bool isIRExplain() const {
68  }
69 
71  bool isCalciteExplain() const {
74  }
75  bool isCalciteExplainDetail() const {
77  }
79  bool isOtherExplain() const { return explain_type_ == ExplainType::Other; }
80 
81  std::string ActualQuery() { return actual_query_; }
82 
83  bool isVerbose() const { return verbose_; }
84 
85  private:
87  std::string actual_query_ = "";
88  bool verbose_{false};
89 };
90 
92  public:
93  // HACK: This needs to go away as calcite takes over parsing
94  enum class DMLType : int { Insert = 0, Delete, Update, NotDML };
95 
97 
98  ParserWrapper(std::string query_string);
99  std::string process(std::string user,
100  std::string passwd,
101  std::string catalog,
102  std::string sql_string,
103  const bool legacy_syntax);
104  virtual ~ParserWrapper();
105 
106  bool is_ddl = false;
107  bool is_update_dml = false; // INSERT DELETE UPDATE
108  bool is_ctas = false;
109  bool is_itas = false;
110  bool is_copy = false;
111  bool is_copy_to = false;
112  bool is_validate = false;
113  bool is_other_explain = false;
114  bool is_refresh = false;
115 
116  DMLType getDMLType() const { return dml_type_; }
117 
118  QueryType getQueryType() const { return query_type_; }
119 
120  bool isUpdateDelete() const {
122  }
123 
124  private:
127 
128  static const std::vector<std::string> ddl_cmd;
129  static const std::vector<std::string> update_dml_cmd;
130 };
QueryType query_type_
virtual ~ParserWrapper()
bool isCalciteExplainDetail() const
Definition: ParserWrapper.h:75
bool isVerbose() const
Definition: ParserWrapper.h:83
std::string process(std::string user, std::string passwd, std::string catalog, std::string sql_string, const bool legacy_syntax)
DMLType dml_type_
std::string ActualQuery()
Definition: ParserWrapper.h:81
std::string actual_query_
Definition: ParserWrapper.h:87
bool isOtherExplain() const
Definition: ParserWrapper.h:79
QueryType getQueryType() const
static const std::vector< std::string > ddl_cmd
bool isOptimizedExplain() const
Definition: ParserWrapper.h:70
DMLType getDMLType() const
bool isSelectExplain() const
Definition: ParserWrapper.h:58
bool isJustExplain() const
Definition: ParserWrapper.h:52
static const std::vector< std::string > update_dml_cmd
ExplainType explain_type_
Definition: ParserWrapper.h:86
bool isExplain() const
Definition: ParserWrapper.h:50
ParserWrapper(std::string query_string)
bool isUpdateDelete() const
bool isCalciteExplain() const
Definition: ParserWrapper.h:71
ExplainInfo(ExplainType type)
Definition: ParserWrapper.h:47
bool isPlanExplain() const
Definition: ParserWrapper.h:78
bool isIRExplain() const
Definition: ParserWrapper.h:66