OmniSciDB  cde582ebc3
 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::MIN = 1, SqlWindowFunctionKind::MAX, SqlWindowFunctionKind::AVG, SqlWindowFunctionKind::SUM,
  SqlWindowFunctionKind::COUNT, SqlWindowFunctionKind::FIRST_EXPR, SqlWindowFunctionKind::LAST_EXPR, SqlWindowFunctionKind::NTH_EXPR,
  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::SUM_INTERNAL
}
 
enum  SqlWindowFrameBoundType {
  SqlWindowFrameBoundType::UNBOUNDED_PRECEDING = 1, SqlWindowFrameBoundType::EXPR_PRECEDING, SqlWindowFrameBoundType::CURRENT_ROW, SqlWindowFrameBoundType::EXPR_FOLLOWING,
  SqlWindowFrameBoundType::UNBOUNDED_FOLLOWING, SqlWindowFrameBoundType::UNKNOWN
}
 
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)
 
std::string toString (const SqlWindowFrameBoundType &kind)
 

Detailed Description

Common Enum definitions for SQL processing.

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)
Value:

Definition at line 65 of file sqldefs.h.

Enumeration Type Documentation

enum JoinType
strong
Enumerator
INNER 
LEFT 
SEMI 
ANTI 
INVALID 

Definition at line 151 of file sqldefs.h.

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

Definition at line 72 of file sqldefs.h.

72  {
73  kAVG,
74  kMIN,
75  kMAX,
76  kSUM,
77  kCOUNT,
80  kSAMPLE,
82 };
Definition: sqldefs.h:74
Definition: sqldefs.h:76
Definition: sqldefs.h:77
Definition: sqldefs.h:75
Definition: sqldefs.h:73
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 28 of file sqldefs.h.

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

Definition at line 70 of file sqldefs.h.

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

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

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

Definition at line 110 of file sqldefs.h.

110  {
111  // set MIN's enum val as one, and we use window function kind's enum vals
112  // to classify a behavior of our runtime code for window framing
113  // i.e., aggregate_##value_type##_values functions
114  // todo (yoonmin): support FIRST_EXPR, LAST_EXPR, AND NTH_EXPR with framing
115  MIN = 1,
116  MAX,
117  AVG,
118  SUM,
119  COUNT,
120  FIRST_EXPR,
121  LAST_EXPR,
122  NTH_EXPR,
123  ROW_NUMBER,
124  RANK,
125  DENSE_RANK,
126  PERCENT_RANK,
127  CUME_DIST,
128  NTILE,
129  LAG,
130  LEAD,
131  FIRST_VALUE,
132  LAST_VALUE,
133  SUM_INTERNAL // For deserialization from Calcite only. Gets rewritten to a regular SUM.
134 };
Enumerator
kDISK 
kGPU 
kCPU 

Definition at line 147 of file sqldefs.h.

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

Definition at line 149 of file sqldefs.h.

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

Function Documentation

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

Definition at line 270 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().

270  {
271  if (func_name == "LOWER") {
272  return SqlStringOpKind::LOWER;
273  }
274  if (func_name == "UPPER") {
275  return SqlStringOpKind::UPPER;
276  }
277  if (func_name == "INITCAP") {
279  }
280  if (func_name == "REVERSE") {
282  }
283  if (func_name == "REPEAT") {
285  }
286  if (func_name == "||") {
288  }
289  if (func_name == "LPAD") {
290  return SqlStringOpKind::LPAD;
291  }
292  if (func_name == "RPAD") {
293  return SqlStringOpKind::RPAD;
294  }
295  if (func_name == "TRIM") {
296  return SqlStringOpKind::TRIM;
297  }
298  if (func_name == "LTRIM") {
299  return SqlStringOpKind::LTRIM;
300  }
301  if (func_name == "RTRIM") {
302  return SqlStringOpKind::RTRIM;
303  }
304  if (func_name == "SUBSTRING") {
306  }
307  if (func_name == "OVERLAY") {
309  }
310  if (func_name == "REPLACE") {
312  }
313  if (func_name == "SPLIT_PART") {
315  }
316  if (func_name == "REGEXP_REPLACE") {
318  }
319  if (func_name == "REGEXP_SUBSTR") {
321  }
322  if (func_name == "REGEXP_MATCH") {
324  }
325  LOG(FATAL) << "Invalid string function " << func_name << ".";
327 }
#define LOG(tag)
Definition: Logger.h:216

+ Here is the caller graph for this function:

std::string toString ( const JoinType join_type)
inline

Definition at line 158 of file sqldefs.h.

References ANTI, INNER, LEFT, and SEMI.

158  {
159  switch (join_type) {
160  case JoinType::INNER:
161  return "INNER";
162  case JoinType::LEFT:
163  return "LEFT";
164  case JoinType::SEMI:
165  return "SEMI";
166  case JoinType::ANTI:
167  return "ANTI";
168  default:
169  return "INVALID";
170  }
171 }
std::string toString ( const SQLQualifier qualifier)
inline

Definition at line 173 of file sqldefs.h.

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

173  {
174  switch (qualifier) {
175  case kONE:
176  return "ONE";
177  case kANY:
178  return "ANY";
179  case kALL:
180  return "ALL";
181  }
182  LOG(FATAL) << "Invalid SQLQualifier: " << qualifier;
183  return "";
184 }
Definition: sqldefs.h:70
#define LOG(tag)
Definition: Logger.h:216
Definition: sqldefs.h:70
Definition: sqldefs.h:70
std::string toString ( const SQLAgg kind)
inline

