OmniSciDB  ca0c39ec8f
 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 <sstream>
#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::JSON_VALUE, SqlStringOpKind::BASE64_ENCODE,
  SqlStringOpKind::BASE64_DECODE, SqlStringOpKind::TRY_STRING_CAST, 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::LAG_IN_FRAME,
  SqlWindowFunctionKind::LEAD, SqlWindowFunctionKind::LEAD_IN_FRAME, 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)
 
std::ostream & operator<< (std::ostream &os, const SqlStringOpKind kind)
 
SqlStringOpKind name_to_string_op_kind (const std::string &func_name)
 
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 157 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 151 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 
JSON_VALUE 
BASE64_ENCODE 
BASE64_DECODE 
TRY_STRING_CAST 
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 
LAG_IN_FRAME 
LEAD 
LEAD_IN_FRAME 
FIRST_VALUE 
LAST_VALUE 
SUM_INTERNAL 

Definition at line 114 of file sqldefs.h.

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

Definition at line 153 of file sqldefs.h.

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

Definition at line 155 of file sqldefs.h.

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

Function Documentation

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

Definition at line 331 of file sqldefs.h.

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

Referenced by RelAlgTranslator::translateStringOper().

331  {
332  if (func_name == "LOWER") {
333  return SqlStringOpKind::LOWER;
334  }
335  if (func_name == "UPPER") {
336  return SqlStringOpKind::UPPER;
337  }
338  if (func_name == "INITCAP") {
340  }
341  if (func_name == "REVERSE") {
343  }
344  if (func_name == "REPEAT") {
346  }
347  if (func_name == "||") {
349  }
350  if (func_name == "LPAD") {
351  return SqlStringOpKind::LPAD;
352  }
353  if (func_name == "RPAD") {
354  return SqlStringOpKind::RPAD;
355  }
356  if (func_name == "TRIM") {
357  return SqlStringOpKind::TRIM;
358  }
359  if (func_name == "LTRIM") {
360  return SqlStringOpKind::LTRIM;
361  }
362  if (func_name == "RTRIM") {
363  return SqlStringOpKind::RTRIM;
364  }
365  if (func_name == "SUBSTRING") {
367  }
368  if (func_name == "OVERLAY") {
370  }
371  if (func_name == "REPLACE") {
373  }
374  if (func_name == "SPLIT_PART") {
376  }
377  if (func_name == "REGEXP_REPLACE") {
379  }
380  if (func_name == "REGEXP_SUBSTR") {
382  }
383  if (func_name == "REGEXP_MATCH") {
385  }
386  if (func_name == "JSON_VALUE") {
388  }
389  if (func_name == "BASE64_ENCODE") {
391  }
392  if (func_name == "BASE64_DECODE") {
394  }
395  if (func_name == "TRY_CAST") {
397  }
398  LOG(FATAL) << "Invalid string function " << func_name << ".";
400 }
#define LOG(tag)
Definition: Logger.h:216

+ Here is the caller graph for this function:

std::ostream& operator<< ( std::ostream &  os,
const SqlStringOpKind  kind 
)
inline

Definition at line 277 of file sqldefs.h.

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

277  {
278  switch (kind) {
280  return os << "LOWER";
282  return os << "UPPER";
284  return os << "INITCAP";
286  return os << "REVERSE";
288  return os << "REPEAT";
290  return os << "CONCAT";
292  return os << "RCONCAT";
294  return os << "LPAD";
296  return os << "RPAD";
298  return os << "TRIM";
300  return os << "LTRIM";
302  return os << "RTRIM";
304  return os << "SUBSTRING";
306  return os << "OVERLAY";
308  return os << "REPLACE";
310  return os << "SPLIT_PART";
312  return os << "REGEXP_REPLACE";
314  return os << "REGEXP_SUBSTR";
316  return os << "JSON_VALUE";
318  return os << "BASE64_ENCODE";
320  return os << "BASE64_DECODE";
322  return os << "TRY_STRING_CAST";
324  return os << "INVALID";
325  }
326  LOG(FATAL) << "Invalid string operation";
327  // Make compiler happy
328  return os << "INVALID";
329 }
#define LOG(tag)
Definition: Logger.h:216
std::string toString ( const JoinType join_type)
inline

Definition at line 165 of file sqldefs.h.

References ANTI, INNER, LEFT, and SEMI.

