OmniSciDB  fe05a0c208
 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 {
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, INVALID };
109 
110 #ifndef __CUDACC__
111 
112 #include <string>
113 #include "Logger/Logger.h"
114 
115 inline std::string toString(const SQLAgg& kind) {
116  switch (kind) {
117  case kAVG:
118  return "AVG";
119  case kMIN:
120  return "MIN";
121  case kMAX:
122  return "MAX";
123  case kSUM:
124  return "SUM";
125  case kCOUNT:
126  return "COUNT";
128  return "APPROX_COUNT_DISTINCT";
129  case kAPPROX_MEDIAN:
130  return "APPROX_MEDIAN";
131  case kSAMPLE:
132  return "SAMPLE";
133  case kSINGLE_VALUE:
134  return "SINGLE_VALUE";
135  }
136  LOG(FATAL) << "Invalid aggregate kind: " << kind;
137  return "";
138 }
139 
140 inline std::string toString(const SQLOps& op) {
141  switch (op) {
142  case kEQ:
143  return "EQ";
144  case kBW_EQ:
145  return "BW_EQ";
146  case kNE:
147  return "NE";
148  case kLT:
149  return "LT";
150  case kGT:
151  return "GT";
152  case kLE:
153  return "LE";
154  case kGE:
155  return "GE";
156  case kAND:
157  return "AND";
158  case kOR:
159  return "OR";
160  case kNOT:
161  return "NOT";
162  case kMINUS:
163  return "MINUS";
164  case kPLUS:
165  return "PLUS";
166  case kMULTIPLY:
167  return "MULTIPLY";
168  case kDIVIDE:
169  return "DIVIDE";
170  case kMODULO:
171  return "MODULO";
172  case kUMINUS:
173  return "UMINUS";
174  case kISNULL:
175  return "ISNULL";
176  case kISNOTNULL:
177  return "ISNOTNULL";
178  case kEXISTS:
179  return "EXISTS";
180  case kCAST:
181  return "CAST";
182  case kARRAY_AT:
183  return "ARRAY_AT";
184  case kUNNEST:
185  return "UNNEST";
186  case kFUNCTION:
187  return "FUNCTION";
188  case kIN:
189  return "IN";
190  case kOVERLAPS:
191  return "OVERLAPS";
192  }
193  LOG(FATAL) << "Invalid operation kind: " << op;
194  return "";
195 }
196 
197 inline std::string toString(const SqlWindowFunctionKind& kind) {
198  switch (kind) {
200  return "ROW_NUMBER";
202  return "RANK";
204  return "DENSE_RANK";
206  return "PERCENT_RANK";
208  return "CUME_DIST";
210  return "NTILE";
212  return "LAG";
214  return "LEAD";
216  return "FIRST_VALUE";
218  return "LAST_VALUE";
220  return "AVG";
222  return "MIN";
224  return "MAX";
226  return "SUM";
228  return "COUNT";
230  return "SUM_INTERNAL";
231  }
232  LOG(FATAL) << "Invalid window function kind.";
233  return "";
234 }
235 
236 #endif
237 
238 #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:194
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