OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sqldefs.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 
24 #ifndef SQLDEFS_H
25 #define SQLDEFS_H
26 
27 // must not change the order without keeping the array in OperExpr::to_string
28 // in sync.
29 enum SQLOps {
30  kEQ = 0,
32  kNE,
33  kLT,
34  kGT,
35  kLE,
36  kGE,
38  kOR,
53  kIN,
55 };
56 
57 #define IS_COMPARISON(X) \
58  ((X) == kEQ || (X) == kBW_EQ || (X) == kOVERLAPS || (X) == kNE || (X) == kLT || \
59  (X) == kGT || (X) == kLE || (X) == kGE)
60 #define IS_LOGIC(X) ((X) == kAND || (X) == kOR)
61 #define IS_ARITHMETIC(X) \
62  ((X) == kMINUS || (X) == kPLUS || (X) == kMULTIPLY || (X) == kDIVIDE || (X) == kMODULO)
63 #define COMMUTE_COMPARISON(X) \
64  ((X) == kLT ? kGT : (X) == kLE ? kGE : (X) == kGT ? kLT : (X) == kGE ? kLE : (X))
65 #define IS_UNARY(X) \
66  ((X) == kNOT || (X) == kUMINUS || (X) == kISNULL || (X) == kEXISTS || (X) == kCAST)
67 #define IS_EQUIVALENCE(X) ((X) == kEQ || (X) == kBW_EQ || (X) == kOVERLAPS)
68 
70 
71 enum SQLAgg {
81 };
82 
84  ROW_NUMBER,
85  RANK,
86  DENSE_RANK,
88  CUME_DIST,
89  NTILE,
90  LAG,
91  LEAD,
93  LAST_VALUE,
94  AVG,
95  MIN,
96  MAX,
97  SUM,
98  COUNT,
99  SUM_INTERNAL // For deserialization from Calcite only. Gets rewritten to a regular SUM.
100 };
101 
103 
104 enum StorageOption { kDISK = 0, kGPU = 1, kCPU = 2 };
105 
106 enum ViewRefreshOption { kMANUAL = 0, kAUTO = 1, kIMMEDIATE = 2 };
107 
108 enum class JoinType { INNER, LEFT, SEMI, ANTI, INVALID };
109 
110 #ifndef __CUDACC__
111 
112 #include <string>
113 #include "Logger/Logger.h"
114 
115 inline std::string toString(const JoinType& join_type) {
116  switch (join_type) {
117  case JoinType::INNER:
118  return "INNER";
119  case JoinType::LEFT:
120  return "LEFT";
121  case JoinType::SEMI:
122  return "SEMI";
123  case JoinType::ANTI:
124  return "ANTI";
125  default:
126  return "INVALID";
127  }
128 }
129 
130 inline std::string toString(const SQLQualifier& qualifier) {
131  switch (qualifier) {
132  case kONE:
133  return "ONE";
134  case kANY:
135  return "ANY";
136  case kALL:
137  return "ALL";
138  }
139  LOG(FATAL) << "Invalid SQLQualifier: " << qualifier;
140  return "";
141 }
142 
143 inline std::string toString(const SQLAgg& kind) {
144  switch (kind) {
145  case kAVG:
146  return "AVG";
147  case kMIN:
148  return "MIN";
149  case kMAX:
150  return "MAX";
151  case kSUM:
152  return "SUM";
153  case kCOUNT:
154  return "COUNT";
156  return "APPROX_COUNT_DISTINCT";
157  case kAPPROX_QUANTILE:
158  return "APPROX_PERCENTILE";
159  case kSAMPLE:
160  return "SAMPLE";
161  case kSINGLE_VALUE:
162  return "SINGLE_VALUE";
163  }
164  LOG(FATAL) << "Invalid aggregate kind: " << kind;
165  return "";
166 }
167 
168 inline std::string toString(const SQLOps& op) {
169  switch (op) {
170  case kEQ:
171  return "EQ";
172  case kBW_EQ:
173  return "BW_EQ";
174  case kNE:
175  return "NE";
176  case kLT:
177  return "LT";
178  case kGT:
179  return "GT";
180  case kLE:
181  return "LE";
182  case kGE:
183  return "GE";
184  case kAND:
185  return "AND";
186  case kOR:
187  return "OR";
188  case kNOT:
189  return "NOT";
190  case kMINUS:
191  return "MINUS";
192  case kPLUS:
193  return "PLUS";
194  case kMULTIPLY:
195  return "MULTIPLY";
196  case kDIVIDE:
197  return "DIVIDE";
198  case kMODULO:
199  return "MODULO";
200  case kUMINUS:
201  return "UMINUS";
202  case kISNULL:
203  return "ISNULL";
204  case kISNOTNULL:
205  return "ISNOTNULL";
206  case kEXISTS:
207  return "EXISTS";
208  case kCAST:
209  return "CAST";
210  case kARRAY_AT:
211  return "ARRAY_AT";
212  case kUNNEST:
213  return "UNNEST";
214  case kFUNCTION:
215  return "FUNCTION";
216  case kIN:
217  return "IN";
218  case kOVERLAPS:
219  return "OVERLAPS";
220  }
221  LOG(FATAL) << "Invalid operation kind: " << op;
222  return "";
223 }
224 
225 inline std::string toString(const SqlWindowFunctionKind& kind) {
226  switch (kind) {
228  return "ROW_NUMBER";
230  return "RANK";
232  return "DENSE_RANK";
234  return "PERCENT_RANK";
236  return "CUME_DIST";
238  return "NTILE";
240  return "LAG";
242  return "LEAD";
244  return "FIRST_VALUE";
246  return "LAST_VALUE";
248  return "AVG";
250  return "MIN";
252  return "MAX";
254  return "SUM";
256  return "COUNT";
258  return "SUM_INTERNAL";
259  }
260  LOG(FATAL) << "Invalid window function kind.";
261  return "";
262 }
263 
264 #endif
265 
266 #endif // SQLDEFS_H
Definition: sqldefs.h:69
SQLAgg
Definition: sqldefs.h:71
ViewRefreshOption
Definition: sqldefs.h:106
Definition: sqldefs.h:104
JoinType
Definition: sqldefs.h:108
std::string toString(const ExtArgumentType &sig_type)
SQLQualifier
Definition: sqldefs.h:69
#define LOG(tag)
Definition: Logger.h:203
SQLOps
Definition: sqldefs.h:29
Definition: sqldefs.h:35
Definition: sqldefs.h:36
Definition: sqldefs.h:38
Definition: sqldefs.h:49
Definition: sqldefs.h:30
Definition: sqldefs.h:41
Definition: sqldefs.h:73
Definition: sqldefs.h:37
Definition: sqldefs.h:75
Definition: sqldefs.h:69
StorageOption
Definition: sqldefs.h:104
SQLStmtType
Definition: sqldefs.h:102
Definition: sqldefs.h:34
Definition: sqldefs.h:40
Definition: sqldefs.h:69
Definition: sqldefs.h:104
Definition: sqldefs.h:32
Definition: sqldefs.h:76
Definition: sqldefs.h:106
SqlWindowFunctionKind
Definition: sqldefs.h:83
Definition: sqldefs.h:53
Definition: sqldefs.h:31
Definition: sqldefs.h:33
Definition: sqldefs.h:74
Definition: sqldefs.h:72
Definition: sqldefs.h:39
Definition: sqldefs.h:104