OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sqldefs.h File Reference

Common Enum definitions for SQL processing. More...

#include <string>
#include "Logger/Logger.h"
+ Include dependency graph for sqldefs.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define IS_COMPARISON(X)
 
#define IS_LOGIC(X)   ((X) == kAND || (X) == kOR)
 
#define IS_ARITHMETIC(X)   ((X) == kMINUS || (X) == kPLUS || (X) == kMULTIPLY || (X) == kDIVIDE || (X) == kMODULO)
 
#define COMMUTE_COMPARISON(X)   ((X) == kLT ? kGT : (X) == kLE ? kGE : (X) == kGT ? kLT : (X) == kGE ? kLE : (X))
 
#define IS_UNARY(X)
 
#define IS_EQUIVALENCE(X)   ((X) == kEQ || (X) == kBW_EQ || (X) == kOVERLAPS)
 

Enumerations

enum  SQLOps {
  kEQ = 0, kBW_EQ, kNE, kLT,
  kGT, kLE, kGE, kAND,
  kOR, kNOT, kMINUS, kPLUS,
  kMULTIPLY, kDIVIDE, kMODULO, kUMINUS,
  kISNULL, kISNOTNULL, kEXISTS, kCAST,
  kARRAY_AT, kUNNEST, kFUNCTION, kIN,
  kOVERLAPS, kENCODE_TEXT
}
 
enum  SQLQualifier { kONE, kANY, kALL }
 
enum  SQLAgg {
  kAVG, kMIN, kMAX, kSUM,
  kCOUNT, kAPPROX_COUNT_DISTINCT, kAPPROX_QUANTILE, kSAMPLE,
  kSINGLE_VALUE
}
 
enum  SqlStringOpKind {
  SqlStringOpKind::LOWER = 1, SqlStringOpKind::UPPER, SqlStringOpKind::INITCAP, SqlStringOpKind::REVERSE,
  SqlStringOpKind::REPEAT, SqlStringOpKind::CONCAT, SqlStringOpKind::RCONCAT, SqlStringOpKind::LPAD,
  SqlStringOpKind::RPAD, SqlStringOpKind::TRIM, SqlStringOpKind::LTRIM, SqlStringOpKind::RTRIM,
  SqlStringOpKind::SUBSTRING, SqlStringOpKind::OVERLAY, SqlStringOpKind::REPLACE, SqlStringOpKind::SPLIT_PART,
  SqlStringOpKind::REGEXP_REPLACE, SqlStringOpKind::REGEXP_SUBSTR, SqlStringOpKind::INVALID
}
 
enum  SqlWindowFunctionKind {
  SqlWindowFunctionKind::ROW_NUMBER, SqlWindowFunctionKind::RANK, SqlWindowFunctionKind::DENSE_RANK, SqlWindowFunctionKind::PERCENT_RANK,
  SqlWindowFunctionKind::CUME_DIST, SqlWindowFunctionKind::NTILE, SqlWindowFunctionKind::LAG, SqlWindowFunctionKind::LEAD,
  SqlWindowFunctionKind::FIRST_VALUE, SqlWindowFunctionKind::LAST_VALUE, SqlWindowFunctionKind::AVG, SqlWindowFunctionKind::MIN,
  SqlWindowFunctionKind::MAX, SqlWindowFunctionKind::SUM, SqlWindowFunctionKind::COUNT, SqlWindowFunctionKind::SUM_INTERNAL
}
 
enum  SQLStmtType {
  kSELECT, kUPDATE, kINSERT, kDELETE,
  kCREATE_TABLE
}
 
enum  StorageOption { kDISK = 0, kGPU = 1, kCPU = 2 }
 
enum  ViewRefreshOption { kMANUAL = 0, kAUTO = 1, kIMMEDIATE = 2 }
 
enum  JoinType {
  JoinType::INNER, JoinType::LEFT, JoinType::SEMI, JoinType::ANTI,
  JoinType::INVALID
}
 

Functions

std::string toString (const JoinType &join_type)
 
std::string toString (const SQLQualifier &qualifier)
 
std::string toString (const SQLAgg &kind)
 
std::string toString (const SQLOps &op)
 
SqlStringOpKind name_to_string_op_kind (const std::string &func_name)
 
std::string toString (const SqlStringOpKind &kind)
 
std::string toString (const SqlWindowFunctionKind &kind)
 

Detailed Description

Common Enum definitions for SQL processing.

Author
Wei Hong wei@m.nosp@m.ap-d.nosp@m..com Copyright (c) 2014 MapD Technologies, Inc. All rights reserved.

