OmniSciDB  94e8789169
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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_MEDIAN, 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::INVALID }
 

Functions

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 
INVALID 

Definition at line 108 of file sqldefs.h.

enum SQLAgg
Enumerator
kAVG 
kMIN 
kMAX 
kSUM 
kCOUNT 
kAPPROX_COUNT_DISTINCT 
kAPPROX_MEDIAN 
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 SQLAgg kind)
inline

Definition at line 115 of file sqldefs.h.

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

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

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

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