OmniSciDB  ca0c39ec8f
 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 #pragma once
24 
25 #include <string>
26 #include <vector>
27 
29 
30 class ExplainInfo {
31  public:
33 
36  ExplainInfo(std::string query_string);
37 
38  bool isExplain() const { return explain_type_ != ExplainType::None; }
39 
40  bool isJustExplain() const {
41  return explain_type_ == ExplainType::IR ||
44  }
45 
46  bool isSelectExplain() const {
47  return explain_type_ == ExplainType::IR ||
51  }
52 
53  bool isIRExplain() const {
55  }
56 
60  bool isOtherExplain() const { return explain_type_ == ExplainType::Other; }
61 
62  std::string ActualQuery() { return actual_query_; }
63 
64  private:
66  std::string actual_query_ = "";
67 };
68 
70  public:
71  // HACK: This needs to go away as calcite takes over parsing
72  enum class DMLType : int { Insert = 0, Delete, Update, NotDML };
73 
75 
76  ParserWrapper(std::string query_string);
77  std::string process(std::string user,
78  std::string passwd,
79  std::string catalog,
80  std::string sql_string,
81  const bool legacy_syntax);
82  virtual ~ParserWrapper();
83 
84  bool is_ddl = false;
85  bool is_update_dml = false; // INSERT DELETE UPDATE
86  bool is_ctas = false;
87  bool is_itas = false;
88  bool is_copy = false;
89  bool is_copy_to = false;
90  bool is_validate = false;
91  bool is_other_explain = false;
92  bool is_refresh = false;
93 
94  DMLType getDMLType() const { return dml_type_; }
95 
96  QueryType getQueryType() const { return query_type_; }
97 
98  bool isUpdateDelete() const {
100  }
101 
102  private:
105 
106  static const std::vector<std::string> ddl_cmd;
107  static const std::vector<std::string> update_dml_cmd;
108 };
QueryType query_type_
virtual ~ParserWrapper()
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:62
std::string actual_query_
Definition: ParserWrapper.h:66
bool is_other_explain
Definition: ParserWrapper.h:91
bool isOtherExplain() const
Definition: ParserWrapper.h:60
QueryType getQueryType() const
Definition: ParserWrapper.h:96
static const std::vector< std::string > ddl_cmd
bool isOptimizedExplain() const
Definition: ParserWrapper.h:57
DMLType getDMLType() const
Definition: ParserWrapper.h:94
bool isSelectExplain() const
Definition: ParserWrapper.h:46
bool isJustExplain() const
Definition: ParserWrapper.h:40
static const std::vector< std::string > update_dml_cmd
ExplainType explain_type_
Definition: ParserWrapper.h:65
bool isExplain() const
Definition: ParserWrapper.h:38
ParserWrapper(std::string query_string)
bool isUpdateDelete() const
Definition: ParserWrapper.h:98
bool isCalciteExplain() const
Definition: ParserWrapper.h:58
ExplainInfo(ExplainType type)
Definition: ParserWrapper.h:35
bool isPlanExplain() const
Definition: ParserWrapper.h:59
bool isIRExplain() const
Definition: ParserWrapper.h:53