Definition in file sqldefs.h.

Macro Definition Documentation

#define COMMUTE_COMPARISON (   X)    ((X) == kLT ? kGT : (X) == kLE ? kGE : (X) == kGT ? kLT : (X) == kGE ? kLE : (X))

Definition at line 64 of file sqldefs.h.

Referenced by Analyzer::BinOper::normalize_simple_predicate().

#define IS_ARITHMETIC (   X)    ((X) == kMINUS || (X) == kPLUS || (X) == kMULTIPLY || (X) == kDIVIDE || (X) == kMODULO)
#define IS_UNARY (   X)
Value:

Definition at line 66 of file sqldefs.h.

Enumeration Type Documentation

enum JoinType
strong
Enumerator
INNER 
LEFT 
SEMI 
ANTI 
INVALID 

Definition at line 136 of file sqldefs.h.

enum SQLAgg
Enumerator
kAVG 
kMIN 
kMAX 
kSUM 
kCOUNT 
kAPPROX_COUNT_DISTINCT 
kAPPROX_QUANTILE 
kSAMPLE 
kSINGLE_VALUE 

Definition at line 73 of file sqldefs.h.

73  {
74  kAVG,
75  kMIN,
76  kMAX,
77  kSUM,
78  kCOUNT,
81  kSAMPLE,
83 };
Definition: sqldefs.h:75
Definition: sqldefs.h:77
Definition: sqldefs.h:78
Definition: sqldefs.h:76
Definition: sqldefs.h:74
enum SQLOps
Enumerator
kEQ 
kBW_EQ 
kNE 
kLT 
kGT 
kLE 
kGE 
kAND 
kOR 
kNOT 
kMINUS 
kPLUS 
kMULTIPLY 
kDIVIDE 
kMODULO 
kUMINUS 
kISNULL 
kISNOTNULL 
kEXISTS 
kCAST 
kARRAY_AT 
kUNNEST 
kFUNCTION 
kIN 
kOVERLAPS 
kENCODE_TEXT 

Definition at line 29 of file sqldefs.h.

29  {
30  kEQ = 0,
31  kBW_EQ,
32  kNE,
33  kLT,
34  kGT,
35  kLE,
36  kGE,
37  kAND,
38  kOR,
39  kNOT,
40  kMINUS,
41  kPLUS,
42  kMULTIPLY,
43  kDIVIDE,
44  kMODULO,
45  kUMINUS,
46  kISNULL,
47  kISNOTNULL,
48  kEXISTS,
49  kCAST,
50  kARRAY_AT,
51  kUNNEST,
52  kFUNCTION,
53  kIN,
54  kOVERLAPS,
56 };
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:37
Definition: sqldefs.h:34
Definition: sqldefs.h:40
Definition: sqldefs.h:32
Definition: sqldefs.h:53
Definition: sqldefs.h:31
Definition: sqldefs.h:33
Definition: sqldefs.h:39
Enumerator
kONE 
kANY 
kALL 

Definition at line 71 of file sqldefs.h.

71 { kONE, kANY, kALL };
Definition: sqldefs.h:71
Definition: sqldefs.h:71
Definition: sqldefs.h:71
Enumerator
kSELECT 
kUPDATE 
kINSERT 
kDELETE 
kCREATE_TABLE 

Definition at line 130 of file sqldefs.h.

enum SqlStringOpKind
strong
Enumerator
LOWER 
UPPER 
INITCAP 
REVERSE 
REPEAT 
CONCAT 
RCONCAT 
LPAD 
RPAD 
TRIM 
LTRIM 
RTRIM 
SUBSTRING 
OVERLAY 
REPLACE 
SPLIT_PART 
REGEXP_REPLACE 
REGEXP_SUBSTR 
INVALID 

Definition at line 85 of file sqldefs.h.

enum SqlWindowFunctionKind
strong
Enumerator
ROW_NUMBER 
RANK 
DENSE_RANK 
PERCENT_RANK 
CUME_DIST 
NTILE 
LAG 
LEAD 
FIRST_VALUE 
LAST_VALUE 
AVG 
MIN 
MAX 
SUM 
COUNT 
SUM_INTERNAL 

Definition at line 111 of file sqldefs.h.

Enumerator
kDISK 
kGPU 
kCPU 

Definition at line 132 of file sqldefs.h.

132 { kDISK = 0, kGPU = 1, kCPU = 2 };
Definition: sqldefs.h:132
Definition: sqldefs.h:132
Definition: sqldefs.h:132
Enumerator
kMANUAL 
kAUTO 
kIMMEDIATE 

