OmniSciDB  340b00dbf6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 {
80 };
81 
83  ROW_NUMBER,
84  RANK,
85  DENSE_RANK,
87  CUME_DIST,
88  NTILE,
89  LAG,
90  LEAD,
92  LAST_VALUE,
93  AVG,
94  MIN,
95  MAX,
96  SUM,
97  COUNT,
98  SUM_INTERNAL // For deserialization from Calcite only. Gets rewritten to a regular SUM.
99 };
100 
102 
103 enum StorageOption { kDISK = 0, kGPU = 1, kCPU = 2 };
104 
105 enum ViewRefreshOption { kMANUAL = 0, kAUTO = 1, kIMMEDIATE = 2 };
106 
107 enum class JoinType { INNER, LEFT, INVALID };
108 
109 #ifndef __CUDACC__
110 
111 #include <string>
112 #include "Logger/Logger.h"
113 
114 inline std::string toString(const SQLAgg& kind) {
115  switch (kind) {
116  case kAVG:
117  return "AVG";
118  case kMIN:
119  return "MIN";
120  case kMAX:
121  return "MAX";
122  case kSUM:
123  return "SUM";
124  case kCOUNT:
125  return "COUNT";
127  return "APPROX_COUNT_DISTINCT";
128  case kSAMPLE:
129  return "SAMPLE";
130  case kSINGLE_VALUE:
131  return "SINGLE_VALUE";
132  }
133  LOG(FATAL) << "Invalid aggregate kind: " << kind;
134  return "";
135 }
136 
137 inline std::string toString(const SQLOps& op) {
138  switch (op) {
139  case kEQ:
140  return "EQ";
141  case kBW_EQ:
142  return "BW_EQ";
143  case kNE:
144  return "NE";
145  case kLT:
146  return "LT";
147  case kGT:
148  return "GT";
149  case kLE:
150  return "LE";
151  case kGE:
152  return "GE";
153  case kAND:
154  return "AND";
155  case kOR:
156  return "OR";
157  case kNOT:
158  return "NOT";
159  case kMINUS:
160  return "MINUS";
161  case kPLUS:
162  return "PLUS";
163  case kMULTIPLY:
164  return "MULTIPLY";
165  case kDIVIDE:
166  return "DIVIDE";
167  case kMODULO:
168  return "MODULO";
169  case kUMINUS:
170  return "UMINUS";
171  case kISNULL:
172  return "ISNULL";
173  case kISNOTNULL:
174  return "ISNOTNULL";
175  case kEXISTS:
176  return "EXISTS";
177  case kCAST:
178  return "CAST";
179  case kARRAY_AT:
180  return "ARRAY_AT";
181  case kUNNEST:
182  return "UNNEST";
183  case kFUNCTION:
184  return "FUNCTION";
185  case kIN:
186  return "IN";
187  case kOVERLAPS:
188  return "OVERLAPS";
189  }
190  LOG(FATAL) << "Invalid operation kind: " << op;
191  return "";
192 }
193 
194 inline std::string toString(const SqlWindowFunctionKind& kind) {
195  switch (kind) {
197  return "ROW_NUMBER";
199  return "RANK";
201  return "DENSE_RANK";
203  return "PERCENT_RANK";
205  return "CUME_DIST";
207  return "NTILE";
209  return "LAG";
211  return "LEAD";
213  return "FIRST_VALUE";
215  return "LAST_VALUE";
217  return "AVG";
219  return "MIN";
221  return "MAX";
223  return "SUM";
225  return "COUNT";
227  return "SUM_INTERNAL";
228  }
229  LOG(FATAL) << "Invalid window function kind.";
230  return "";
231 }
232 
233 #endif
234 
235 #endif // SQLDEFS_H
Definition: sqldefs.h:69
SQLAgg
Definition: sqldefs.h:71
ViewRefreshOption
Definition: sqldefs.h:105
Definition: sqldefs.h:103
JoinType
Definition: sqldefs.h:107
std::string toString(const ExtArgumentType &sig_type)
SQLQualifier
Definition: sqldefs.h:69
#define LOG(tag)
Definition: Logger.h:188
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:103
SQLStmtType
Definition: sqldefs.h:101
Definition: sqldefs.h:34
Definition: sqldefs.h:40
Definition: sqldefs.h:69
Definition: sqldefs.h:103
Definition: sqldefs.h:32
Definition: sqldefs.h:76
Definition: sqldefs.h:105
SqlWindowFunctionKind
Definition: sqldefs.h:82
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:103