OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ParserNode.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
24 #ifndef PARSER_NODE_H_
25 #define PARSER_NODE_H_
26 
27 #include <cstdint>
28 #include <cstring>
29 #include <list>
30 #include <string>
31 
32 #include <boost/algorithm/string/predicate.hpp>
33 #include <boost/process/search_path.hpp>
34 
35 #include "../Analyzer/Analyzer.h"
36 #include "../Catalog/Catalog.h"
37 #include "../Distributed/AggregatedResult.h"
38 #include "../Shared/sqldefs.h"
39 #include "../Shared/sqltypes.h"
41 
42 #include "../Fragmenter/InsertDataLoader.h"
43 
44 #include <Import/Importer.h>
45 
46 #include <functional>
47 
48 namespace query_state {
49 class QueryState;
50 class QueryStateProxy;
51 } // namespace query_state
53 
54 namespace Parser {
55 
56 /*
57  * @type Node
58  * @brief root super class for all nodes in a pre-Analyzer
59  * parse tree.
60  */
61 class Node {
62  public:
63  virtual ~Node() {}
64 };
65 
66 /*
67  * @type SQLType
68  * @brief class that captures type, predication and scale.
69  */
70 class SQLType : public Node {
71  public:
72  explicit SQLType(SQLTypes t)
73  : type(t), param1(-1), param2(0), is_array(false), array_size(-1) {}
74  SQLType(SQLTypes t, int p1)
75  : type(t), param1(p1), param2(0), is_array(false), array_size(-1) {}
76  SQLType(SQLTypes t, int p1, int p2, bool a)
77  : type(t), param1(p1), param2(p2), is_array(a), array_size(-1) {}
78  SQLTypes get_type() const { return type; }
79  int get_param1() const { return param1; }
80  int get_param2() const { return param2; }
81  bool get_is_array() const { return is_array; }
82  void set_is_array(bool a) { is_array = a; }
83  int get_array_size() const { return array_size; }
84  void set_array_size(int s) { array_size = s; }
85  std::string to_string() const;
86  void check_type();
87 
88  private:
90  int param1; // e.g. for NUMERIC(10). -1 means unspecified.
91  int param2; // e.g. for NUMERIC(10,3). 0 is default value.
92  bool is_array;
94 };
95 
96 /*
97  * @type Expr
98  * @brief root super class for all expression nodes
99  */
100 class Expr : public Node {
101  public:
103  /*
104  * @brief Performs semantic analysis on the expression node
105  * @param catalog The catalog object for the current database
106  * @return An Analyzer::Expr object for the expression post semantic analysis
107  */
108  virtual std::shared_ptr<Analyzer::Expr> analyze(
109  const Catalog_Namespace::Catalog& catalog,
110  Analyzer::Query& query,
111  TlistRefType allow_tlist_ref = TLIST_NONE) const = 0;
112  virtual std::string to_string() const = 0;
113 };
114 
115 /*
116  * @type Literal
117  * @brief root super class for all literals
118  */
119 class Literal : public Expr {
120  public:
121  std::shared_ptr<Analyzer::Expr> analyze(
122  const Catalog_Namespace::Catalog& catalog,
123  Analyzer::Query& query,
124  TlistRefType allow_tlist_ref = TLIST_NONE) const override = 0;
125  std::string to_string() const override = 0;
126 };
127 
128 /*
129  * @type NullLiteral
130  * @brief the Literal NULL
131  */
132 class NullLiteral : public Literal {
133  public:
135  std::shared_ptr<Analyzer::Expr> analyze(
136  const Catalog_Namespace::Catalog& catalog,
137  Analyzer::Query& query,
138  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
139  std::string to_string() const override { return "NULL"; }
140 };
141 
142 /*
143  * @type StringLiteral
144  * @brief the literal for string constants
145  */
146 class StringLiteral : public Literal {
147  public:
148  explicit StringLiteral(std::string* s) : stringval(s) {}
149  const std::string* get_stringval() const { return stringval.get(); }
150  std::shared_ptr<Analyzer::Expr> analyze(
151  const Catalog_Namespace::Catalog& catalog,
152  Analyzer::Query& query,
153  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
154  static std::shared_ptr<Analyzer::Expr> analyzeValue(const std::string&);
155  std::string to_string() const override { return "'" + *stringval + "'"; }
156 
157  private:
158  std::unique_ptr<std::string> stringval;
159 };
160 
161 /*
162  * @type IntLiteral
163  * @brief the literal for integer constants
164  */
165 class IntLiteral : public Literal {
166  public:
167  explicit IntLiteral(int64_t i) : intval(i) {}
168  int64_t get_intval() const { return intval; }
169  std::shared_ptr<Analyzer::Expr> analyze(
170  const Catalog_Namespace::Catalog& catalog,
171  Analyzer::Query& query,
172  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
173  static std::shared_ptr<Analyzer::Expr> analyzeValue(const int64_t intval);
174  std::string to_string() const override {
175  return boost::lexical_cast<std::string>(intval);
176  }
177 
178  private:
179  int64_t intval;
180 };
181 
182 /*
183  * @type FixedPtLiteral
184  * @brief the literal for DECIMAL and NUMERIC
185  */
186 class FixedPtLiteral : public Literal {
187  public:
188  explicit FixedPtLiteral(std::string* n) : fixedptval(n) {}
189  const std::string* get_fixedptval() const { return fixedptval.get(); }
190  std::shared_ptr<Analyzer::Expr> analyze(
191  const Catalog_Namespace::Catalog& catalog,
192  Analyzer::Query& query,
193  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
194  static std::shared_ptr<Analyzer::Expr> analyzeValue(const int64_t numericval,
195  const int scale,
196  const int precision);
197  std::string to_string() const override { return *fixedptval; }
198 
199  private:
200  std::unique_ptr<std::string> fixedptval;
201 };
202 
203 /*
204  * @type FloatLiteral
205  * @brief the literal for FLOAT or REAL
206  */
207 class FloatLiteral : public Literal {
208  public:
209  explicit FloatLiteral(float f) : floatval(f) {}
210  float get_floatval() const { return floatval; }
211  std::shared_ptr<Analyzer::Expr> analyze(
212  const Catalog_Namespace::Catalog& catalog,
213  Analyzer::Query& query,
214  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
215  std::string to_string() const override {
216  return boost::lexical_cast<std::string>(floatval);
217  }
218 
219  private:
220  float floatval;
221 };
222 
223 /*
224  * @type DoubleLiteral
225  * @brief the literal for DOUBLE PRECISION
226  */
227 class DoubleLiteral : public Literal {
228  public:
229  explicit DoubleLiteral(double d) : doubleval(d) {}
230  double get_doubleval() const { return doubleval; }
231  std::shared_ptr<Analyzer::Expr> analyze(
232  const Catalog_Namespace::Catalog& catalog,
233  Analyzer::Query& query,
234  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
235  std::string to_string() const override {
236  return boost::lexical_cast<std::string>(doubleval);
237  }
238 
239  private:
240  double doubleval;
241 };
242 
243 /*
244  * @type TimestampLiteral
245  * @brief the literal for Timestamp
246  */
247 class TimestampLiteral : public Literal {
248  public:
249  explicit TimestampLiteral() { time(reinterpret_cast<time_t*>(&timestampval_)); }
250  std::shared_ptr<Analyzer::Expr> analyze(
251  const Catalog_Namespace::Catalog& catalog,
252  Analyzer::Query& query,
253  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
254  static std::shared_ptr<Analyzer::Expr> get(const int64_t);
255  std::string to_string() const override {
256  // TODO: Should we convert to a datum and use the datum toString converters to pretty
257  // print?
258  return boost::lexical_cast<std::string>(timestampval_);
259  }
260 
261  private:
262  int64_t timestampval_;
263 };
264 
265 /*
266  * @type UserLiteral
267  * @brief the literal for USER
268  */
269 class UserLiteral : public Literal {
270  public:
272  std::shared_ptr<Analyzer::Expr> analyze(
273  const Catalog_Namespace::Catalog& catalog,
274  Analyzer::Query& query,
275  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
276  std::string to_string() const override { return "USER"; }
277 };
278 
279 /*
280  * @type ArrayLiteral
281  * @brief the literal for arrays
282  */
283 class ArrayLiteral : public Literal {
284  public:
286  ArrayLiteral(std::list<Expr*>* v) {
287  CHECK(v);
288  for (const auto e : *v) {
289  value_list.emplace_back(e);
290  }
291  delete v;
292  }
293  const std::list<std::unique_ptr<Expr>>& get_value_list() const { return value_list; }
294  std::shared_ptr<Analyzer::Expr> analyze(
295  const Catalog_Namespace::Catalog& catalog,
296  Analyzer::Query& query,
297  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
298  std::string to_string() const override;
299 
300  private:
301  std::list<std::unique_ptr<Expr>> value_list;
302 };
303 
304 /*
305  * @type OperExpr
306  * @brief all operator expressions
307  */
308 class OperExpr : public Expr {
309  public:
311  : optype(t), opqualifier(kONE), left(l), right(r) {}
313  : optype(t), opqualifier(q), left(l), right(r) {}
314  SQLOps get_optype() const { return optype; }
315  const Expr* get_left() const { return left.get(); }
316  const Expr* get_right() const { return right.get(); }
317  std::shared_ptr<Analyzer::Expr> analyze(
318  const Catalog_Namespace::Catalog& catalog,
319  Analyzer::Query& query,
320  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
321  static std::shared_ptr<Analyzer::Expr> normalize(
322  const SQLOps optype,
323  const SQLQualifier qual,
324  std::shared_ptr<Analyzer::Expr> left_expr,
325  std::shared_ptr<Analyzer::Expr> right_expr);
326  std::string to_string() const override;
327 
328  private:
331  std::unique_ptr<Expr> left;
332  std::unique_ptr<Expr> right;
333 };
334 
335 // forward reference of QuerySpec
336 class QuerySpec;
337 
338 /*
339  * @type SubqueryExpr
340  * @brief expression for subquery
341  */
342 class SubqueryExpr : public Expr {
343  public:
344  explicit SubqueryExpr(QuerySpec* q) : query(q) {}
345  const QuerySpec* get_query() const { return query.get(); }
346  std::shared_ptr<Analyzer::Expr> analyze(
347  const Catalog_Namespace::Catalog& catalog,
349  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
350  std::string to_string() const override;
351 
352  private:
353  std::unique_ptr<QuerySpec> query;
354 };
355 
356 class IsNullExpr : public Expr {
357  public:
358  IsNullExpr(bool n, Expr* a) : is_not(n), arg(a) {}
359  bool get_is_not() const { return is_not; }
360  std::shared_ptr<Analyzer::Expr> analyze(
361  const Catalog_Namespace::Catalog& catalog,
362  Analyzer::Query& query,
363  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
364  std::string to_string() const override;
365 
366  private:
367  bool is_not;
368  std::unique_ptr<Expr> arg;
369 };
370 
371 /*
372  * @type InExpr
373  * @brief expression for the IS NULL predicate
374  */
375 class InExpr : public Expr {
376  public:
377  InExpr(bool n, Expr* a) : is_not(n), arg(a) {}
378  bool get_is_not() const { return is_not; }
379  const Expr* get_arg() const { return arg.get(); }
380  std::shared_ptr<Analyzer::Expr> analyze(
381  const Catalog_Namespace::Catalog& catalog,
382  Analyzer::Query& query,
383  TlistRefType allow_tlist_ref = TLIST_NONE) const override = 0;
384  std::string to_string() const override;
385 
386  protected:
387  bool is_not;
388  std::unique_ptr<Expr> arg;
389 };
390 
391 /*
392  * @type InSubquery
393  * @brief expression for the IN (subquery) predicate
394  */
395 class InSubquery : public InExpr {
396  public:
397  InSubquery(bool n, Expr* a, SubqueryExpr* q) : InExpr(n, a), subquery(q) {}
398  const SubqueryExpr* get_subquery() const { return subquery.get(); }
399  std::shared_ptr<Analyzer::Expr> analyze(
400  const Catalog_Namespace::Catalog& catalog,
401  Analyzer::Query& query,
402  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
403  std::string to_string() const override;
404 
405  private:
406  std::unique_ptr<SubqueryExpr> subquery;
407 };
408 
409 /*
410  * @type InValues
411  * @brief expression for IN (val1, val2, ...)
412  */
413 class InValues : public InExpr {
414  public:
415  InValues(bool n, Expr* a, std::list<Expr*>* v) : InExpr(n, a) {
416  CHECK(v);
417  for (const auto e : *v) {
418  value_list.emplace_back(e);
419  }
420  delete v;
421  }
422  const std::list<std::unique_ptr<Expr>>& get_value_list() const { return value_list; }
423  std::shared_ptr<Analyzer::Expr> analyze(
424  const Catalog_Namespace::Catalog& catalog,
425  Analyzer::Query& query,
426  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
427  std::string to_string() const override;
428 
429  private:
430  std::list<std::unique_ptr<Expr>> value_list;
431 };
432 
433 /*
434  * @type BetweenExpr
435  * @brief expression for BETWEEN lower AND upper
436  */
437 class BetweenExpr : public Expr {
438  public:
439  BetweenExpr(bool n, Expr* a, Expr* l, Expr* u)
440  : is_not(n), arg(a), lower(l), upper(u) {}
441  bool get_is_not() const { return is_not; }
442  const Expr* get_arg() const { return arg.get(); }
443  const Expr* get_lower() const { return lower.get(); }
444  const Expr* get_upper() const { return upper.get(); }
445  std::shared_ptr<Analyzer::Expr> analyze(
446  const Catalog_Namespace::Catalog& catalog,
447  Analyzer::Query& query,
448  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
449  std::string to_string() const override;
450 
451  private:
452  bool is_not;
453  std::unique_ptr<Expr> arg;
454  std::unique_ptr<Expr> lower;
455  std::unique_ptr<Expr> upper;
456 };
457 
458 /*
459  * @type CharLengthExpr
460  * @brief expression to get length of string
461  */
462 
463 class CharLengthExpr : public Expr {
464  public:
465  CharLengthExpr(Expr* a, bool e) : arg(a), calc_encoded_length(e) {}
466  const Expr* get_arg() const { return arg.get(); }
468  std::shared_ptr<Analyzer::Expr> analyze(
469  const Catalog_Namespace::Catalog& catalog,
470  Analyzer::Query& query,
471  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
472  std::string to_string() const override;
473 
474  private:
475  std::unique_ptr<Expr> arg;
477 };
478 
479 /*
480  * @type CardinalityExpr
481  * @brief expression to get cardinality of an array
482  */
483 
484 class CardinalityExpr : public Expr {
485  public:
487  const Expr* get_arg() const { return arg.get(); }
488  std::shared_ptr<Analyzer::Expr> analyze(
489  const Catalog_Namespace::Catalog& catalog,
490  Analyzer::Query& query,
491  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
492  std::string to_string() const override;
493 
494  private:
495  std::unique_ptr<Expr> arg;
496 };
497 
498 /*
499  * @type LikeExpr
500  * @brief expression for the LIKE predicate
501  */
502 class LikeExpr : public Expr {
503  public:
504  LikeExpr(bool n, bool i, Expr* a, Expr* l, Expr* e)
505  : is_not(n), is_ilike(i), arg(a), like_string(l), escape_string(e) {}
506  bool get_is_not() const { return is_not; }
507  const Expr* get_arg() const { return arg.get(); }
508  const Expr* get_like_string() const { return like_string.get(); }
509  const Expr* get_escape_string() const { return escape_string.get(); }
510  std::shared_ptr<Analyzer::Expr> analyze(
511  const Catalog_Namespace::Catalog& catalog,
512  Analyzer::Query& query,
513  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
514  static std::shared_ptr<Analyzer::Expr> get(std::shared_ptr<Analyzer::Expr> arg_expr,
515  std::shared_ptr<Analyzer::Expr> like_expr,
516  std::shared_ptr<Analyzer::Expr> escape_expr,
517  const bool is_ilike,
518  const bool is_not);
519  std::string to_string() const override;
520 
521  private:
522  bool is_not;
523  bool is_ilike;
524  std::unique_ptr<Expr> arg;
525  std::unique_ptr<Expr> like_string;
526  std::unique_ptr<Expr> escape_string;
527 
528  static void check_like_expr(const std::string& like_str, char escape_char);
529  static bool test_is_simple_expr(const std::string& like_str, char escape_char);
530  static void erase_cntl_chars(std::string& like_str, char escape_char);
531 };
532 
533 /*
534  * @type RegexpExpr
535  * @brief expression for REGEXP
536  */
537 class RegexpExpr : public Expr {
538  public:
539  RegexpExpr(bool n, Expr* a, Expr* p, Expr* e)
540  : is_not(n), arg(a), pattern_string(p), escape_string(e) {}
541  bool get_is_not() const { return is_not; }
542  const Expr* get_arg() const { return arg.get(); }
543  const Expr* get_pattern_string() const { return pattern_string.get(); }
544  const Expr* get_escape_string() const { return escape_string.get(); }
545  std::shared_ptr<Analyzer::Expr> analyze(
546  const Catalog_Namespace::Catalog& catalog,
547  Analyzer::Query& query,
548  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
549  static std::shared_ptr<Analyzer::Expr> get(std::shared_ptr<Analyzer::Expr> arg_expr,
550  std::shared_ptr<Analyzer::Expr> pattern_expr,
551  std::shared_ptr<Analyzer::Expr> escape_expr,
552  const bool is_not);
553  std::string to_string() const override;
554 
555  private:
556  bool is_not;
557  std::unique_ptr<Expr> arg;
558  std::unique_ptr<Expr> pattern_string;
559  std::unique_ptr<Expr> escape_string;
560 
561  static void check_pattern_expr(const std::string& pattern_str, char escape_char);
562  static bool translate_to_like_pattern(std::string& pattern_str, char escape_char);
563 };
564 
565 /*
566  * @type LikelihoodExpr
567  * @brief expression for LIKELY, UNLIKELY
568  */
569 class LikelihoodExpr : public Expr {
570  public:
571  LikelihoodExpr(bool n, Expr* a, float l) : is_not(n), arg(a), likelihood(l) {}
572  bool get_is_not() const { return is_not; }
573  const Expr* get_arg() const { return arg.get(); }
574  float get_likelihood() const { return likelihood; }
575  std::shared_ptr<Analyzer::Expr> analyze(
576  const Catalog_Namespace::Catalog& catalog,
577  Analyzer::Query& query,
578  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
579  static std::shared_ptr<Analyzer::Expr> get(std::shared_ptr<Analyzer::Expr> arg_expr,
580  float likelihood,
581  const bool is_not);
582  std::string to_string() const override;
583 
584  private:
585  bool is_not;
586  std::unique_ptr<Expr> arg;
587  float likelihood;
588 };
589 
590 /*
591  * @type ExistsExpr
592  * @brief expression for EXISTS (subquery)
593  */
594 class ExistsExpr : public Expr {
595  public:
596  explicit ExistsExpr(QuerySpec* q) : query(q) {}
597  const QuerySpec* get_query() const { return query.get(); }
598  std::shared_ptr<Analyzer::Expr> analyze(
599  const Catalog_Namespace::Catalog& catalog,
601  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
602  std::string to_string() const override;
603 
604  private:
605  std::unique_ptr<QuerySpec> query;
606 };
607 
608 /*
609  * @type ColumnRef
610  * @brief expression for a column reference
611  */
612 class ColumnRef : public Expr {
613  public:
614  explicit ColumnRef(std::string* n1) : table(nullptr), column(n1) {}
615  ColumnRef(std::string* n1, std::string* n2) : table(n1), column(n2) {}
616  const std::string* get_table() const { return table.get(); }
617  const std::string* get_column() const { return column.get(); }
618  std::shared_ptr<Analyzer::Expr> analyze(
619  const Catalog_Namespace::Catalog& catalog,
620  Analyzer::Query& query,
621  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
622  std::string to_string() const override;
623 
624  private:
625  std::unique_ptr<std::string> table;
626  std::unique_ptr<std::string> column; // can be nullptr in the t.* case
627 };
628 
629 /*
630  * @type FunctionRef
631  * @brief expression for a function call
632  */
633 class FunctionRef : public Expr {
634  public:
635  explicit FunctionRef(std::string* n) : name(n), distinct(false), arg(nullptr) {}
636  FunctionRef(std::string* n, Expr* a) : name(n), distinct(false), arg(a) {}
637  FunctionRef(std::string* n, bool d, Expr* a) : name(n), distinct(d), arg(a) {}
638  const std::string* get_name() const { return name.get(); }
639  bool get_distinct() const { return distinct; }
640  Expr* get_arg() const { return arg.get(); }
641  std::shared_ptr<Analyzer::Expr> analyze(
642  const Catalog_Namespace::Catalog& catalog,
643  Analyzer::Query& query,
644  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
645  std::string to_string() const override;
646 
647  private:
648  std::unique_ptr<std::string> name;
649  bool distinct; // only true for COUNT(DISTINCT x)
650  std::unique_ptr<Expr> arg; // for COUNT, nullptr means '*'
651 };
652 
653 class CastExpr : public Expr {
654  public:
655  CastExpr(Expr* a, SQLType* t) : arg(a), target_type(t) {}
656  std::shared_ptr<Analyzer::Expr> analyze(
657  const Catalog_Namespace::Catalog& catalog,
658  Analyzer::Query& query,
659  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
660  std::string to_string() const override {
661  return "CAST(" + arg->to_string() + " AS " + target_type->to_string() + ")";
662  }
663 
664  private:
665  std::unique_ptr<Expr> arg;
666  std::unique_ptr<SQLType> target_type;
667 };
668 
669 class ExprPair : public Node {
670  public:
671  ExprPair(Expr* e1, Expr* e2) : expr1(e1), expr2(e2) {}
672  const Expr* get_expr1() const { return expr1.get(); }
673  const Expr* get_expr2() const { return expr2.get(); }
674 
675  private:
676  std::unique_ptr<Expr> expr1;
677  std::unique_ptr<Expr> expr2;
678 };
679 
680 class CaseExpr : public Expr {
681  public:
682  CaseExpr(std::list<ExprPair*>* w, Expr* e) : else_expr(e) {
683  CHECK(w);
684  for (const auto e : *w) {
685  when_then_list.emplace_back(e);
686  }
687  delete w;
688  }
689  std::shared_ptr<Analyzer::Expr> analyze(
690  const Catalog_Namespace::Catalog& catalog,
691  Analyzer::Query& query,
692  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
693  static std::shared_ptr<Analyzer::Expr> normalize(
694  const std::list<
695  std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>&,
696  const std::shared_ptr<Analyzer::Expr>);
697  std::string to_string() const override;
698 
699  private:
700  std::list<std::unique_ptr<ExprPair>> when_then_list;
701  std::unique_ptr<Expr> else_expr;
702 };
703 
704 /*
705  * @type TableRef
706  * @brief table reference in FROM clause
707  */
708 class TableRef : public Node {
709  public:
710  explicit TableRef(std::string* t) : table_name(t), range_var(nullptr) {}
711  TableRef(std::string* t, std::string* r) : table_name(t), range_var(r) {}
712  const std::string* get_table_name() const { return table_name.get(); }
713  const std::string* get_range_var() const { return range_var.get(); }
714  std::string to_string() const;
715 
716  private:
717  std::unique_ptr<std::string> table_name;
718  std::unique_ptr<std::string> range_var;
719 };
720 
721 /*
722  * @type Stmt
723  * @brief root super class for all SQL statements
724  */
725 class Stmt : public Node {
726  // intentionally empty
727 };
728 
729 /*
730  * @type DMLStmt
731  * @brief DML Statements
732  */
733 class DMLStmt : public Stmt {
734  public:
735  virtual void analyze(const Catalog_Namespace::Catalog& catalog,
736  Analyzer::Query& query) const = 0;
737 };
738 
739 /*
740  * @type DDLStmt
741  * @brief DDL Statements
742  */
743 class ColumnDef;
744 class DDLStmt : public Stmt {
745  public:
746  virtual void execute(const Catalog_Namespace::SessionInfo& session) = 0;
747  void setColumnDescriptor(ColumnDescriptor& cd, const ColumnDef* coldef);
748 };
749 
750 /*
751  * @type TableElement
752  * @brief elements in table definition
753  */
754 class TableElement : public Node {
755  // intentionally empty
756 };
757 
758 /*
759  * @type ColumnConstraintDef
760  * @brief integrity constraint on a column
761  */
762 class ColumnConstraintDef : public Node {
763  public:
764  ColumnConstraintDef(bool n, bool u, bool p, Literal* d)
765  : notnull(n), unique(u), is_primarykey(p), defaultval(d) {}
768  ColumnConstraintDef(std::string* t, std::string* c)
769  : notnull(false)
770  , unique(false)
772  , foreign_table(t)
773  , foreign_column(c) {}
774  bool get_notnull() const { return notnull; }
775  bool get_unique() const { return unique; }
776  bool get_is_primarykey() const { return is_primarykey; }
777  const Literal* get_defaultval() const { return defaultval.get(); }
778  const Expr* get_check_condition() const { return check_condition.get(); }
779  const std::string* get_foreign_table() const { return foreign_table.get(); }
780  const std::string* get_foreign_column() const { return foreign_column.get(); }
781 
782  private:
783  bool notnull;
784  bool unique;
786  std::unique_ptr<Literal> defaultval;
787  std::unique_ptr<Expr> check_condition;
788  std::unique_ptr<std::string> foreign_table;
789  std::unique_ptr<std::string> foreign_column;
790 };
791 
792 /*
793  * @type CompressDef
794  * @brief Node for compression scheme definition
795  */
796 class CompressDef : public Node {
797  public:
798  CompressDef(std::string* n, int p) : encoding_name(n), encoding_param(p) {}
799  const std::string* get_encoding_name() const { return encoding_name.get(); }
800  int get_encoding_param() const { return encoding_param; }
801 
802  private:
803  std::unique_ptr<std::string> encoding_name;
805 };
806 
807 /*
808  * @type ColumnDef
809  * @brief Column definition
810  */
811 class ColumnDef : public TableElement {
812  public:
813  ColumnDef(std::string* c, SQLType* t, CompressDef* cp, ColumnConstraintDef* cc)
815  const std::string* get_column_name() const { return column_name.get(); }
816  SQLType* get_column_type() const { return column_type.get(); }
817  const CompressDef* get_compression() const { return compression.get(); }
819  return column_constraint.get();
820  }
821 
822  private:
823  std::unique_ptr<std::string> column_name;
824  std::unique_ptr<SQLType> column_type;
825  std::unique_ptr<CompressDef> compression;
826  std::unique_ptr<ColumnConstraintDef> column_constraint;
827 };
828 
829 /*
830  * @type TableConstraintDef
831  * @brief integrity constraint for table
832  */
834  // intentionally empty
835 };
836 
837 /*
838  * @type UniqueDef
839  * @brief uniqueness constraint
840  */
842  public:
843  UniqueDef(bool p, std::list<std::string*>* cl) : is_primarykey(p) {
844  CHECK(cl);
845  for (const auto s : *cl) {
846  column_list.emplace_back(s);
847  }
848  delete cl;
849  }
850  bool get_is_primarykey() const { return is_primarykey; }
851  const std::list<std::unique_ptr<std::string>>& get_column_list() const {
852  return column_list;
853  }
854 
855  private:
857  std::list<std::unique_ptr<std::string>> column_list;
858 };
859 
860 /*
861  * @type ForeignKeyDef
862  * @brief foreign key constraint
863  */
865  public:
866  ForeignKeyDef(std::list<std::string*>* cl, std::string* t, std::list<std::string*>* fcl)
867  : foreign_table(t) {
868  CHECK(cl);
869  for (const auto s : *cl) {
870  column_list.emplace_back(s);
871  }
872  delete cl;
873  if (fcl) {
874  for (const auto s : *fcl) {
875  foreign_column_list.emplace_back(s);
876  }
877  }
878  delete fcl;
879  }
880  const std::list<std::unique_ptr<std::string>>& get_column_list() const {
881  return column_list;
882  }
883  const std::string* get_foreign_table() const { return foreign_table.get(); }
884  const std::list<std::unique_ptr<std::string>>& get_foreign_column_list() const {
885  return foreign_column_list;
886  }
887 
888  private:
889  std::list<std::unique_ptr<std::string>> column_list;
890  std::unique_ptr<std::string> foreign_table;
891  std::list<std::unique_ptr<std::string>> foreign_column_list;
892 };
893 
894 /*
895  * @type CheckDef
896  * @brief Check constraint
897  */
898 class CheckDef : public TableConstraintDef {
899  public:
901  const Expr* get_check_condition() const { return check_condition.get(); }
902 
903  private:
904  std::unique_ptr<Expr> check_condition;
905 };
906 
907 /*
908  * @type SharedDictionaryDef
909  * @brief Shared dictionary hint. The underlying string dictionary will be shared with the
910  * referenced column.
911  */
913  public:
914  SharedDictionaryDef(const std::string& column,
915  const std::string& foreign_table,
916  const std::string foreign_column)
917  : column_(column), foreign_table_(foreign_table), foreign_column_(foreign_column) {}
918 
919  const std::string& get_column() const { return column_; }
920 
921  const std::string& get_foreign_table() const { return foreign_table_; }
922 
923  const std::string& get_foreign_column() const { return foreign_column_; }
924 
925  private:
926  const std::string column_;
927  const std::string foreign_table_;
928  const std::string foreign_column_;
929 };
930 
931 /*
932  * @type ShardKeyDef
933  * @brief Shard key for a table, mainly useful for distributed joins.
934  */
936  public:
937  ShardKeyDef(const std::string& column) : column_(column) {}
938 
939  const std::string& get_column() const { return column_; }
940 
941  private:
942  const std::string column_;
943 };
944 
945 /*
946  * @type NameValueAssign
947  * @brief Assignment of a string value to a named attribute
948  */
949 class NameValueAssign : public Node {
950  public:
951  NameValueAssign(std::string* n, Literal* v) : name(n), value(v) {}
952  const std::string* get_name() const { return name.get(); }
953  const Literal* get_value() const { return value.get(); }
954 
955  private:
956  std::unique_ptr<std::string> name;
957  std::unique_ptr<Literal> value;
958 };
959 
960 /*
961  * @type CreateTableStmt
962  * @brief CREATE TABLE statement
963  */
964 class CreateTableStmt : public DDLStmt {
965  public:
966  CreateTableStmt(std::string* tab,
967  std::list<TableElement*>* table_elems,
968  bool is_temporary,
969  bool if_not_exists,
970  std::list<NameValueAssign*>* s)
971  : table_(tab), is_temporary_(is_temporary), if_not_exists_(if_not_exists) {
972  CHECK(table_elems);
973  for (const auto e : *table_elems) {
974  table_element_list_.emplace_back(e);
975  }
976  delete table_elems;
977  if (s) {
978  for (const auto e : *s) {
979  storage_options_.emplace_back(e);
980  }
981  delete s;
982  }
983  }
984  const std::string* get_table() const { return table_.get(); }
985  const std::list<std::unique_ptr<TableElement>>& get_table_element_list() const {
986  return table_element_list_;
987  }
988 
989  void execute(const Catalog_Namespace::SessionInfo& session) override;
990  void executeDryRun(const Catalog_Namespace::SessionInfo& session,
991  TableDescriptor& td,
992  std::list<ColumnDescriptor>& columns,
993  std::vector<SharedDictionaryDef>& shared_dict_defs);
994 
995  private:
996  std::unique_ptr<std::string> table_;
997  std::list<std::unique_ptr<TableElement>> table_element_list_;
1000  std::list<std::unique_ptr<NameValueAssign>> storage_options_;
1001 };
1002 
1003 /*
1004  * @type InsertIntoTableAsSelectStmt
1005  * @brief INSERT INTO TABLE SELECT statement
1006  */
1008  public:
1009  // ITAS constructor
1010  InsertIntoTableAsSelectStmt(const std::string* table_name,
1011  const std::string* select_query,
1012  std::list<std::string*>* c)
1013  : table_name_(*table_name), select_query_(*select_query) {
1014  if (c) {
1015  for (auto e : *c) {
1016  column_list_.emplace_back(e);
1017  }
1018  delete c;
1019  }
1020 
1021  delete table_name;
1022  delete select_query;
1023  }
1024 
1025  void populateData(QueryStateProxy, bool is_temporary, bool validate_table);
1026  void execute(const Catalog_Namespace::SessionInfo& session) override;
1027 
1028  std::string& get_table() { return table_name_; }
1029 
1030  std::string& get_select_query() { return select_query_; }
1031 
1034  virtual AggregatedResult query(QueryStateProxy, std::string& sql_query_string) = 0;
1035  virtual void checkpoint(const Catalog_Namespace::SessionInfo& parent_session_info,
1036  int tableId) = 0;
1037  virtual void rollback(const Catalog_Namespace::SessionInfo& parent_session_info,
1038  int tableId) = 0;
1039  };
1040 
1042  virtual ~LocalConnector() {}
1044  std::string& sql_query_string,
1045  bool validate_only);
1046  AggregatedResult query(QueryStateProxy, std::string& sql_query_string) override;
1047  size_t leafCount() override { return 1; };
1049  const size_t leaf_idx,
1050  Fragmenter_Namespace::InsertData& insert_data) override;
1051  void checkpoint(const Catalog_Namespace::SessionInfo& session, int tableId) override;
1052  void rollback(const Catalog_Namespace::SessionInfo& session, int tableId) override;
1053  std::list<ColumnDescriptor> getColumnDescriptors(AggregatedResult& result,
1054  bool for_create);
1055  };
1056 
1058 
1059  protected:
1060  std::vector<std::unique_ptr<std::string>> column_list_;
1061  std::string table_name_;
1062  std::string select_query_;
1063 };
1064 
1065 /*
1066  * @type CreateTableAsSelectStmt
1067  * @brief CREATE TABLE AS SELECT statement
1068  */
1070  public:
1071  CreateTableAsSelectStmt(const std::string* table_name,
1072  const std::string* select_query,
1073  const bool is_temporary,
1074  const bool if_not_exists,
1075  std::list<NameValueAssign*>* s)
1076  : InsertIntoTableAsSelectStmt(table_name, select_query, nullptr)
1077  , is_temporary_(is_temporary)
1078  , if_not_exists_(if_not_exists) {
1079  if (s) {
1080  for (const auto& e : *s) {
1081  storage_options_.emplace_back(e);
1082  }
1083  delete s;
1084  }
1085  }
1086 
1087  void execute(const Catalog_Namespace::SessionInfo& session) override;
1088 
1089  private:
1090  const bool is_temporary_;
1091  const bool if_not_exists_;
1092  std::list<std::unique_ptr<NameValueAssign>> storage_options_;
1093 };
1094 
1095 /*
1096  * @type DropTableStmt
1097  * @brief DROP TABLE statement
1098  */
1099 class DropTableStmt : public DDLStmt {
1100  public:
1101  DropTableStmt(std::string* tab, bool i) : table(tab), if_exists(i) {}
1102  const std::string* get_table() const { return table.get(); }
1103  void execute(const Catalog_Namespace::SessionInfo& session) override;
1104 
1105  private:
1106  std::unique_ptr<std::string> table;
1108 };
1109 
1110 /*
1111  * @type TruncateTableStmt
1112  * @brief TRUNCATE TABLE statement
1113  */
1114 class TruncateTableStmt : public DDLStmt {
1115  public:
1116  TruncateTableStmt(std::string* tab) : table(tab) {}
1117  const std::string* get_table() const { return table.get(); }
1118  void execute(const Catalog_Namespace::SessionInfo& session) override;
1119 
1120  private:
1121  std::unique_ptr<std::string> table;
1122 };
1123 
1124 class OptimizeTableStmt : public DDLStmt {
1125  public:
1126  OptimizeTableStmt(std::string* table, std::list<NameValueAssign*>* o) : table_(table) {
1127  if (!table_) {
1128  throw std::runtime_error("Table name is required for OPTIMIZE command.");
1129  }
1130  if (o) {
1131  for (const auto e : *o) {
1132  options_.emplace_back(e);
1133  }
1134  delete o;
1135  }
1136  }
1137 
1138  const std::string getTableName() const { return *(table_.get()); }
1139 
1141  for (const auto& e : options_) {
1142  if (boost::iequals(*(e->get_name()), "VACUUM")) {
1143  return true;
1144  }
1145  }
1146  return false;
1147  }
1148 
1149  void execute(const Catalog_Namespace::SessionInfo& session) override {
1150  // Should pass optimize params to the table optimizer
1151  CHECK(false);
1152  }
1153 
1154  private:
1155  std::unique_ptr<std::string> table_;
1156  std::list<std::unique_ptr<NameValueAssign>> options_;
1157 };
1158 
1159 class ValidateStmt : public DDLStmt {
1160  public:
1161  ValidateStmt(std::string* type, std::list<NameValueAssign*>* with_opts) : type_(type) {
1162  if (!type_) {
1163  throw std::runtime_error("Validation Type is required for VALIDATE command.");
1164  }
1165  std::list<std::unique_ptr<NameValueAssign>> options;
1166  if (with_opts) {
1167  for (const auto e : *with_opts) {
1168  options.emplace_back(e);
1169  }
1170  delete with_opts;
1171 
1172  for (const auto& opt : options) {
1173  if (boost::iequals(*opt->get_name(), "REPAIR_TYPE")) {
1174  const auto repair_type =
1175  static_cast<const StringLiteral*>(opt->get_value())->get_stringval();
1176  CHECK(repair_type);
1177  if (boost::iequals(*repair_type, "REMOVE")) {
1178  isRepairTypeRemove_ = true;
1179  } else {
1180  throw std::runtime_error("REPAIR_TYPE must be REMOVE.");
1181  }
1182  } else {
1183  throw std::runtime_error("The only VALIDATE WITH options is REPAIR_TYPE.");
1184  }
1185  }
1186  }
1187  }
1188 
1189  bool isRepairTypeRemove() const { return isRepairTypeRemove_; }
1190 
1191  const std::string getType() const { return *(type_.get()); }
1192 
1193  void execute(const Catalog_Namespace::SessionInfo& session) override { UNREACHABLE(); }
1194 
1195  private:
1196  std::unique_ptr<std::string> type_;
1197  bool isRepairTypeRemove_ = false;
1198 };
1199 
1200 class RenameDatabaseStmt : public DDLStmt {
1201  public:
1202  RenameDatabaseStmt(std::string* database_name, std::string* new_database_name)
1203  : database_name_(database_name), new_database_name_(new_database_name) {}
1204 
1205  auto const& getPreviousDatabaseName() { return database_name_; }
1206  auto const& getNewDatabaseName() { return new_database_name_; }
1207  void execute(const Catalog_Namespace::SessionInfo& session) override;
1208 
1209  private:
1210  std::unique_ptr<std::string> database_name_;
1211  std::unique_ptr<std::string> new_database_name_;
1212 };
1213 
1214 class RenameUserStmt : public DDLStmt {
1215  public:
1216  RenameUserStmt(std::string* username, std::string* new_username)
1217  : username_(username), new_username_(new_username) {}
1218  auto const& getOldUserName() { return username_; }
1219  auto const& getNewUserName() { return new_username_; }
1220  void execute(const Catalog_Namespace::SessionInfo& session) override;
1221 
1222  private:
1223  std::unique_ptr<std::string> username_;
1224  std::unique_ptr<std::string> new_username_;
1225 };
1226 
1227 class RenameTableStmt : public DDLStmt {
1228  public:
1229  RenameTableStmt(std::string* tab, std::string* new_tab_name)
1230  : table(tab), new_table_name(new_tab_name) {}
1231 
1232  const std::string* get_prev_table() const { return table.get(); }
1233  const std::string* get_new_table() const { return new_table_name.get(); }
1234  void execute(const Catalog_Namespace::SessionInfo& session) override;
1235 
1236  private:
1237  std::unique_ptr<std::string> table;
1238  std::unique_ptr<std::string> new_table_name;
1239 };
1240 
1241 class RenameColumnStmt : public DDLStmt {
1242  public:
1243  RenameColumnStmt(std::string* tab, std::string* col, std::string* new_col_name)
1244  : table(tab), column(col), new_column_name(new_col_name) {}
1245  void execute(const Catalog_Namespace::SessionInfo& session) override;
1246 
1247  private:
1248  std::unique_ptr<std::string> table;
1249  std::unique_ptr<std::string> column;
1250  std::unique_ptr<std::string> new_column_name;
1251 };
1252 
1253 class AddColumnStmt : public DDLStmt {
1254  public:
1255  AddColumnStmt(std::string* tab, ColumnDef* coldef) : table(tab), coldef(coldef) {}
1256  AddColumnStmt(std::string* tab, std::list<ColumnDef*>* coldefs) : table(tab) {
1257  for (const auto coldef : *coldefs) {
1258  this->coldefs.emplace_back(coldef);
1259  }
1260  delete coldefs;
1261  }
1262  void execute(const Catalog_Namespace::SessionInfo& session) override;
1263  void check_executable(const Catalog_Namespace::SessionInfo& session);
1264  const std::string* get_table() const { return table.get(); }
1265 
1266  private:
1267  std::unique_ptr<std::string> table;
1268  std::unique_ptr<ColumnDef> coldef;
1269  std::list<std::unique_ptr<ColumnDef>> coldefs;
1270 };
1271 
1272 /*
1273  * @type DumpTableStmt
1274  * @brief DUMP TABLE table TO archive_file_path
1275  */
1277  public:
1278  DumpRestoreTableStmtBase(std::string* tab,
1279  std::string* path,
1280  std::list<NameValueAssign*>* options,
1281  const bool is_restore)
1282  : table(tab), path(path) {
1283  auto options_deleter = [](std::list<NameValueAssign*>* options) {
1284  for (auto option : *options) {
1285  delete option;
1286  }
1287  delete options;
1288  };
1289  std::unique_ptr<std::list<NameValueAssign*>, decltype(options_deleter)> options_ptr(
1290  options, options_deleter);
1291  std::vector<std::string> allowed_compression_programs{"lz4", "gzip", "none"};
1292  // specialize decompressor or break on osx bsdtar...
1293  if (options) {
1294  for (const auto option : *options) {
1295  if (boost::iequals(*option->get_name(), "compression")) {
1296  if (const auto str_literal =
1297  dynamic_cast<const StringLiteral*>(option->get_value())) {
1298  compression = *str_literal->get_stringval();
1299  const std::string lowercase_compression =
1300  boost::algorithm::to_lower_copy(compression);
1301  if (allowed_compression_programs.end() ==
1302  std::find(allowed_compression_programs.begin(),
1303  allowed_compression_programs.end(),
1304  lowercase_compression)) {
1305  throw std::runtime_error("Compression program " + compression +
1306  " is not supported.");
1307  }
1308  } else {
1309  throw std::runtime_error("Compression option must be a string.");
1310  }
1311  } else {
1312  throw std::runtime_error("Invalid WITH option: " + *option->get_name());
1313  }
1314  }
1315  }
1316  // default lz4 compression, next gzip, or none.
1317  if (compression.empty()) {
1318  if (boost::process::search_path(compression = "gzip").string().empty()) {
1319  if (boost::process::search_path(compression = "lz4").string().empty()) {
1320  compression = "none";
1321  }
1322  }
1323  }
1324  if (boost::iequals(compression, "none")) {
1325  compression.clear();
1326  } else {
1327  std::map<std::string, std::string> decompression{{"lz4", "unlz4"},
1328  {"gzip", "gunzip"}};
1329  const auto use_program = is_restore ? decompression[compression] : compression;
1330  const auto prog_path = boost::process::search_path(use_program);
1331  if (prog_path.string().empty()) {
1332  throw std::runtime_error("Compression program " + use_program + " is not found.");
1333  }
1334  compression = "--use-compress-program=" + use_program;
1335  }
1336  }
1337  const std::string* getTable() const { return table.get(); }
1338  const std::string* getPath() const { return path.get(); }
1339  const std::string getCompression() const { return compression; }
1340 
1341  protected:
1342  std::unique_ptr<std::string> table;
1343  std::unique_ptr<std::string> path; // dump TO file path
1344  std::string compression;
1345 };
1346 
1348  public:
1349  DumpTableStmt(std::string* tab, std::string* path, std::list<NameValueAssign*>* options)
1350  : DumpRestoreTableStmtBase(tab, path, options, false) {}
1351  void execute(const Catalog_Namespace::SessionInfo& session) override;
1352 };
1353 
1354 /*
1355  * @type RestoreTableStmt
1356  * @brief RESTORE TABLE table FROM archive_file_path
1357  */
1359  public:
1360  RestoreTableStmt(std::string* tab,
1361  std::string* path,
1362  std::list<NameValueAssign*>* options)
1363  : DumpRestoreTableStmtBase(tab, path, options, true) {}
1364  void execute(const Catalog_Namespace::SessionInfo& session) override;
1365 };
1366 
1367 /*
1368  * @type CopyTableStmt
1369  * @brief COPY ... FROM ...
1370  */
1371 class CopyTableStmt : public DDLStmt {
1372  public:
1373  CopyTableStmt(std::string* t, std::string* f, std::list<NameValueAssign*>* o)
1374  : table(t), file_pattern(f) {
1375  if (o) {
1376  for (const auto e : *o) {
1377  options.emplace_back(e);
1378  }
1379  delete o;
1380  }
1381  }
1382  void execute(const Catalog_Namespace::SessionInfo& session) override;
1383  void execute(const Catalog_Namespace::SessionInfo& session,
1384  const std::function<std::unique_ptr<Importer_NS::Importer>(
1386  const TableDescriptor*,
1387  const std::string&,
1388  const Importer_NS::CopyParams&)>& importer_factory);
1389  std::unique_ptr<std::string> return_message;
1390 
1391  std::string& get_table() const {
1392  CHECK(table);
1393  return *table;
1394  }
1395 
1396  bool was_geo_copy_from() const { return _was_geo_copy_from; }
1397 
1398  void get_geo_copy_from_payload(std::string& geo_copy_from_table,
1399  std::string& geo_copy_from_file_name,
1400  Importer_NS::CopyParams& geo_copy_from_copy_params,
1401  std::string& geo_copy_from_partitions) {
1402  geo_copy_from_table = *table;
1403  geo_copy_from_file_name = _geo_copy_from_file_name;
1404  geo_copy_from_copy_params = _geo_copy_from_copy_params;
1405  geo_copy_from_partitions = _geo_copy_from_partitions;
1406  _was_geo_copy_from = false;
1407  }
1408 
1409  private:
1410  std::unique_ptr<std::string> table;
1411  std::unique_ptr<std::string> file_pattern;
1412  std::list<std::unique_ptr<NameValueAssign>> options;
1413 
1414  bool _was_geo_copy_from = false;
1418 };
1419 
1420 /*
1421  * @type CreateRoleStmt
1422  * @brief CREATE ROLE statement
1423  */
1424 class CreateRoleStmt : public DDLStmt {
1425  public:
1426  CreateRoleStmt(std::string* r) : role(r) {}
1427  const std::string& get_role() const { return *role; }
1428  void execute(const Catalog_Namespace::SessionInfo& session) override;
1429 
1430  private:
1431  std::unique_ptr<std::string> role;
1432 };
1433 
1434 /*
1435  * @type DropRoleStmt
1436  * @brief DROP ROLE statement
1437  */
1438 class DropRoleStmt : public DDLStmt {
1439  public:
1440  DropRoleStmt(std::string* r) : role(r) {}
1441  const std::string& get_role() const { return *role; }
1442  void execute(const Catalog_Namespace::SessionInfo& session) override;
1443 
1444  private:
1445  std::unique_ptr<std::string> role;
1446 };
1447 
1448 inline void parser_slistval_to_vector(std::list<std::string*>* l,
1449  std::vector<std::string>& v) {
1450  CHECK(l);
1451  for (auto str : *l) {
1452  v.push_back(*str);
1453  delete str;
1454  }
1455  delete l;
1456 }
1457 
1458 /*
1459  * @type GrantPrivilegesStmt
1460  * @brief GRANT PRIVILEGES statement
1461  */
1463  public:
1464  GrantPrivilegesStmt(std::list<std::string*>* p,
1465  std::string* t,
1466  std::string* o,
1467  std::list<std::string*>* g)
1468  : object_type(t), object(o) {
1471  }
1472 
1473  const std::vector<std::string>& get_privs() const { return privs; }
1474  const std::string& get_object_type() const { return *object_type; }
1475  const std::string& get_object() const { return *object; }
1476  const std::vector<std::string>& get_grantees() const { return grantees; }
1477  void execute(const Catalog_Namespace::SessionInfo& session) override;
1478 
1479  private:
1480  std::vector<std::string> privs;
1481  std::unique_ptr<std::string> object_type;
1482  std::unique_ptr<std::string> object;
1483  std::vector<std::string> grantees;
1484 };
1485 
1486 /*
1487  * @type RevokePrivilegesStmt
1488  * @brief REVOKE PRIVILEGES statement
1489  */
1491  public:
1492  RevokePrivilegesStmt(std::list<std::string*>* p,
1493  std::string* t,
1494  std::string* o,
1495  std::list<std::string*>* g)
1496  : object_type(t), object(o) {
1499  }
1500 
1501  const std::vector<std::string>& get_privs() const { return privs; }
1502  const std::string& get_object_type() const { return *object_type; }
1503  const std::string& get_object() const { return *object; }
1504  const std::vector<std::string>& get_grantees() const { return grantees; }
1505  void execute(const Catalog_Namespace::SessionInfo& session) override;
1506 
1507  private:
1508  std::vector<std::string> privs;
1509  std::unique_ptr<std::string> object_type;
1510  std::unique_ptr<std::string> object;
1511  std::vector<std::string> grantees;
1512 };
1513 
1514 /*
1515  * @type ShowPrivilegesStmt
1516  * @brief SHOW PRIVILEGES statement
1517  */
1518 class ShowPrivilegesStmt : public DDLStmt {
1519  public:
1520  ShowPrivilegesStmt(std::string* t, std::string* o, std::string* r)
1521  : object_type(t), object(o), role(r) {}
1522  const std::string& get_object_type() const { return *object_type; }
1523  const std::string& get_object() const { return *object; }
1524  const std::string& get_role() const { return *role; }
1525  void execute(const Catalog_Namespace::SessionInfo& session) override;
1526 
1527  private:
1528  std::unique_ptr<std::string> object_type;
1529  std::unique_ptr<std::string> object;
1530  std::unique_ptr<std::string> role;
1531 };
1532 
1533 /*
1534  * @type GrantRoleStmt
1535  * @brief GRANT ROLE statement
1536  */
1537 class GrantRoleStmt : public DDLStmt {
1538  public:
1539  GrantRoleStmt(std::list<std::string*>* r, std::list<std::string*>* g) {
1542  }
1543  const std::vector<std::string>& get_roles() const { return roles; }
1544  const std::vector<std::string>& get_grantees() const { return grantees; }
1545  void execute(const Catalog_Namespace::SessionInfo& session) override;
1546 
1547  private:
1548  std::vector<std::string> roles;
1549  std::vector<std::string> grantees;
1550 };
1551 
1552 /*
1553  * @type RevokeRoleStmt
1554  * @brief REVOKE ROLE statement
1555  */
1556 class RevokeRoleStmt : public DDLStmt {
1557  public:
1558  RevokeRoleStmt(std::list<std::string*>* r, std::list<std::string*>* g) {
1561  }
1562  const std::vector<std::string>& get_roles() const { return roles; }
1563  const std::vector<std::string>& get_grantees() const { return grantees; }
1564  void execute(const Catalog_Namespace::SessionInfo& session) override;
1565 
1566  private:
1567  std::vector<std::string> roles;
1568  std::vector<std::string> grantees;
1569 };
1570 
1571 /*
1572  * @type QueryExpr
1573  * @brief query expression
1574  */
1575 class QueryExpr : public Node {
1576  public:
1577  virtual void analyze(const Catalog_Namespace::Catalog& catalog,
1578  Analyzer::Query& query) const = 0;
1579 };
1580 
1581 /*
1582  * @type UnionQuery
1583  * @brief UNION or UNION ALL queries
1584  */
1585 class UnionQuery : public QueryExpr {
1586  public:
1587  UnionQuery(bool u, QueryExpr* l, QueryExpr* r) : is_unionall(u), left(l), right(r) {}
1588  bool get_is_unionall() const { return is_unionall; }
1589  const QueryExpr* get_left() const { return left.get(); }
1590  const QueryExpr* get_right() const { return right.get(); }
1591  void analyze(const Catalog_Namespace::Catalog& catalog,
1592  Analyzer::Query& query) const override;
1593 
1594  private:
1596  std::unique_ptr<QueryExpr> left;
1597  std::unique_ptr<QueryExpr> right;
1598 };
1599 
1600 class SelectEntry : public Node {
1601  public:
1602  SelectEntry(Expr* e, std::string* r) : select_expr(e), alias(r) {}
1603  const Expr* get_select_expr() const { return select_expr.get(); }
1604  const std::string* get_alias() const { return alias.get(); }
1605  std::string to_string() const;
1606 
1607  private:
1608  std::unique_ptr<Expr> select_expr;
1609  std::unique_ptr<std::string> alias;
1610 };
1611 
1612 /*
1613  * @type QuerySpec
1614  * @brief a simple query
1615  */
1616 class QuerySpec : public QueryExpr {
1617  public:
1618  QuerySpec(bool d,
1619  std::list<SelectEntry*>* s,
1620  std::list<TableRef*>* f,
1621  Expr* w,
1622  std::list<Expr*>* g,
1623  Expr* h)
1624  : is_distinct(d), where_clause(w), having_clause(h) {
1625  if (s) {
1626  for (const auto e : *s) {
1627  select_clause.emplace_back(e);
1628  }
1629  delete s;
1630  }
1631  CHECK(f);
1632  for (const auto e : *f) {
1633  from_clause.emplace_back(e);
1634  }
1635  delete f;
1636  if (g) {
1637  for (const auto e : *g) {
1638  groupby_clause.emplace_back(e);
1639  }
1640  delete g;
1641  }
1642  }
1643  bool get_is_distinct() const { return is_distinct; }
1644  const std::list<std::unique_ptr<SelectEntry>>& get_select_clause() const {
1645  return select_clause;
1646  }
1647  const std::list<std::unique_ptr<TableRef>>& get_from_clause() const {
1648  return from_clause;
1649  }
1650  const Expr* get_where_clause() const { return where_clause.get(); }
1651  const std::list<std::unique_ptr<Expr>>& get_groupby_clause() const {
1652  return groupby_clause;
1653  }
1654  const Expr* get_having_clause() const { return having_clause.get(); }
1655  void analyze(const Catalog_Namespace::Catalog& catalog,
1656  Analyzer::Query& query) const override;
1657  std::string to_string() const;
1658 
1659  private:
1661  std::list<std::unique_ptr<SelectEntry>> select_clause; /* nullptr means SELECT * */
1662  std::list<std::unique_ptr<TableRef>> from_clause;
1663  std::unique_ptr<Expr> where_clause;
1664  std::list<std::unique_ptr<Expr>> groupby_clause;
1665  std::unique_ptr<Expr> having_clause;
1666  void analyze_from_clause(const Catalog_Namespace::Catalog& catalog,
1667  Analyzer::Query& query) const;
1669  Analyzer::Query& query) const;
1671  Analyzer::Query& query) const;
1672  void analyze_group_by(const Catalog_Namespace::Catalog& catalog,
1673  Analyzer::Query& query) const;
1675  Analyzer::Query& query) const;
1676 };
1677 
1678 /*
1679  * @type OrderSpec
1680  * @brief order spec for a column in ORDER BY clause
1681  */
1682 class OrderSpec : public Node {
1683  public:
1684  OrderSpec(int n, ColumnRef* c, bool d, bool f)
1685  : colno(n), column(c), is_desc(d), nulls_first(f) {}
1686  int get_colno() const { return colno; }
1687  const ColumnRef* get_column() const { return column.get(); }
1688  bool get_is_desc() const { return is_desc; }
1689  bool get_nulls_first() const { return nulls_first; }
1690 
1691  private:
1692  int colno; /* 0 means use column name */
1693  std::unique_ptr<ColumnRef> column;
1694  bool is_desc;
1696 };
1697 
1698 /*
1699  * @type SelectStmt
1700  * @brief SELECT statement
1701  */
1702 class SelectStmt : public DMLStmt {
1703  public:
1704  SelectStmt(QueryExpr* q, std::list<OrderSpec*>* o, int64_t l, int64_t f)
1705  : query_expr(q), limit(l), offset(f) {
1706  if (o) {
1707  for (const auto e : *o) {
1708  orderby_clause.emplace_back(e);
1709  }
1710  delete o;
1711  }
1712  }
1713  const QueryExpr* get_query_expr() const { return query_expr.get(); }
1714  const std::list<std::unique_ptr<OrderSpec>>& get_orderby_clause() const {
1715  return orderby_clause;
1716  }
1717  void analyze(const Catalog_Namespace::Catalog& catalog,
1718  Analyzer::Query& query) const override;
1719 
1720  private:
1721  std::unique_ptr<QueryExpr> query_expr;
1722  std::list<std::unique_ptr<OrderSpec>> orderby_clause;
1723  int64_t limit;
1724  int64_t offset;
1725 };
1726 
1727 /*
1728  * @type ShowCreateTableStmt
1729  * @brief shows create table statement to create table
1730  */
1732  public:
1733  ShowCreateTableStmt(std::string* tab) : table(tab) {}
1734  std::string get_create_stmt();
1735  void execute(const Catalog_Namespace::SessionInfo& session) override { CHECK(false); }
1736 
1737  private:
1738  std::unique_ptr<std::string> table;
1739 };
1740 
1741 /*
1742  * @type ExportQueryStmt
1743  * @brief COPY ( query ) TO file ...
1744  */
1745 class ExportQueryStmt : public DDLStmt {
1746  public:
1747  ExportQueryStmt(std::string* q, std::string* p, std::list<NameValueAssign*>* o)
1748  : select_stmt(q), file_path(p) {
1749  if (o) {
1750  for (const auto e : *o) {
1751  options.emplace_back(e);
1752  }
1753  delete o;
1754  }
1755  }
1756  void execute(const Catalog_Namespace::SessionInfo& session) override;
1757  const std::string get_select_stmt() const { return *select_stmt; }
1758 
1759  private:
1760  std::unique_ptr<std::string> select_stmt;
1761  std::unique_ptr<std::string> file_path;
1762  std::list<std::unique_ptr<NameValueAssign>> options;
1763 };
1764 
1765 /*
1766  * @type CreateViewStmt
1767  * @brief CREATE VIEW statement
1768  */
1769 class CreateViewStmt : public DDLStmt {
1770  public:
1771  CreateViewStmt(const std::string& view_name,
1772  const std::string& select_query,
1773  const bool if_not_exists)
1774  : view_name_(view_name)
1775  , select_query_(select_query)
1776  , if_not_exists_(if_not_exists) {}
1777  const std::string& get_view_name() const { return view_name_; }
1778  const std::string& get_select_query() const { return select_query_; }
1779  void execute(const Catalog_Namespace::SessionInfo& session) override;
1780 
1781  private:
1782  const std::string view_name_;
1783  const std::string select_query_;
1784  const bool if_not_exists_;
1785 };
1786 
1787 /*
1788  * @type DropViewStmt
1789  * @brief DROP VIEW statement
1790  */
1791 class DropViewStmt : public DDLStmt {
1792  public:
1793  DropViewStmt(std::string* v, bool i) : view_name(v), if_exists(i) {}
1794  const std::string* get_view_name() const { return view_name.get(); }
1795  void execute(const Catalog_Namespace::SessionInfo& session) override;
1796 
1797  private:
1798  std::unique_ptr<std::string> view_name;
1800 };
1801 
1802 /*
1803  * @type CreateDBStmt
1804  * @brief CREATE DATABASE statement
1805  */
1806 class CreateDBStmt : public DDLStmt {
1807  public:
1808  CreateDBStmt(std::string* n, std::list<NameValueAssign*>* l, const bool if_not_exists)
1809  : db_name(n), if_not_exists_(if_not_exists) {
1810  if (l) {
1811  for (const auto e : *l) {
1812  name_value_list.emplace_back(e);
1813  }
1814  delete l;
1815  }
1816  }
1817  void execute(const Catalog_Namespace::SessionInfo& session) override;
1818 
1819  private:
1820  std::unique_ptr<std::string> db_name;
1821  std::list<std::unique_ptr<NameValueAssign>> name_value_list;
1823 };
1824 
1825 /*
1826  * @type DropDBStmt
1827  * @brief DROP DATABASE statement
1828  */
1829 class DropDBStmt : public DDLStmt {
1830  public:
1831  explicit DropDBStmt(std::string* n, bool if_exists)
1832  : db_name(n), if_exists_(if_exists) {}
1833  auto const& getDatabaseName() { return db_name; }
1834  void execute(const Catalog_Namespace::SessionInfo& session) override;
1835 
1836  private:
1837  std::unique_ptr<std::string> db_name;
1839 };
1840 
1841 /*
1842  * @type CreateUserStmt
1843  * @brief CREATE USER statement
1844  */
1845 class CreateUserStmt : public DDLStmt {
1846  public:
1847  CreateUserStmt(std::string* n, std::list<NameValueAssign*>* l) : user_name(n) {
1848  if (l) {
1849  for (const auto e : *l) {
1850  name_value_list.emplace_back(e);
1851  }
1852  delete l;
1853  }
1854  }
1855  void execute(const Catalog_Namespace::SessionInfo& session) override;
1856 
1857  private:
1858  std::unique_ptr<std::string> user_name;
1859  std::list<std::unique_ptr<NameValueAssign>> name_value_list;
1860 };
1861 
1862 /*
1863  * @type AlterUserStmt
1864  * @brief ALTER USER statement
1865  */
1866 class AlterUserStmt : public DDLStmt {
1867  public:
1868  AlterUserStmt(std::string* n, std::list<NameValueAssign*>* l) : user_name(n) {
1869  if (l) {
1870  for (const auto e : *l) {
1871  name_value_list.emplace_back(e);
1872  }
1873  delete l;
1874  }
1875  }
1876  void execute(const Catalog_Namespace::SessionInfo& session) override;
1877 
1878  private:
1879  std::unique_ptr<std::string> user_name;
1880  std::list<std::unique_ptr<NameValueAssign>> name_value_list;
1881 };
1882 
1883 /*
1884  * @type DropUserStmt
1885  * @brief DROP USER statement
1886  */
1887 class DropUserStmt : public DDLStmt {
1888  public:
1889  DropUserStmt(std::string* n) : user_name(n) {}
1890  auto const& getUserName() { return user_name; }
1891  void execute(const Catalog_Namespace::SessionInfo& session) override;
1892 
1893  private:
1894  std::unique_ptr<std::string> user_name;
1895 };
1896 
1897 /*
1898  * @type InsertStmt
1899  * @brief super class for INSERT statements
1900  */
1901 class InsertStmt : public DMLStmt {
1902  public:
1903  InsertStmt(std::string* t, std::list<std::string*>* c) : table(t) {
1904  if (c) {
1905  for (const auto e : *c) {
1906  column_list.emplace_back(e);
1907  }
1908  delete c;
1909  }
1910  }
1911  const std::string* get_table() const { return table.get(); }
1912  const std::list<std::unique_ptr<std::string>>& get_column_list() const {
1913  return column_list;
1914  }
1915  void analyze(const Catalog_Namespace::Catalog& catalog,
1916  Analyzer::Query& query) const override = 0;
1917 
1918  protected:
1919  std::unique_ptr<std::string> table;
1920  std::list<std::unique_ptr<std::string>> column_list;
1921 };
1922 
1923 /*
1924  * @type InsertValuesStmt
1925  * @brief INSERT INTO ... VALUES ...
1926  */
1928  public:
1929  InsertValuesStmt(std::string* t, std::list<std::string*>* c, std::list<Expr*>* v)
1930  : InsertStmt(t, c) {
1931  CHECK(v);
1932  for (const auto e : *v) {
1933  value_list.emplace_back(e);
1934  }
1935  delete v;
1936  }
1937  const std::list<std::unique_ptr<Expr>>& get_value_list() const { return value_list; }
1938  void analyze(const Catalog_Namespace::Catalog& catalog,
1939  Analyzer::Query& query) const override;
1940 
1941  size_t determineLeafIndex(const Catalog_Namespace::Catalog& catalog, size_t num_leafs);
1942 
1943  private:
1944  std::list<std::unique_ptr<Expr>> value_list;
1945 };
1946 
1947 /*
1948  * @type InsertQueryStmt
1949  * @brief INSERT INTO ... SELECT ...
1950  */
1951 class InsertQueryStmt : public InsertStmt {
1952  public:
1953  InsertQueryStmt(std::string* t, std::list<std::string*>* c, QuerySpec* q)
1954  : InsertStmt(t, c), query(q) {}
1955  const QuerySpec* get_query() const { return query.get(); }
1956  void analyze(const Catalog_Namespace::Catalog& catalog,
1957  Analyzer::Query& query) const override;
1958 
1959  private:
1960  std::unique_ptr<QuerySpec> query;
1961 };
1962 
1963 /*
1964  * @type Assignment
1965  * @brief assignment in UPDATE statement
1966  */
1967 class Assignment : public Node {
1968  public:
1969  Assignment(std::string* c, Expr* a) : column(c), assignment(a) {}
1970  const std::string* get_column() const { return column.get(); }
1971  const Expr* get_assignment() const { return assignment.get(); }
1972 
1973  private:
1974  std::unique_ptr<std::string> column;
1975  std::unique_ptr<Expr> assignment;
1976 };
1977 
1978 /*
1979  * @type UpdateStmt
1980  * @brief UPDATE statement
1981  */
1982 class UpdateStmt : public DMLStmt {
1983  public:
1984  UpdateStmt(std::string* t, std::list<Assignment*>* a, Expr* w)
1985  : table(t), where_clause(w) {
1986  CHECK(a);
1987  for (const auto e : *a) {
1988  assignment_list.emplace_back(e);
1989  }
1990  delete a;
1991  }
1992  const std::string* get_table() const { return table.get(); }
1993  const std::list<std::unique_ptr<Assignment>>& get_assignment_list() const {
1994  return assignment_list;
1995  }
1996  const Expr* get_where_clause() const { return where_clause.get(); }
1997  void analyze(const Catalog_Namespace::Catalog& catalog,
1998  Analyzer::Query& query) const override;
1999 
2000  private:
2001  std::unique_ptr<std::string> table;
2002  std::list<std::unique_ptr<Assignment>> assignment_list;
2003  std::unique_ptr<Expr> where_clause;
2004 };
2005 
2006 /*
2007  * @type DeleteStmt
2008  * @brief DELETE statement
2009  */
2010 class DeleteStmt : public DMLStmt {
2011  public:
2012  DeleteStmt(std::string* t, Expr* w) : table(t), where_clause(w) {}
2013  const std::string* get_table() const { return table.get(); }
2014  const Expr* get_where_clause() const { return where_clause.get(); }
2015  void analyze(const Catalog_Namespace::Catalog& catalog,
2016  Analyzer::Query& query) const override;
2017 
2018  private:
2019  std::unique_ptr<std::string> table;
2020  std::unique_ptr<Expr> where_clause;
2021 };
2022 
2023 template <typename LITERAL_TYPE>
2025 
2026 template <>
2028  template <typename T>
2029  decltype(auto) operator()(T t) {
2030  const std::string property_name(boost::to_upper_copy<std::string>(*t->get_name()));
2031  if (!dynamic_cast<const IntLiteral*>(t->get_value())) {
2032  throw std::runtime_error(property_name + " must be an integer literal.");
2033  }
2034  const auto val = static_cast<const IntLiteral*>(t->get_value())->get_intval();
2035  if (val <= 0) {
2036  throw std::runtime_error(property_name + " must be a positive number.");
2037  }
2038  return val;
2039  }
2040 };
2041 
2042 template <>
2044  template <typename T>
2045  decltype(auto) operator()(T t) {
2046  const auto val = static_cast<const StringLiteral*>(t->get_value())->get_stringval();
2047  CHECK(val);
2048  const auto val_upper = boost::to_upper_copy<std::string>(*val);
2049  return val_upper;
2050  }
2051 };
2052 
2053 template <typename T>
2054 struct ShouldInvalidateSessionsByDB : public std::false_type {};
2055 template <typename T>
2056 struct ShouldInvalidateSessionsByUser : public std::false_type {};
2057 
2058 template <>
2059 struct ShouldInvalidateSessionsByDB<DropDBStmt> : public std::true_type {};
2060 template <>
2061 struct ShouldInvalidateSessionsByUser<DropUserStmt> : public std::true_type {};
2062 template <>
2063 struct ShouldInvalidateSessionsByDB<RenameDatabaseStmt> : public std::true_type {};
2064 template <>
2065 struct ShouldInvalidateSessionsByUser<RenameUserStmt> : public std::true_type {};
2066 
2067 } // namespace Parser
2068 
2069 #endif // PARSERNODE_H_
virtual void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const =0
const ColumnConstraintDef * get_column_constraint() const
Definition: ParserNode.h:818
std::list< std::unique_ptr< ColumnDef > > coldefs
Definition: ParserNode.h:1269
virtual void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const =0
OperExpr(SQLOps t, SQLQualifier q, Expr *l, Expr *r)
Definition: ParserNode.h:312
DumpRestoreTableStmtBase(std::string *tab, std::string *path, std::list< NameValueAssign * > *options, const bool is_restore)
Definition: ParserNode.h:1278
ExistsExpr(QuerySpec *q)
Definition: ParserNode.h:596
const std::string foreign_column_
Definition: ParserNode.h:928
std::string & get_table() const
Definition: ParserNode.h:1391
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:83
QuerySpec(bool d, std::list< SelectEntry * > *s, std::list< TableRef * > *f, Expr *w, std::list< Expr * > *g, Expr *h)
Definition: ParserNode.h:1618
std::unique_ptr< std::string > table_name
Definition: ParserNode.h:717
void execute(const Catalog_Namespace::SessionInfo &session) override
void execute(const Catalog_Namespace::SessionInfo &session) override
ValidateStmt(std::string *type, std::list< NameValueAssign * > *with_opts)
Definition: ParserNode.h:1161
std::unique_ptr< std::string > username_
Definition: ParserNode.h:1223
std::unique_ptr< std::string > name
Definition: ParserNode.h:956
std::unique_ptr< std::string > view_name
Definition: ParserNode.h:1798
const Literal * get_value() const
Definition: ParserNode.h:953
LikelihoodExpr(bool n, Expr *a, float l)
Definition: ParserNode.h:571
std::unique_ptr< std::string > role
Definition: ParserNode.h:1445
const std::string & get_column() const
Definition: ParserNode.h:939
const std::string * get_table() const
Definition: ParserNode.h:2013
const Expr * get_arg() const
Definition: ParserNode.h:573
std::list< std::unique_ptr< ExprPair > > when_then_list
Definition: ParserNode.h:700
std::unique_ptr< std::string > table
Definition: ParserNode.h:1919
IntLiteral(int64_t i)
Definition: ParserNode.h:167
bool get_is_desc() const
Definition: ParserNode.h:1688
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:336
RevokePrivilegesStmt(std::list< std::string * > *p, std::string *t, std::string *o, std::list< std::string * > *g)
Definition: ParserNode.h:1492
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
InsertQueryStmt(std::string *t, std::list< std::string * > *c, QuerySpec *q)
Definition: ParserNode.h:1953
GrantPrivilegesStmt(std::list< std::string * > *p, std::string *t, std::string *o, std::list< std::string * > *g)
Definition: ParserNode.h:1464
std::unique_ptr< Expr > select_expr
Definition: ParserNode.h:1608
ExportQueryStmt(std::string *q, std::string *p, std::list< NameValueAssign * > *o)
Definition: ParserNode.h:1747
std::unique_ptr< Expr > where_clause
Definition: ParserNode.h:1663
RestoreTableStmt(std::string *tab, std::string *path, std::list< NameValueAssign * > *options)
Definition: ParserNode.h:1360
std::string to_string() const override
std::unique_ptr< Expr > arg
Definition: ParserNode.h:495
SQLType * get_column_type() const
Definition: ParserNode.h:816
std::unique_ptr< std::string > foreign_column
Definition: ParserNode.h:789
float get_likelihood() const
Definition: ParserNode.h:574
std::list< std::unique_ptr< TableRef > > from_clause
Definition: ParserNode.h:1662
void setColumnDescriptor(ColumnDescriptor &cd, const ColumnDef *coldef)
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string * get_table() const
Definition: ParserNode.h:1911
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< std::string > table
Definition: ParserNode.h:1248
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:81
const std::string getCompression() const
Definition: ParserNode.h:1339
const std::string * get_table() const
Definition: ParserNode.h:616
const std::string * get_column() const
Definition: ParserNode.h:1970
SQLTypes
Definition: sqltypes.h:41
std::unique_ptr< std::string > column
Definition: ParserNode.h:626
void executeDryRun(const Catalog_Namespace::SessionInfo &session, TableDescriptor &td, std::list< ColumnDescriptor > &columns, std::vector< SharedDictionaryDef > &shared_dict_defs)
std::unique_ptr< std::string > user_name
Definition: ParserNode.h:1879
CreateTableStmt(std::string *tab, std::list< TableElement * > *table_elems, bool is_temporary, bool if_not_exists, std::list< NameValueAssign * > *s)
Definition: ParserNode.h:966
std::unique_ptr< SQLType > target_type
Definition: ParserNode.h:666
std::unique_ptr< QuerySpec > query
Definition: ParserNode.h:1960
const Expr * get_arg() const
Definition: ParserNode.h:442
std::unique_ptr< std::string > table
Definition: ParserNode.h:1267
std::unique_ptr< std::string > table
Definition: ParserNode.h:2001
void execute(const Catalog_Namespace::SessionInfo &session) override
std::vector< std::string > roles
Definition: ParserNode.h:1548
void execute(const Catalog_Namespace::SessionInfo &session) override
std::string to_string() const
std::unique_ptr< Expr > arg
Definition: ParserNode.h:368
std::list< std::unique_ptr< TableElement > > table_element_list_
Definition: ParserNode.h:997
CastExpr(Expr *a, SQLType *t)
Definition: ParserNode.h:655
float get_floatval() const
Definition: ParserNode.h:210
std::list< std::unique_ptr< NameValueAssign > > options
Definition: ParserNode.h:1412
std::unique_ptr< Expr > lower
Definition: ParserNode.h:454
DropViewStmt(std::string *v, bool i)
Definition: ParserNode.h:1793
FixedPtLiteral(std::string *n)
Definition: ParserNode.h:188
SQLType(SQLTypes t, int p1)
Definition: ParserNode.h:74
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1155
const std::string getType() const
Definition: ParserNode.h:1191
SQLQualifier
Definition: sqldefs.h:69
const std::string & get_role() const
Definition: ParserNode.h:1441
static std::shared_ptr< Analyzer::Expr > analyzeValue(const int64_t intval)
Definition: ParserNode.cpp:112
auto const & getPreviousDatabaseName()
Definition: ParserNode.h:1205
std::unique_ptr< QuerySpec > query
Definition: ParserNode.h:353
const Expr * get_pattern_string() const
Definition: ParserNode.h:543
const std::string column_
Definition: ParserNode.h:926
std::string to_string() const
std::unique_ptr< std::string > alias
Definition: ParserNode.h:1609
std::unique_ptr< std::string > return_message
Definition: ParserNode.h:1389
StringLiteral(std::string *s)
Definition: ParserNode.h:148
void populateData(QueryStateProxy, bool is_temporary, bool validate_table)
const Expr * get_select_expr() const
Definition: ParserNode.h:1603
DoubleLiteral(double d)
Definition: ParserNode.h:229
SQLOps
Definition: sqldefs.h:29
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
Definition: ParserNode.cpp:993
const std::string getTableName() const
Definition: ParserNode.h:1138
InsertStmt(std::string *t, std::list< std::string * > *c)
Definition: ParserNode.h:1903
std::string to_string() const override
const std::string * get_prev_table() const
Definition: ParserNode.h:1232
std::string to_string() const override
Definition: ParserNode.h:660
std::string to_string() const override
auto const & getNewDatabaseName()
Definition: ParserNode.h:1206
std::vector< std::string > grantees
Definition: ParserNode.h:1511
InsertValuesStmt(std::string *t, std::list< std::string * > *c, std::list< Expr * > *v)
Definition: ParserNode.h:1929
const std::string * get_table() const
Definition: ParserNode.h:984
void get_geo_copy_from_payload(std::string &geo_copy_from_table, std::string &geo_copy_from_file_name, Importer_NS::CopyParams &geo_copy_from_copy_params, std::string &geo_copy_from_partitions)
Definition: ParserNode.h:1398
const Expr * get_check_condition() const
Definition: ParserNode.h:778
UpdateStmt(std::string *t, std::list< Assignment * > *a, Expr *w)
Definition: ParserNode.h:1984
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:187
std::unique_ptr< Expr > arg
Definition: ParserNode.h:475
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:863
std::unique_ptr< std::string > object
Definition: ParserNode.h:1529
std::unique_ptr< Expr > check_condition
Definition: ParserNode.h:787
std::unique_ptr< std::string > table
Definition: ParserNode.h:625
const std::string * get_table() const
Definition: ParserNode.h:1102
std::string to_string() const override
Definition: ParserNode.h:197
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:857
void execute(const Catalog_Namespace::SessionInfo &session) override
bool get_is_not() const
Definition: ParserNode.h:506
std::unique_ptr< std::string > path
Definition: ParserNode.h:1343
#define UNREACHABLE()
Definition: Logger.h:234
const std::list< std::unique_ptr< OrderSpec > > & get_orderby_clause() const
Definition: ParserNode.h:1714
AddColumnStmt(std::string *tab, std::list< ColumnDef * > *coldefs)
Definition: ParserNode.h:1256
std::string to_string() const override=0
const std::list< std::unique_ptr< std::string > > & get_foreign_column_list() const
Definition: ParserNode.h:884
std::unique_ptr< std::string > object
Definition: ParserNode.h:1482
std::unique_ptr< std::string > new_username_
Definition: ParserNode.h:1224
DropDBStmt(std::string *n, bool if_exists)
Definition: ParserNode.h:1831
void execute(const Catalog_Namespace::SessionInfo &session) override
Definition: ParserNode.h:1735
const std::string & get_foreign_table() const
Definition: ParserNode.h:921
std::unique_ptr< Expr > where_clause
Definition: ParserNode.h:2020
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:166
std::unique_ptr< std::string > user_name
Definition: ParserNode.h:1858
SQLOps get_optype() const
Definition: ParserNode.h:314
Expr * get_arg() const
Definition: ParserNode.h:640
std::unique_ptr< Expr > assignment
Definition: ParserNode.h:1975
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:179
std::unique_ptr< std::string > table
Definition: ParserNode.h:1410
virtual void checkpoint(const Catalog_Namespace::SessionInfo &parent_session_info, int tableId)=0
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override=0
std::string to_string() const override
const std::string * get_new_table() const
Definition: ParserNode.h:1233
DropRoleStmt(std::string *r)
Definition: ParserNode.h:1440
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1448
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:157
OptimizeTableStmt(std::string *table, std::list< NameValueAssign * > *o)
Definition: ParserNode.h:1126
const Literal * get_defaultval() const
Definition: ParserNode.h:777
std::string to_string() const
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override=0
const Expr * get_arg() const
Definition: ParserNode.h:542
void execute(const Catalog_Namespace::SessionInfo &session) override
CaseExpr(std::list< ExprPair * > *w, Expr *e)
Definition: ParserNode.h:682
ShardKeyDef(const std::string &column)
Definition: ParserNode.h:937
CreateDBStmt(std::string *n, std::list< NameValueAssign * > *l, const bool if_not_exists)
Definition: ParserNode.h:1808
std::unique_ptr< Literal > defaultval
Definition: ParserNode.h:786
static void check_pattern_expr(const std::string &pattern_str, char escape_char)
Definition: ParserNode.cpp:576
std::unique_ptr< std::string > table
Definition: ParserNode.h:1106
const Expr * get_where_clause() const
Definition: ParserNode.h:1996
std::unique_ptr< std::string > new_column_name
Definition: ParserNode.h:1250
const std::vector< std::string > & get_roles() const
Definition: ParserNode.h:1543
std::string to_string() const override
bool get_is_unionall() const
Definition: ParserNode.h:1588
std::unique_ptr< ColumnConstraintDef > column_constraint
Definition: ParserNode.h:826
size_t determineLeafIndex(const Catalog_Namespace::Catalog &catalog, size_t num_leafs)
SQLType(SQLTypes t, int p1, int p2, bool a)
Definition: ParserNode.h:76
std::unique_ptr< Expr > arg
Definition: ParserNode.h:557
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1528
const std::string & get_column() const
Definition: ParserNode.h:919
TableRef(std::string *t, std::string *r)
Definition: ParserNode.h:711
const std::string * get_table() const
Definition: ParserNode.h:1992
std::unique_ptr< Expr > arg
Definition: ParserNode.h:453
std::unique_ptr< std::string > table
Definition: ParserNode.h:1738
const Expr * get_arg() const
Definition: ParserNode.h:487
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1509
const Expr * get_arg() const
Definition: ParserNode.h:507
std::unique_ptr< Expr > arg
Definition: ParserNode.h:388
static bool translate_to_like_pattern(std::string &pattern_str, char escape_char)
Definition: ParserNode.cpp:582
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::list< std::unique_ptr< Expr > > & get_value_list() const
Definition: ParserNode.h:422
ColumnConstraintDef(bool n, bool u, bool p, Literal *d)
Definition: ParserNode.h:764
bool get_is_not() const
Definition: ParserNode.h:378
std::unique_ptr< std::string > file_path
Definition: ParserNode.h:1761
ColumnRef(std::string *n1, std::string *n2)
Definition: ParserNode.h:615
SelectStmt(QueryExpr *q, std::list< OrderSpec * > *o, int64_t l, int64_t f)
Definition: ParserNode.h:1704
void execute(const Catalog_Namespace::SessionInfo &session) override
SQLType(SQLTypes t)
Definition: ParserNode.h:72
std::unique_ptr< std::string > column
Definition: ParserNode.h:1974
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string & get_object_type() const
Definition: ParserNode.h:1474
const Expr * get_escape_string() const
Definition: ParserNode.h:509
void insertDataToLeaf(const Catalog_Namespace::SessionInfo &session, const size_t leaf_idx, Fragmenter_Namespace::InsertData &insert_data) override
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1820
IsNullExpr(bool n, Expr *a)
Definition: ParserNode.h:358
const std::string & get_object() const
Definition: ParserNode.h:1523
std::vector< std::string > roles
Definition: ParserNode.h:1567
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:430
std::vector< std::string > privs
Definition: ParserNode.h:1508
void execute(const Catalog_Namespace::SessionInfo &session) override
static std::shared_ptr< Analyzer::Expr > normalize(const std::list< std::pair< std::shared_ptr< Analyzer::Expr >, std::shared_ptr< Analyzer::Expr >>> &, const std::shared_ptr< Analyzer::Expr >)
Definition: ParserNode.cpp:905
void analyze_having_clause(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
std::string to_string() const override
const Expr * get_like_string() const
Definition: ParserNode.h:508
const std::string get_select_stmt() const
Definition: ParserNode.h:1757
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1504
void execute(const Catalog_Namespace::SessionInfo &session) override
const Expr * get_arg() const
Definition: ParserNode.h:379
std::string to_string() const override
Definition: ParserNode.h:155
const std::string & get_role() const
Definition: ParserNode.h:1524
bool get_calc_encoded_length() const
Definition: ParserNode.h:467
std::unique_ptr< std::string > table
Definition: ParserNode.h:1342
bool get_is_array() const
Definition: ParserNode.h:81
const SubqueryExpr * get_subquery() const
Definition: ParserNode.h:398
const std::list< std::unique_ptr< SelectEntry > > & get_select_clause() const
Definition: ParserNode.h:1644
const std::string * getPath() const
Definition: ParserNode.h:1338
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:90
std::list< std::unique_ptr< std::string > > foreign_column_list
Definition: ParserNode.h:891
std::string to_string() const override
Definition: ParserNode.h:276
const std::string * getTable() const
Definition: ParserNode.h:1337
bool was_geo_copy_from() const
Definition: ParserNode.h:1396
InSubquery(bool n, Expr *a, SubqueryExpr *q)
Definition: ParserNode.h:397
CreateRoleStmt(std::string *r)
Definition: ParserNode.h:1426
const std::string * get_table_name() const
Definition: ParserNode.h:712
std::unique_ptr< Expr > expr2
Definition: ParserNode.h:677
const ColumnRef * get_column() const
Definition: ParserNode.h:1687
std::unique_ptr< Expr > arg
Definition: ParserNode.h:650
const Expr * get_right() const
Definition: ParserNode.h:316
const std::string * get_stringval() const
Definition: ParserNode.h:149
std::list< std::unique_ptr< SelectEntry > > select_clause
Definition: ParserNode.h:1661
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:696
CHECK(cgen_state)
Importer_NS::CopyParams _geo_copy_from_copy_params
Definition: ParserNode.h:1416
std::list< std::unique_ptr< NameValueAssign > > name_value_list
Definition: ParserNode.h:1821
Definition: ParserNode.h:1600
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:301
std::string to_string() const override
Definition: ParserNode.h:255
ExprPair(Expr *e1, Expr *e2)
Definition: ParserNode.h:671
const std::string * get_fixedptval() const
Definition: ParserNode.h:189
const std::list< std::unique_ptr< Expr > > & get_value_list() const
Definition: ParserNode.h:1937
const std::string & get_role() const
Definition: ParserNode.h:1427
std::list< std::unique_ptr< NameValueAssign > > storage_options_
Definition: ParserNode.h:1092
bool get_is_not() const
Definition: ParserNode.h:541
std::unique_ptr< ColumnRef > column
Definition: ParserNode.h:1693
ForeignKeyDef(std::list< std::string * > *cl, std::string *t, std::list< std::string * > *fcl)
Definition: ParserNode.h:866
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1563
std::unique_ptr< Expr > where_clause
Definition: ParserNode.h:2003
std::unique_ptr< std::string > type_
Definition: ParserNode.h:1196
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:105
std::unique_ptr< std::string > foreign_table
Definition: ParserNode.h:890
std::vector< std::string > grantees
Definition: ParserNode.h:1483
virtual AggregatedResult query(QueryStateProxy, std::string &sql_query_string)=0
std::unique_ptr< SQLType > column_type
Definition: ParserNode.h:824
const std::string * get_encoding_name() const
Definition: ParserNode.h:799
const std::list< std::unique_ptr< std::string > > & get_column_list() const
Definition: ParserNode.h:1912
std::unique_ptr< Expr > expr1
Definition: ParserNode.h:676
const std::list< std::unique_ptr< Expr > > & get_value_list() const
Definition: ParserNode.h:293
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
std::list< std::unique_ptr< NameValueAssign > > name_value_list
Definition: ParserNode.h:1880
SharedDictionaryDef(const std::string &column, const std::string &foreign_table, const std::string foreign_column)
Definition: ParserNode.h:914
std::unique_ptr< Expr > right
Definition: ParserNode.h:332
const Expr * get_check_condition() const
Definition: ParserNode.h:901
const QueryExpr * get_left() const
Definition: ParserNode.h:1589
const std::string & get_foreign_column() const
Definition: ParserNode.h:923
std::list< ColumnDescriptor > getColumnDescriptors(AggregatedResult &result, bool for_create)
void analyze_where_clause(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
void execute(const Catalog_Namespace::SessionInfo &session) override
void set_is_array(bool a)
Definition: ParserNode.h:82
void check_executable(const Catalog_Namespace::SessionInfo &session)
const std::string * get_table() const
Definition: ParserNode.h:1117
auto const & getUserName()
Definition: ParserNode.h:1890
int64_t get_intval() const
Definition: ParserNode.h:168
void execute(const Catalog_Namespace::SessionInfo &session) override
const Expr * get_upper() const
Definition: ParserNode.h:444
std::unique_ptr< std::string > role
Definition: ParserNode.h:1431
const std::list< std::unique_ptr< std::string > > & get_column_list() const
Definition: ParserNode.h:851
const Expr * get_where_clause() const
Definition: ParserNode.h:2014
ColumnDef(std::string *c, SQLType *t, CompressDef *cp, ColumnConstraintDef *cc)
Definition: ParserNode.h:813
void execute(const Catalog_Namespace::SessionInfo &session) override
RevokeRoleStmt(std::list< std::string * > *r, std::list< std::string * > *g)
Definition: ParserNode.h:1558
const int32_t groups_buffer_size return nullptr
void execute(const Catalog_Namespace::SessionInfo &session) override
std::string _geo_copy_from_partitions
Definition: ParserNode.h:1417
const std::string * get_column_name() const
Definition: ParserNode.h:815
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string & get_select_query() const
Definition: ParserNode.h:1778
std::unique_ptr< std::string > table
Definition: ParserNode.h:2019
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:1920
const Expr * get_having_clause() const
Definition: ParserNode.h:1654
std::string to_string() const override
static std::shared_ptr< Analyzer::Expr > analyzeValue(const std::string &)
Definition: ParserNode.cpp:97
FunctionRef(std::string *n, Expr *a)
Definition: ParserNode.h:636
DropUserStmt(std::string *n)
Definition: ParserNode.h:1889
std::unique_ptr< QueryExpr > right
Definition: ParserNode.h:1597
std::unique_ptr< Expr > escape_string
Definition: ParserNode.h:526
CreateTableAsSelectStmt(const std::string *table_name, const std::string *select_query, const bool is_temporary, const bool if_not_exists, std::list< NameValueAssign * > *s)
Definition: ParserNode.h:1071
specifies the content in-memory of a row in the column metadata table
const Expr * get_where_clause() const
Definition: ParserNode.h:1650
const std::string * get_alias() const
Definition: ParserNode.h:1604
void execute(const Catalog_Namespace::SessionInfo &session) override
CheckDef(Expr *c)
Definition: ParserNode.h:900
BetweenExpr(bool n, Expr *a, Expr *l, Expr *u)
Definition: ParserNode.h:439
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:1156
std::string to_string() const override
Definition: ParserNode.h:215
const std::vector< std::string > & get_roles() const
Definition: ParserNode.h:1562
const std::string foreign_table_
Definition: ParserNode.h:927
bool g_enable_smem_group_by true
static void erase_cntl_chars(std::string &like_str, char escape_char)
Definition: ParserNode.cpp:499
const std::string * get_name() const
Definition: ParserNode.h:638
std::string to_string() const
AddColumnStmt(std::string *tab, ColumnDef *coldef)
Definition: ParserNode.h:1255
bool get_is_primarykey() const
Definition: ParserNode.h:850
const std::string select_query_
Definition: ParserNode.h:1783
std::unique_ptr< Expr > pattern_string
Definition: ParserNode.h:558
virtual void execute(const Catalog_Namespace::SessionInfo &session)=0
void execute(const Catalog_Namespace::SessionInfo &session) override
static std::shared_ptr< Analyzer::Expr > normalize(const SQLOps optype, const SQLQualifier qual, std::shared_ptr< Analyzer::Expr > left_expr, std::shared_ptr< Analyzer::Expr > right_expr)
Definition: ParserNode.cpp:261
int get_colno() const
Definition: ParserNode.h:1686
void execute(const Catalog_Namespace::SessionInfo &session) override
std::string to_string() const override
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1210
TruncateTableStmt(std::string *tab)
Definition: ParserNode.h:1116
const std::list< std::unique_ptr< TableElement > > & get_table_element_list() const
Definition: ParserNode.h:985
std::unique_ptr< std::string > new_table_name
Definition: ParserNode.h:1238
std::unique_ptr< std::string > user_name
Definition: ParserNode.h:1894
GrantRoleStmt(std::list< std::string * > *r, std::list< std::string * > *g)
Definition: ParserNode.h:1539
const std::list< std::unique_ptr< Expr > > & get_groupby_clause() const
Definition: ParserNode.h:1651
UnionQuery(bool u, QueryExpr *l, QueryExpr *r)
Definition: ParserNode.h:1587
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
const std::string * get_name() const
Definition: ParserNode.h:952
SQLQualifier opqualifier
Definition: ParserNode.h:330
std::list< std::unique_ptr< Expr > > groupby_clause
Definition: ParserNode.h:1664
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
std::unique_ptr< Expr > left
Definition: ParserNode.h:331
virtual ~Node()
Definition: ParserNode.h:63
void execute(const Catalog_Namespace::SessionInfo &session) override
void execute(const Catalog_Namespace::SessionInfo &session) override
Definition: ParserNode.h:1193
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:688
std::unique_ptr< Expr > arg
Definition: ParserNode.h:586
const std::string * get_range_var() const
Definition: ParserNode.h:713
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:235
void set_array_size(int s)
Definition: ParserNode.h:84
std::unique_ptr< std::string > column_name
Definition: ParserNode.h:823
bool get_distinct() const
Definition: ParserNode.h:639
Definition: sqldefs.h:69
const bool if_not_exists_
Definition: ParserNode.h:1784
std::string to_string() const override
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1476
RenameDatabaseStmt(std::string *database_name, std::string *new_database_name)
Definition: ParserNode.h:1202
const CompressDef * get_compression() const
Definition: ParserNode.h:817
CreateUserStmt(std::string *n, std::list< NameValueAssign * > *l)
Definition: ParserNode.h:1847
std::string to_string() const override
Definition: ParserNode.cpp:220
std::unique_ptr< Literal > value
Definition: ParserNode.h:957
std::list< std::unique_ptr< Assignment > > assignment_list
Definition: ParserNode.h:2002
const Expr * get_lower() const
Definition: ParserNode.h:443
std::unique_ptr< QueryExpr > left
Definition: ParserNode.h:1596
std::unique_ptr< std::string > column
Definition: ParserNode.h:1249
void execute(const Catalog_Namespace::SessionInfo &session) override
bool get_is_not() const
Definition: ParserNode.h:441
ArrayLiteral(std::list< Expr * > *v)
Definition: ParserNode.h:286
InExpr(bool n, Expr *a)
Definition: ParserNode.h:377
const std::list< std::unique_ptr< std::string > > & get_column_list() const
Definition: ParserNode.h:880
std::unique_ptr< QueryExpr > query_expr
Definition: ParserNode.h:1721
const std::string view_name_
Definition: ParserNode.h:1782
bool isRepairTypeRemove() const
Definition: ParserNode.h:1189
DropTableStmt(std::string *tab, bool i)
Definition: ParserNode.h:1101
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override=0
std::unique_ptr< Expr > like_string
Definition: ParserNode.h:525
CompressDef(std::string *n, int p)
Definition: ParserNode.h:798
std::list< std::unique_ptr< NameValueAssign > > options
Definition: ParserNode.h:1762
std::unique_ptr< std::string > range_var
Definition: ParserNode.h:718
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:613
InsertIntoTableAsSelectStmt(const std::string *table_name, const std::string *select_query, std::list< std::string * > *c)
Definition: ParserNode.h:1010
InValues(bool n, Expr *a, std::list< Expr * > *v)
Definition: ParserNode.h:415
const std::string * get_foreign_table() const
Definition: ParserNode.h:883
std::string to_string() const override
Definition: ParserNode.h:174
NameValueAssign(std::string *n, Literal *v)
Definition: ParserNode.h:951
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:770
std::list< std::unique_ptr< NameValueAssign > > storage_options_
Definition: ParserNode.h:1000
const std::string column_
Definition: ParserNode.h:942
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:846
std::unique_ptr< std::string > encoding_name
Definition: ParserNode.h:803
std::unique_ptr< std::string > object
Definition: ParserNode.h:1510
void rollback(const Catalog_Namespace::SessionInfo &session, int tableId) override
CharLengthExpr(Expr *a, bool e)
Definition: ParserNode.h:465
void execute(const Catalog_Namespace::SessionInfo &session) override
std::string to_string() const override
AggregatedResult query(QueryStateProxy, std::string &sql_query_string, bool validate_only)
static std::shared_ptr< Analyzer::Expr > analyzeValue(const int64_t numericval, const int scale, const int precision)
Definition: ParserNode.cpp:137
auto const & getNewUserName()
Definition: ParserNode.h:1219
std::string to_string() const override
void analyze_select_clause(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
static bool test_is_simple_expr(const std::string &like_str, char escape_char)
Definition: ParserNode.cpp:478
CreateViewStmt(const std::string &view_name, const std::string &select_query, const bool if_not_exists)
Definition: ParserNode.h:1771
const std::string * get_foreign_table() const
Definition: ParserNode.h:779
virtual std::string to_string() const =0
int get_param1() const
Definition: ParserNode.h:79
std::vector< std::string > privs
Definition: ParserNode.h:1480
void analyze_from_clause(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
int get_array_size() const
Definition: ParserNode.h:83
bool get_nulls_first() const
Definition: ParserNode.h:1689
std::vector< std::unique_ptr< std::string > > column_list_
Definition: ParserNode.h:1060
bool shouldVacuumDeletedRows() const
Definition: ParserNode.h:1140
TableRef(std::string *t)
Definition: ParserNode.h:710
void execute(const Catalog_Namespace::SessionInfo &session) override
bool get_is_not() const
Definition: ParserNode.h:359
DistributedConnector * leafs_connector_
Definition: ParserNode.h:1057
std::unique_ptr< QuerySpec > query
Definition: ParserNode.h:605
RenameUserStmt(std::string *username, std::string *new_username)
Definition: ParserNode.h:1216
std::string to_string() const override
std::unique_ptr< ColumnDef > coldef
Definition: ParserNode.h:1268
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:668
std::string to_string() const override
std::unique_ptr< std::string > name
Definition: ParserNode.h:648
std::unique_ptr< std::string > fixedptval
Definition: ParserNode.h:200
bool get_is_primarykey() const
Definition: ParserNode.h:776
virtual std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const =0
std::unique_ptr< std::string > role
Definition: ParserNode.h:1530
std::unique_ptr< std::string > file_pattern
Definition: ParserNode.h:1411
std::unique_ptr< Expr > arg
Definition: ParserNode.h:665
bool g_enable_watchdog false
Definition: Execute.cpp:71
SQLTypes type
Definition: ParserNode.h:89
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:356
std::list< std::unique_ptr< std::string > > column_list
Definition: ParserNode.h:889
Assignment(std::string *c, Expr *a)
Definition: ParserNode.h:1969
const QuerySpec * get_query() const
Definition: ParserNode.h:1955
const std::vector< std::string > & get_privs() const
Definition: ParserNode.h:1473
SQLTypes get_type() const
Definition: ParserNode.h:78
CopyTableStmt(std::string *t, std::string *f, std::list< NameValueAssign * > *o)
Definition: ParserNode.h:1373
ShowCreateTableStmt(std::string *tab)
Definition: ParserNode.h:1733
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:148
bool get_is_distinct() const
Definition: ParserNode.h:1643
std::string to_string() const override
Definition: ParserNode.h:235
const std::string & get_object_type() const
Definition: ParserNode.h:1522
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:364
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1544
ColumnConstraintDef(std::string *t, std::string *c)
Definition: ParserNode.h:768
SubqueryExpr(QuerySpec *q)
Definition: ParserNode.h:344
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:444
bool get_is_not() const
Definition: ParserNode.h:572
std::string to_string() const override
Definition: ParserNode.h:139
const std::string * get_foreign_column() const
Definition: ParserNode.h:780
std::string to_string() const override
The data to be inserted using the fragment manager.
Definition: Fragmenter.h:59
const Expr * get_left() const
Definition: ParserNode.h:315
std::unique_ptr< std::string > stringval
Definition: ParserNode.h:158
std::unique_ptr< std::string > table
Definition: ParserNode.h:1121
const std::vector< std::string > & get_privs() const
Definition: ParserNode.h:1501
void analyze_group_by(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:1944
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1481
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
const Expr * get_expr2() const
Definition: ParserNode.h:673
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:518
const std::string * get_view_name() const
Definition: ParserNode.h:1794
const QuerySpec * get_query() const
Definition: ParserNode.h:597
auto const & getOldUserName()
Definition: ParserNode.h:1218
const std::string & get_object() const
Definition: ParserNode.h:1503
std::unique_ptr< Expr > having_clause
Definition: ParserNode.h:1665
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1837
specifies the content in-memory of a row in the table metadata table
ColumnRef(std::string *n1)
Definition: ParserNode.h:614
std::string to_string() const override
Definition: ParserNode.cpp:980
const QuerySpec * get_query() const
Definition: ParserNode.h:345
const std::string & get_view_name() const
Definition: ParserNode.h:1777
LikeExpr(bool n, bool i, Expr *a, Expr *l, Expr *e)
Definition: ParserNode.h:504
std::unique_ptr< SubqueryExpr > subquery
Definition: ParserNode.h:406
virtual void rollback(const Catalog_Namespace::SessionInfo &parent_session_info, int tableId)=0
std::unique_ptr< Expr > else_expr
Definition: ParserNode.h:701
void checkpoint(const Catalog_Namespace::SessionInfo &session, int tableId) override
const Expr * get_escape_string() const
Definition: ParserNode.h:544
std::unique_ptr< Expr > upper
Definition: ParserNode.h:455
FunctionRef(std::string *n)
Definition: ParserNode.h:635
int get_encoding_param() const
Definition: ParserNode.h:800
std::unique_ptr< CompressDef > compression
Definition: ParserNode.h:825
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:128
std::string _geo_copy_from_file_name
Definition: ParserNode.h:1415
std::unique_ptr< Expr > escape_string
Definition: ParserNode.h:559
OperExpr(SQLOps t, Expr *l, Expr *r)
Definition: ParserNode.h:310
std::unique_ptr< std::string > foreign_table
Definition: ParserNode.h:788
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:344
const QueryExpr * get_query_expr() const
Definition: ParserNode.h:1713
RenameColumnStmt(std::string *tab, std::string *col, std::string *new_col_name)
Definition: ParserNode.h:1243
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:406
const std::list< std::unique_ptr< Assignment > > & get_assignment_list() const
Definition: ParserNode.h:1993
std::vector< std::string > grantees
Definition: ParserNode.h:1549
FunctionRef(std::string *n, bool d, Expr *a)
Definition: ParserNode.h:637
AlterUserStmt(std::string *n, std::list< NameValueAssign * > *l)
Definition: ParserNode.h:1868
std::unique_ptr< std::string > select_stmt
Definition: ParserNode.h:1760
std::unique_ptr< std::string > table_
Definition: ParserNode.h:996
void execute(const Catalog_Namespace::SessionInfo &session) override
Definition: ParserNode.h:1149
std::list< std::unique_ptr< NameValueAssign > > name_value_list
Definition: ParserNode.h:1859
std::vector< std::string > grantees
Definition: ParserNode.h:1568
const Expr * get_arg() const
Definition: ParserNode.h:466
OrderSpec(int n, ColumnRef *c, bool d, bool f)
Definition: ParserNode.h:1684
void execute(const Catalog_Namespace::SessionInfo &session) override
double get_doubleval() const
Definition: ParserNode.h:230
RegexpExpr(bool n, Expr *a, Expr *p, Expr *e)
Definition: ParserNode.h:539
const std::string & get_object_type() const
Definition: ParserNode.h:1502
std::unique_ptr< std::string > table
Definition: ParserNode.h:1237
ShowPrivilegesStmt(std::string *t, std::string *o, std::string *r)
Definition: ParserNode.h:1520
UniqueDef(bool p, std::list< std::string * > *cl)
Definition: ParserNode.h:843
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string * get_table() const
Definition: ParserNode.h:1264
SelectEntry(Expr *e, std::string *r)
Definition: ParserNode.h:1602
const QueryExpr * get_right() const
Definition: ParserNode.h:1590
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
std::string to_string() const override
const Expr * get_expr1() const
Definition: ParserNode.h:672
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
Definition: ParserNode.cpp:458
const std::string & get_object() const
Definition: ParserNode.h:1475
std::unique_ptr< Expr > arg
Definition: ParserNode.h:524
const std::string * get_column() const
Definition: ParserNode.h:617
void execute(const Catalog_Namespace::SessionInfo &session) override
std::list< std::unique_ptr< OrderSpec > > orderby_clause
Definition: ParserNode.h:1722
int get_param2() const
Definition: ParserNode.h:80
static void check_like_expr(const std::string &like_str, char escape_char)
Definition: ParserNode.cpp:472
std::unique_ptr< Expr > check_condition
Definition: ParserNode.h:904
DumpTableStmt(std::string *tab, std::string *path, std::list< NameValueAssign * > *options)
Definition: ParserNode.h:1349
RenameTableStmt(std::string *tab, std::string *new_tab_name)
Definition: ParserNode.h:1229
const std::list< std::unique_ptr< TableRef > > & get_from_clause() const
Definition: ParserNode.h:1647
auto const & getDatabaseName()
Definition: ParserNode.h:1833
DeleteStmt(std::string *t, Expr *w)
Definition: ParserNode.h:2012
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1211
const Expr * get_assignment() const
Definition: ParserNode.h:1971