Definition at line 134 of file sqldefs.h.

134 { kMANUAL = 0, kAUTO = 1, kIMMEDIATE = 2 };
Definition: sqldefs.h:134

Function Documentation

SqlStringOpKind name_to_string_op_kind ( const std::string &  func_name)
inline

Definition at line 255 of file sqldefs.h.

References CONCAT, logger::FATAL, INITCAP, INVALID, LOG, LOWER, LPAD, LTRIM, OVERLAY, REGEXP_REPLACE, REGEXP_SUBSTR, REPEAT, REPLACE, REVERSE, RPAD, RTRIM, SPLIT_PART, SUBSTRING, TRIM, and UPPER.

Referenced by RelAlgTranslator::translateStringOper().

255  {
256  if (func_name == "LOWER") {
257  return SqlStringOpKind::LOWER;
258  }
259  if (func_name == "UPPER") {
260  return SqlStringOpKind::UPPER;
261  }
262  if (func_name == "INITCAP") {
264  }
265  if (func_name == "REVERSE") {
267  }
268  if (func_name == "REPEAT") {
270  }
271  if (func_name == "||") {
273  }
274  if (func_name == "LPAD") {
275  return SqlStringOpKind::LPAD;
276  }
277  if (func_name == "RPAD") {
278  return SqlStringOpKind::RPAD;
279  }
280  if (func_name == "TRIM") {
281  return SqlStringOpKind::TRIM;
282  }
283  if (func_name == "LTRIM") {
284  return SqlStringOpKind::LTRIM;
285  }
286  if (func_name == "RTRIM") {
287  return SqlStringOpKind::RTRIM;
288  }
289  if (func_name == "SUBSTRING") {
291  }
292  if (func_name == "OVERLAY") {
294  }
295  if (func_name == "REPLACE") {
297  }
298  if (func_name == "SPLIT_PART") {
300  }
301  if (func_name == "REGEXP_REPLACE") {
303  }
304  if (func_name == "REGEXP_SUBSTR") {
306  }
307  if (func_name == "REGEXP_MATCH") {
309  }
310  LOG(FATAL) << "Invalid string function " << func_name << ".";
312 }
#define LOG(tag)
Definition: Logger.h:217

+ Here is the caller graph for this function:

std::string toString ( const JoinType join_type)
inline

Definition at line 143 of file sqldefs.h.

References ANTI, INNER, LEFT, and SEMI.

143  {
144  switch (join_type) {
145  case JoinType::INNER:
146  return "INNER";
147  case JoinType::LEFT:
148  return "LEFT";
149  case JoinType::SEMI:
150  return "SEMI";
151  case JoinType::ANTI:
152  return "ANTI";
153  default:
154  return "INVALID";
155  }
156 }
std::string toString ( const SQLQualifier qualifier)
inline

Definition at line 158 of file sqldefs.h.

References logger::FATAL, kALL, kANY, kONE, and LOG.

158  {
159  switch (qualifier) {
160  case kONE:
161  return "ONE";
162  case kANY:
163  return "ANY";
164  case kALL:
165  return "ALL";
166  }
167  LOG(FATAL) << "Invalid SQLQualifier: " << qualifier;
168  return "";
169 }
Definition: sqldefs.h:71
#define LOG(tag)
Definition: Logger.h:217
Definition: sqldefs.h:71
Definition: sqldefs.h:71
std::string toString ( const SQLAgg kind)
inline

Definition at line 171 of file sqldefs.h.

References logger::FATAL, kAPPROX_COUNT_DISTINCT, kAPPROX_QUANTILE, kAVG, kCOUNT, kMAX, kMIN, kSAMPLE, kSINGLE_VALUE, kSUM, and LOG.

171  {
172  switch (kind) {
173  case kAVG:
174  return "AVG";
175  case kMIN:
176  return "MIN";
177  case kMAX:
178  return "MAX";
179  case kSUM:
180  return "SUM";
181  case kCOUNT:
182  return "COUNT";
184  return "APPROX_COUNT_DISTINCT";
185  case kAPPROX_QUANTILE:
186  return "APPROX_PERCENTILE";
187  case kSAMPLE:
188  return "SAMPLE";
189  case kSINGLE_VALUE:
190  return "SINGLE_VALUE";
191  }
192  LOG(FATAL) << "Invalid aggregate kind: " << kind;
193  return "";
194 }
#define LOG(tag)
Definition: Logger.h:217
Definition: sqldefs.h:75
Definition: sqldefs.h:77
Definition: sqldefs.h:78
Definition: sqldefs.h:76
Definition: sqldefs.h:74
std::string toString ( const SQLOps op)
inline

