OmniSciDB  6686921089
 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)   ((X) == kNOT || (X) == kUMINUS || (X) == kISNULL || (X) == kEXISTS || (X) == kCAST)
 
#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
}
 
enum  SQLQualifier { kONE, kANY, kALL }
 
enum  SQLAgg {
  kAVG, kMIN, kMAX, kSUM,
  kCOUNT, kAPPROX_COUNT_DISTINCT, kAPPROX_QUANTILE, kSAMPLE,
  kSINGLE_VALUE
}
 
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)
 
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 63 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)    ((X) == kNOT || (X) == kUMINUS || (X) == kISNULL || (X) == kEXISTS || (X) == kCAST)

Definition at line 65 of file sqldefs.h.

Enumeration Type Documentation

enum JoinType
strong
Enumerator
INNER 
LEFT 
SEMI 
ANTI 
INVALID 

Definition at line 108 of file sqldefs.h.

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

Definition at line 71 of file sqldefs.h.

71  {
72  kAVG,
73  kMIN,
74  kMAX,
75  kSUM,
76  kCOUNT,
79  kSAMPLE,
81 };
Definition: sqldefs.h:73
Definition: sqldefs.h:75
Definition: sqldefs.h:76
Definition: sqldefs.h:74
Definition: sqldefs.h:72
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 

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
55 };
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 69 of file sqldefs.h.

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

Definition at line 102 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 83 of file sqldefs.h.

Enumerator
kDISK 
kGPU 
kCPU 

Definition at line 104 of file sqldefs.h.

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

Definition at line 106 of file sqldefs.h.

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

Function Documentation

std::string toString ( const JoinType join_type)
inline

Definition at line 115 of file sqldefs.h.

References ANTI, INNER, LEFT, and SEMI.

115  {
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 }
std::string toString ( const SQLQualifier qualifier)
inline

Definition at line 130 of file sqldefs.h.

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

130  {
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 }
Definition: sqldefs.h:69
#define LOG(tag)
Definition: Logger.h:203
Definition: sqldefs.h:69
Definition: sqldefs.h:69
std::string toString ( const SQLAgg kind)
inline

Definition at line 143 of file sqldefs.h.

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

143  {
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 }
#define LOG(tag)
Definition: Logger.h:203
Definition: sqldefs.h:73
Definition: sqldefs.h:75
Definition: sqldefs.h:76
Definition: sqldefs.h:74
Definition: sqldefs.h:72
std::string toString ( const SQLOps op)
inline

Definition at line 168 of file sqldefs.h.

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

168  {
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 }
#define LOG(tag)
Definition: Logger.h:203
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 SqlWindowFunctionKind kind)
inline

Definition at line 225 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.

225  {
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 }
#define LOG(tag)
Definition: Logger.h:203