165  {
166  switch (join_type) {
167  case JoinType::INNER:
168  return "INNER";
169  case JoinType::LEFT:
170  return "LEFT";
171  case JoinType::SEMI:
172  return "SEMI";
173  case JoinType::ANTI:
174  return "ANTI";
175  default:
176  return "INVALID";
177  }
178 }
std::string toString ( const SQLQualifier qualifier)
inline

Definition at line 180 of file sqldefs.h.

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

180  {
181  switch (qualifier) {
182  case kONE:
183  return "ONE";
184  case kANY:
185  return "ANY";
186  case kALL:
187  return "ALL";
188  }
189  LOG(FATAL) << "Invalid SQLQualifier: " << qualifier;
190  return "";
191 }
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 193 of file sqldefs.h.

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

193  {
194  switch (kind) {
195  case kAVG:
196  return "AVG";
197  case kMIN:
198  return "MIN";
199  case kMAX:
200  return "MAX";
201  case kSUM:
202  return "SUM";
203  case kCOUNT:
204  return "COUNT";
206  return "APPROX_COUNT_DISTINCT";
207  case kAPPROX_QUANTILE:
208  return "APPROX_PERCENTILE";
209  case kSAMPLE:
210  return "SAMPLE";
211  case kSINGLE_VALUE:
212  return "SINGLE_VALUE";
213  }
214  LOG(FATAL) << "Invalid aggregate kind: " << kind;
215  return "";
216 }
#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 218 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.

218  {
219  switch (op) {
220  case kEQ:
221  return "EQ";
222  case kBW_EQ:
223  return "BW_EQ";
224  case kNE:
225  return "NE";
226  case kLT:
227  return "LT";
228  case kGT:
229  return "GT";
230  case kLE:
231  return "LE";
232  case kGE:
233  return "GE";
234  case kAND:
235  return "AND";
236  case kOR:
237  return "OR";
238  case kNOT:
239  return "NOT";
240  case kMINUS:
241  return "MINUS";
242  case kPLUS:
243  return "PLUS";
244  case kMULTIPLY:
245  return "MULTIPLY";
246  case kDIVIDE:
247  return "DIVIDE";
248  case kMODULO:
249  return "MODULO";
250  case kUMINUS:
251  return "UMINUS";
252  case kISNULL:
253  return "ISNULL";
254  case kISNOTNULL:
255  return "ISNOTNULL";
256  case kEXISTS:
257  return "EXISTS";
258  case kCAST:
259  return "CAST";
260  case kARRAY_AT:
261  return "ARRAY_AT";
262  case kUNNEST:
263  return "UNNEST";
264  case kFUNCTION:
265  return "FUNCTION";
266  case kIN:
267  return "IN";
268  case kOVERLAPS:
269  return "OVERLAPS";
270  case kENCODE_TEXT:
271  return "ENCODE_TEXT";
272  }
273  LOG(FATAL) << "Invalid operation kind: " << op;
274  return "";
275 }
#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 SqlWindowFunctionKind kind)
inline

Definition at line 402 of file sqldefs.h.

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

402  {
403  switch (kind) {
405  return "ROW_NUMBER";
407  return "RANK";
409  return "DENSE_RANK";
411  return "PERCENT_RANK";
413  return "CUME_DIST";
415  return "NTILE";
417  return "LAG";
419  return "LEAD";
421  return "FIRST_VALUE";
423  return "LAST_VALUE";
425  return "AVG";
427  return "MIN";
429  return "MAX";
431  return "SUM";
433  return "COUNT";
435  return "SUM_INTERNAL";
437  return "FIRST_EXPR";
439  return "LAST_EXPR";
441  return "NTH_EXPR";
443  return "LEAD_IN_FRAME";
445  return "LAG_IN_FRAME";
446  }
447  LOG(FATAL) << "Invalid window function kind.";
448  return "";
449 }
#define LOG(tag)
Definition: Logger.h:216
std::string toString ( const SqlWindowFrameBoundType kind)
inline

Definition at line 451 of file sqldefs.h.

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

451  {
452  switch (kind) {
454  return "UNBOUNDED_PRECEDING";
456  return "EXPR_PRECEDING";
458  return "CURRENT_ROW";
460  return "EXPR_FOLLOWING";
462  return "UNBOUNDED_FOLLOWING";
464  return "UNKNOWN";
465  }
466  LOG(FATAL) << "Invalid window function bound type.";
467  return "";
468 }
#define LOG(tag)
Definition: Logger.h:216