Definition at line 186 of file sqldefs.h.

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

186  {
187  switch (kind) {
188  case kAVG:
189  return "AVG";
190  case kMIN:
191  return "MIN";
192  case kMAX:
193  return "MAX";
194  case kSUM:
195  return "SUM";
196  case kCOUNT:
197  return "COUNT";
199  return "APPROX_COUNT_DISTINCT";
200  case kAPPROX_QUANTILE:
201  return "APPROX_PERCENTILE";
202  case kSAMPLE:
203  return "SAMPLE";
204  case kSINGLE_VALUE:
205  return "SINGLE_VALUE";
206  }
207  LOG(FATAL) << "Invalid aggregate kind: " << kind;
208  return "";
209 }
#define LOG(tag)
Definition: Logger.h:216
Definition: sqldefs.h:74
Definition: sqldefs.h:76
Definition: sqldefs.h:77
Definition: sqldefs.h:75
Definition: sqldefs.h:73
std::string toString ( const SQLOps op)
inline

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

211  {
212  switch (op) {
213  case kEQ:
214  return "EQ";
215  case kBW_EQ:
216  return "BW_EQ";
217  case kNE:
218  return "NE";
219  case kLT:
220  return "LT";
221  case kGT:
222  return "GT";
223  case kLE:
224  return "LE";
225  case kGE:
226  return "GE";
227  case kAND:
228  return "AND";
229  case kOR:
230  return "OR";
231  case kNOT:
232  return "NOT";
233  case kMINUS:
234  return "MINUS";
235  case kPLUS:
236  return "PLUS";
237  case kMULTIPLY:
238  return "MULTIPLY";
239  case kDIVIDE:
240  return "DIVIDE";
241  case kMODULO:
242  return "MODULO";
243  case kUMINUS:
244  return "UMINUS";
245  case kISNULL:
246  return "ISNULL";
247  case kISNOTNULL:
248  return "ISNOTNULL";
249  case kEXISTS:
250  return "EXISTS";
251  case kCAST:
252  return "CAST";
253  case kARRAY_AT:
254  return "ARRAY_AT";
255  case kUNNEST:
256  return "UNNEST";
257  case kFUNCTION:
258  return "FUNCTION";
259  case kIN:
260  return "IN";
261  case kOVERLAPS:
262  return "OVERLAPS";
263  case kENCODE_TEXT:
264  return "ENCODE_TEXT";
265  }
266  LOG(FATAL) << "Invalid operation kind: " << op;
267  return "";
268 }
#define LOG(tag)
Definition: Logger.h:216
Definition: sqldefs.h:34
Definition: sqldefs.h:35
Definition: sqldefs.h:37
Definition: sqldefs.h:48
Definition: sqldefs.h:29
Definition: sqldefs.h:40
Definition: sqldefs.h:36
Definition: sqldefs.h:33
Definition: sqldefs.h:39
Definition: sqldefs.h:31
Definition: sqldefs.h:52
Definition: sqldefs.h:30
Definition: sqldefs.h:32
Definition: sqldefs.h:38
std::string toString ( const SqlStringOpKind kind)
inline

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

329  {
330  switch (kind) {
332  return "LOWER";
334  return "UPPER";
336  return "INITCAP";
338  return "REVERSE";
340  return "REPEAT";
343  return "||";
345  return "LPAD";
347  return "RPAD";
349  return "TRIM";
351  return "LTRIM";
353  return "RTRIM";
355  return "SUBSTRING";
357  return "OVERLAY";
359  return "REPLACE";
361  return "SPLIT_PART";
363  return "REGEXP_REPLACE";
365  return "REGEXP_SUBSTR";
366  default:
367  LOG(FATAL) << "Invalid string operation";
368  }
369  return "";
370 }
#define LOG(tag)
Definition: Logger.h:216
std::string toString ( const SqlWindowFunctionKind kind)
inline

Definition at line 372 of file sqldefs.h.

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

372  {
373  switch (kind) {
375  return "ROW_NUMBER";
377  return "RANK";
379  return "DENSE_RANK";
381  return "PERCENT_RANK";
383  return "CUME_DIST";
385  return "NTILE";
387  return "LAG";
389  return "LEAD";
391  return "FIRST_VALUE";
393  return "LAST_VALUE";
395  return "AVG";
397  return "MIN";
399  return "MAX";
401  return "SUM";
403  return "COUNT";
405  return "SUM_INTERNAL";
407  return "FIRST_EXPR";
409  return "LAST_EXPR";
411  return "NTH_EXPR";
412  }
413  LOG(FATAL) << "Invalid window function kind.";
414  return "";
415 }
#define LOG(tag)
Definition: Logger.h:216
std::string toString ( const SqlWindowFrameBoundType kind)
inline

Definition at line 417 of file sqldefs.h.

References CURRENT_ROW, EXPR_FOLLOWING, EXPR_PRECEDING, logger::FATAL, LOG, UNBOUNDED_FOLLOWING, UNBOUNDED_PRECEDING, and UNKNOWN.

417  {
418  switch (kind) {
420  return "UNBOUNDED_PRECEDING";
422  return "EXPR_PRECEDING";
424  return "CURRENT_ROW";
426  return "EXPR_FOLLOWING";
428  return "UNBOUNDED_FOLLOWING";
430  return "UNKNOWN";
431  }
432  LOG(FATAL) << "Invalid window function bound type.";
433  return "";
434 }
#define LOG(tag)
Definition: Logger.h:216