Definition at line 196 of file sqldefs.h.

References logger::FATAL, kAND, kARRAY_AT, kBW_EQ, kCAST, kDIVIDE, kENCODE_TEXT, kEQ, kEXISTS, kFUNCTION, kGE, kGT, kIN, kISNOTNULL, kISNULL, kLE, kLT, kMINUS, kMODULO, kMULTIPLY, kNE, kNOT, kOR, kOVERLAPS, kPLUS, kUMINUS, kUNNEST, and LOG.

196  {
197  switch (op) {
198  case kEQ:
199  return "EQ";
200  case kBW_EQ:
201  return "BW_EQ";
202  case kNE:
203  return "NE";
204  case kLT:
205  return "LT";
206  case kGT:
207  return "GT";
208  case kLE:
209  return "LE";
210  case kGE:
211  return "GE";
212  case kAND:
213  return "AND";
214  case kOR:
215  return "OR";
216  case kNOT:
217  return "NOT";
218  case kMINUS:
219  return "MINUS";
220  case kPLUS:
221  return "PLUS";
222  case kMULTIPLY:
223  return "MULTIPLY";
224  case kDIVIDE:
225  return "DIVIDE";
226  case kMODULO:
227  return "MODULO";
228  case kUMINUS:
229  return "UMINUS";
230  case kISNULL:
231  return "ISNULL";
232  case kISNOTNULL:
233  return "ISNOTNULL";
234  case kEXISTS:
235  return "EXISTS";
236  case kCAST:
237  return "CAST";
238  case kARRAY_AT:
239  return "ARRAY_AT";
240  case kUNNEST:
241  return "UNNEST";
242  case kFUNCTION:
243  return "FUNCTION";
244  case kIN:
245  return "IN";
246  case kOVERLAPS:
247  return "OVERLAPS";
248  case kENCODE_TEXT:
249  return "ENCODE_TEXT";
250  }
251  LOG(FATAL) << "Invalid operation kind: " << op;
252  return "";
253 }
#define LOG(tag)
Definition: Logger.h:217
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:37
Definition: sqldefs.h:34
Definition: sqldefs.h:40
Definition: sqldefs.h:32
Definition: sqldefs.h:53
Definition: sqldefs.h:31
Definition: sqldefs.h:33
Definition: sqldefs.h:39
std::string toString ( const SqlStringOpKind kind)
inline

Definition at line 314 of file sqldefs.h.

References CONCAT, logger::FATAL, INITCAP, LOG, LOWER, LPAD, LTRIM, OVERLAY, RCONCAT, REGEXP_REPLACE, REGEXP_SUBSTR, REPEAT, REPLACE, REVERSE, RPAD, RTRIM, SPLIT_PART, SUBSTRING, TRIM, and UPPER.

314  {
315  switch (kind) {
317  return "LOWER";
319  return "UPPER";
321  return "INITCAP";
323  return "REVERSE";
325  return "REPEAT";
328  return "||";
330  return "LPAD";
332  return "RPAD";
334  return "TRIM";
336  return "LTRIM";
338  return "RTRIM";
340  return "SUBSTRING";
342  return "OVERLAY";
344  return "REPLACE";
346  return "SPLIT_PART";
348  return "REGEXP_REPLACE";
350  return "REGEXP_SUBSTR";
351  default:
352  LOG(FATAL) << "Invalid string operation";
353  }
354  return "";
355 }
#define LOG(tag)
Definition: Logger.h:217
std::string toString ( const SqlWindowFunctionKind kind)
inline

Definition at line 357 of file sqldefs.h.

References AVG, COUNT, CUME_DIST, DENSE_RANK, logger::FATAL, FIRST_VALUE, LAG, LAST_VALUE, LEAD, LOG, MAX, MIN, NTILE, PERCENT_RANK, RANK, ROW_NUMBER, SUM, and SUM_INTERNAL.

357  {
358  switch (kind) {
360  return "ROW_NUMBER";
362  return "RANK";
364  return "DENSE_RANK";
366  return "PERCENT_RANK";
368  return "CUME_DIST";
370  return "NTILE";
372  return "LAG";
374  return "LEAD";
376  return "FIRST_VALUE";
378  return "LAST_VALUE";
380  return "AVG";
382  return "MIN";
384  return "MAX";
386  return "SUM";
388  return "COUNT";
390  return "SUM_INTERNAL";
391  }
392  LOG(FATAL) << "Invalid window function kind.";
393  return "";
394 }
#define LOG(tag)
Definition: Logger.h:217