OmniSciDB  085a039ca4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 #include "Utils/DdlUtils.h"
42 
43 #include "../Fragmenter/InsertDataLoader.h"
44 
45 #include <ImportExport/Importer.h>
47 
48 #include <functional>
49 
50 namespace query_state {
51 class QueryState;
52 class QueryStateProxy;
53 } // namespace query_state
55 
56 namespace Parser {
57 
58 /*
59  * @type Node
60  * @brief root super class for all nodes in a pre-Analyzer
61  * parse tree.
62  */
63 class Node {
64  public:
65  virtual ~Node() {}
66 };
67 
68 /*
69  * @type SQLType
70  * @brief class that captures type, predication and scale.
71  */
72 class SQLType : public Node, public ddl_utils::SqlType {
73  public:
74  explicit SQLType(SQLTypes t) : ddl_utils::SqlType(t, -1, 0, false, -1) {}
75  SQLType(SQLTypes t, int p1) : ddl_utils::SqlType(t, p1, 0, false, -1) {}
76  SQLType(SQLTypes t, int p1, int p2, bool a) : ddl_utils::SqlType(t, p1, p2, a, -1) {}
77  SQLType(SQLTypes t, int p1, int p2, bool a, int array_size)
78  : ddl_utils::SqlType(t, p1, p2, a, array_size) {}
79  SQLType(SQLTypes t, bool a, int array_size)
80  : ddl_utils::SqlType(t, -1, 0, a, array_size) {}
81 };
82 
83 /*
84  * @type Expr
85  * @brief root super class for all expression nodes
86  */
87 class Expr : public Node {
88  public:
90  /*
91  * @brief Performs semantic analysis on the expression node
92  * @param catalog The catalog object for the current database
93  * @return An Analyzer::Expr object for the expression post semantic analysis
94  */
95  virtual std::shared_ptr<Analyzer::Expr> analyze(
96  const Catalog_Namespace::Catalog& catalog,
97  Analyzer::Query& query,
98  TlistRefType allow_tlist_ref = TLIST_NONE) const = 0;
99  virtual std::string to_string() const = 0;
100 };
101 
102 /*
103  * @type Literal
104  * @brief root super class for all literals
105  */
106 class Literal : public Expr {
107  public:
108  std::shared_ptr<Analyzer::Expr> analyze(
109  const Catalog_Namespace::Catalog& catalog,
110  Analyzer::Query& query,
111  TlistRefType allow_tlist_ref = TLIST_NONE) const override = 0;
112  std::string to_string() const override = 0;
113 };
114 
115 /*
116  * @type NullLiteral
117  * @brief the Literal NULL
118  */
119 class NullLiteral : public Literal {
120  public:
122  std::shared_ptr<Analyzer::Expr> analyze(
123  const Catalog_Namespace::Catalog& catalog,
124  Analyzer::Query& query,
125  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
126  std::string to_string() const override { return "NULL"; }
127 };
128 
129 /*
130  * @type StringLiteral
131  * @brief the literal for string constants
132  */
133 class StringLiteral : public Literal {
134  public:
135  explicit StringLiteral(std::string* s) : stringval_(s) {}
136  const std::string* get_stringval() const { return stringval_.get(); }
137  std::shared_ptr<Analyzer::Expr> analyze(
138  const Catalog_Namespace::Catalog& catalog,
139  Analyzer::Query& query,
140  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
141  static std::shared_ptr<Analyzer::Expr> analyzeValue(const std::string& stringval,
142  const bool is_null);
143  std::string to_string() const override { return "'" + *stringval_ + "'"; }
144 
145  private:
146  std::unique_ptr<std::string> stringval_;
147 };
148 
149 /*
150  * @type IntLiteral
151  * @brief the literal for integer constants
152  */
153 class IntLiteral : public Literal {
154  public:
155  explicit IntLiteral(int64_t i) : intval_(i) {}
156  int64_t get_intval() const { return intval_; }
157  std::shared_ptr<Analyzer::Expr> analyze(
158  const Catalog_Namespace::Catalog& catalog,
159  Analyzer::Query& query,
160  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
161  static std::shared_ptr<Analyzer::Expr> analyzeValue(const int64_t intval);
162  std::string to_string() const override {
163  return boost::lexical_cast<std::string>(intval_);
164  }
165 
166  private:
167  int64_t intval_;
168 };
169 
170 /*
171  * @type FixedPtLiteral
172  * @brief the literal for DECIMAL and NUMERIC
173  */
174 class FixedPtLiteral : public Literal {
175  public:
176  explicit FixedPtLiteral(std::string* n) : fixedptval_(n) {}
177  const std::string* get_fixedptval() const { return fixedptval_.get(); }
178  std::shared_ptr<Analyzer::Expr> analyze(
179  const Catalog_Namespace::Catalog& catalog,
180  Analyzer::Query& query,
181  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
182  static std::shared_ptr<Analyzer::Expr> analyzeValue(const int64_t numericval,
183  const int scale,
184  const int precision);
185  std::string to_string() const override { return *fixedptval_; }
186 
187  private:
188  std::unique_ptr<std::string> fixedptval_;
189 };
190 
191 /*
192  * @type FloatLiteral
193  * @brief the literal for FLOAT or REAL
194  */
195 class FloatLiteral : public Literal {
196  public:
197  explicit FloatLiteral(float f) : floatval_(f) {}
198  float get_floatval() const { return floatval_; }
199  std::shared_ptr<Analyzer::Expr> analyze(
200  const Catalog_Namespace::Catalog& catalog,
201  Analyzer::Query& query,
202  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
203  std::string to_string() const override {
204  return boost::lexical_cast<std::string>(floatval_);
205  }
206 
207  private:
208  float floatval_;
209 };
210 
211 /*
212  * @type DoubleLiteral
213  * @brief the literal for DOUBLE PRECISION
214  */
215 class DoubleLiteral : public Literal {
216  public:
217  explicit DoubleLiteral(double d) : doubleval_(d) {}
218  double get_doubleval() const { return doubleval_; }
219  std::shared_ptr<Analyzer::Expr> analyze(
220  const Catalog_Namespace::Catalog& catalog,
221  Analyzer::Query& query,
222  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
223  std::string to_string() const override {
224  return boost::lexical_cast<std::string>(doubleval_);
225  }
226 
227  private:
228  double doubleval_;
229 };
230 
231 /*
232  * @type TimestampLiteral
233  * @brief the literal for Timestamp
234  */
235 class TimestampLiteral : public Literal {
236  public:
237  explicit TimestampLiteral() { time(reinterpret_cast<time_t*>(&timestampval_)); }
238  std::shared_ptr<Analyzer::Expr> analyze(
239  const Catalog_Namespace::Catalog& catalog,
240  Analyzer::Query& query,
241  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
242  static std::shared_ptr<Analyzer::Expr> get(const int64_t);
243  std::string to_string() const override {
244  // TODO: Should we convert to a datum and use the datum toString converters to pretty
245  // print?
246  return boost::lexical_cast<std::string>(timestampval_);
247  }
248 
249  private:
250  int64_t timestampval_;
251 };
252 
253 /*
254  * @type UserLiteral
255  * @brief the literal for USER
256  */
257 class UserLiteral : public Literal {
258  public:
260  std::shared_ptr<Analyzer::Expr> analyze(
261  const Catalog_Namespace::Catalog& catalog,
262  Analyzer::Query& query,
263  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
264  static std::shared_ptr<Analyzer::Expr> get(const std::string&);
265  std::string to_string() const override { return "USER"; }
266 };
267 
268 /*
269  * @type ArrayLiteral
270  * @brief the literal for arrays
271  */
272 class ArrayLiteral : public Literal {
273  public:
275  ArrayLiteral(std::list<Expr*>* v) {
276  CHECK(v);
277  for (const auto e : *v) {
278  value_list_.emplace_back(e);
279  }
280  delete v;
281  }
282  const std::list<std::unique_ptr<Expr>>& get_value_list() const { return value_list_; }
283  std::shared_ptr<Analyzer::Expr> analyze(
284  const Catalog_Namespace::Catalog& catalog,
285  Analyzer::Query& query,
286  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
287  std::string to_string() const override;
288 
289  private:
290  std::list<std::unique_ptr<Expr>> value_list_;
291 };
292 
293 /*
294  * @type OperExpr
295  * @brief all operator expressions
296  */
297 class OperExpr : public Expr {
298  public:
300  : optype_(t), opqualifier_(kONE), left_(l), right_(r) {}
302  : optype_(t), opqualifier_(q), left_(l), right_(r) {}
303  SQLOps get_optype() const { return optype_; }
304  const Expr* get_left() const { return left_.get(); }
305  const Expr* get_right() const { return right_.get(); }
306  std::shared_ptr<Analyzer::Expr> analyze(
307  const Catalog_Namespace::Catalog& catalog,
308  Analyzer::Query& query,
309  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
310  static std::shared_ptr<Analyzer::Expr> normalize(
311  const SQLOps optype,
312  const SQLQualifier qual,
313  std::shared_ptr<Analyzer::Expr> left_expr,
314  std::shared_ptr<Analyzer::Expr> right_expr,
315  const Executor* executor = nullptr);
316  std::string to_string() const override;
317 
318  private:
321  std::unique_ptr<Expr> left_;
322  std::unique_ptr<Expr> right_;
323 };
324 
325 // forward reference of QuerySpec
326 class QuerySpec;
327 
328 /*
329  * @type SubqueryExpr
330  * @brief expression for subquery
331  */
332 class SubqueryExpr : public Expr {
333  public:
334  explicit SubqueryExpr(QuerySpec* q) : query_(q) {}
335  const QuerySpec* get_query() const { return query_.get(); }
336  std::shared_ptr<Analyzer::Expr> analyze(
337  const Catalog_Namespace::Catalog& catalog,
338  Analyzer::Query& query,
339  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
340  std::string to_string() const override;
341 
342  private:
343  std::unique_ptr<QuerySpec> query_;
344 };
345 
346 class IsNullExpr : public Expr {
347  public:
348  IsNullExpr(bool n, Expr* a) : is_not_(n), arg_(a) {}
349  bool get_is_not() const { return is_not_; }
350  std::shared_ptr<Analyzer::Expr> analyze(
351  const Catalog_Namespace::Catalog& catalog,
352  Analyzer::Query& query,
353  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
354  std::string to_string() const override;
355 
356  private:
357  bool is_not_;
358  std::unique_ptr<Expr> arg_;
359 };
360 
361 /*
362  * @type InExpr
363  * @brief expression for the IS NULL predicate
364  */
365 class InExpr : public Expr {
366  public:
367  InExpr(bool n, Expr* a) : is_not_(n), arg_(a) {}
368  bool get_is_not() const { return is_not_; }
369  const Expr* get_arg() const { return arg_.get(); }
370  std::shared_ptr<Analyzer::Expr> analyze(
371  const Catalog_Namespace::Catalog& catalog,
372  Analyzer::Query& query,
373  TlistRefType allow_tlist_ref = TLIST_NONE) const override = 0;
374  std::string to_string() const override;
375 
376  protected:
377  bool is_not_;
378  std::unique_ptr<Expr> arg_;
379 };
380 
381 /*
382  * @type InSubquery
383  * @brief expression for the IN (subquery) predicate
384  */
385 class InSubquery : public InExpr {
386  public:
387  InSubquery(bool n, Expr* a, SubqueryExpr* q) : InExpr(n, a), subquery_(q) {}
388  const SubqueryExpr* get_subquery() const { return subquery_.get(); }
389  std::shared_ptr<Analyzer::Expr> analyze(
390  const Catalog_Namespace::Catalog& catalog,
391  Analyzer::Query& query,
392  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
393  std::string to_string() const override;
394 
395  private:
396  std::unique_ptr<SubqueryExpr> subquery_;
397 };
398 
399 /*
400  * @type InValues
401  * @brief expression for IN (val1, val2, ...)
402  */
403 class InValues : public InExpr {
404  public:
405  InValues(bool n, Expr* a, std::list<Expr*>* v) : InExpr(n, a) {
406  CHECK(v);
407  for (const auto e : *v) {
408  value_list_.emplace_back(e);
409  }
410  delete v;
411  }
412  const std::list<std::unique_ptr<Expr>>& get_value_list() const { return value_list_; }
413  std::shared_ptr<Analyzer::Expr> analyze(
414  const Catalog_Namespace::Catalog& catalog,
415  Analyzer::Query& query,
416  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
417  std::string to_string() const override;
418 
419  private:
420  std::list<std::unique_ptr<Expr>> value_list_;
421 };
422 
423 /*
424  * @type BetweenExpr
425  * @brief expression for BETWEEN lower AND upper
426  */
427 class BetweenExpr : public Expr {
428  public:
429  BetweenExpr(bool n, Expr* a, Expr* l, Expr* u)
430  : is_not_(n), arg_(a), lower_(l), upper_(u) {}
431  bool get_is_not() const { return is_not_; }
432  const Expr* get_arg() const { return arg_.get(); }
433  const Expr* get_lower() const { return lower_.get(); }
434  const Expr* get_upper() const { return upper_.get(); }
435  std::shared_ptr<Analyzer::Expr> analyze(
436  const Catalog_Namespace::Catalog& catalog,
437  Analyzer::Query& query,
438  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
439  std::string to_string() const override;
440 
441  private:
442  bool is_not_;
443  std::unique_ptr<Expr> arg_;
444  std::unique_ptr<Expr> lower_;
445  std::unique_ptr<Expr> upper_;
446 };
447 
448 /*
449  * @type CharLengthExpr
450  * @brief expression to get length of string
451  */
452 
453 class CharLengthExpr : public Expr {
454  public:
456  const Expr* get_arg() const { return arg_.get(); }
458  std::shared_ptr<Analyzer::Expr> analyze(
459  const Catalog_Namespace::Catalog& catalog,
460  Analyzer::Query& query,
461  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
462  std::string to_string() const override;
463 
464  private:
465  std::unique_ptr<Expr> arg_;
467 };
468 
469 /*
470  * @type CardinalityExpr
471  * @brief expression to get cardinality of an array
472  */
473 
474 class CardinalityExpr : public Expr {
475  public:
477  const Expr* get_arg() const { return arg_.get(); }
478  std::shared_ptr<Analyzer::Expr> analyze(
479  const Catalog_Namespace::Catalog& catalog,
480  Analyzer::Query& query,
481  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
482  std::string to_string() const override;
483 
484  private:
485  std::unique_ptr<Expr> arg_;
486 };
487 
488 /*
489  * @type LikeExpr
490  * @brief expression for the LIKE predicate
491  */
492 class LikeExpr : public Expr {
493  public:
494  LikeExpr(bool n, bool i, Expr* a, Expr* l, Expr* e)
495  : is_not_(n), is_ilike_(i), arg_(a), like_string_(l), escape_string_(e) {}
496  bool get_is_not() const { return is_not_; }
497  const Expr* get_arg() const { return arg_.get(); }
498  const Expr* get_like_string() const { return like_string_.get(); }
499  const Expr* get_escape_string() const { return escape_string_.get(); }
500  std::shared_ptr<Analyzer::Expr> analyze(
501  const Catalog_Namespace::Catalog& catalog,
502  Analyzer::Query& query,
503  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
504  static std::shared_ptr<Analyzer::Expr> get(std::shared_ptr<Analyzer::Expr> arg_expr,
505  std::shared_ptr<Analyzer::Expr> like_expr,
506  std::shared_ptr<Analyzer::Expr> escape_expr,
507  const bool is_ilike,
508  const bool is_not);
509  std::string to_string() const override;
510 
511  private:
512  bool is_not_;
513  bool is_ilike_;
514  std::unique_ptr<Expr> arg_;
515  std::unique_ptr<Expr> like_string_;
516  std::unique_ptr<Expr> escape_string_;
517 
518  static void check_like_expr(const std::string& like_str, char escape_char);
519  static bool test_is_simple_expr(const std::string& like_str, char escape_char);
520  static void erase_cntl_chars(std::string& like_str, char escape_char);
521 };
522 
523 /*
524  * @type RegexpExpr
525  * @brief expression for REGEXP
526  */
527 class RegexpExpr : public Expr {
528  public:
529  RegexpExpr(bool n, Expr* a, Expr* p, Expr* e)
530  : is_not_(n), arg_(a), pattern_string_(p), escape_string_(e) {}
531  bool get_is_not() const { return is_not_; }
532  const Expr* get_arg() const { return arg_.get(); }
533  const Expr* get_pattern_string() const { return pattern_string_.get(); }
534  const Expr* get_escape_string() const { return escape_string_.get(); }
535  std::shared_ptr<Analyzer::Expr> analyze(
536  const Catalog_Namespace::Catalog& catalog,
537  Analyzer::Query& query,
538  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
539  static std::shared_ptr<Analyzer::Expr> get(std::shared_ptr<Analyzer::Expr> arg_expr,
540  std::shared_ptr<Analyzer::Expr> pattern_expr,
541  std::shared_ptr<Analyzer::Expr> escape_expr,
542  const bool is_not);
543  std::string to_string() const override;
544 
545  private:
546  bool is_not_;
547  std::unique_ptr<Expr> arg_;
548  std::unique_ptr<Expr> pattern_string_;
549  std::unique_ptr<Expr> escape_string_;
550 
551  static void check_pattern_expr(const std::string& pattern_str, char escape_char);
552  static bool translate_to_like_pattern(std::string& pattern_str, char escape_char);
553 };
554 
555 class WidthBucketExpr : public Expr {
556  public:
559  const Expr* get_target_value() const { return target_value_.get(); }
560  const Expr* get_lower_bound() const { return lower_bound_.get(); }
561  const Expr* get_upper_bound() const { return upper_bound_.get(); }
562  const Expr* get_partition_count() const { return partition_count_.get(); }
563  std::shared_ptr<Analyzer::Expr> analyze(
564  const Catalog_Namespace::Catalog& catalog,
565  Analyzer::Query& query,
566  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
567  static std::shared_ptr<Analyzer::Expr> get(
568  std::shared_ptr<Analyzer::Expr> target_value,
569  std::shared_ptr<Analyzer::Expr> lower_bound,
570  std::shared_ptr<Analyzer::Expr> upper_bound,
571  std::shared_ptr<Analyzer::Expr> partition_count);
572  std::string to_string() const override;
573 
574  private:
575  std::unique_ptr<Expr> target_value_;
576  std::unique_ptr<Expr> lower_bound_;
577  std::unique_ptr<Expr> upper_bound_;
578  std::unique_ptr<Expr> partition_count_;
579 };
580 
581 /*
582  * @type LikelihoodExpr
583  * @brief expression for LIKELY, UNLIKELY
584  */
585 class LikelihoodExpr : public Expr {
586  public:
587  LikelihoodExpr(bool n, Expr* a, float l) : is_not_(n), arg_(a), likelihood_(l) {}
588  bool get_is_not() const { return is_not_; }
589  const Expr* get_arg() const { return arg_.get(); }
590  float get_likelihood() const { return likelihood_; }
591  std::shared_ptr<Analyzer::Expr> analyze(
592  const Catalog_Namespace::Catalog& catalog,
593  Analyzer::Query& query,
594  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
595  static std::shared_ptr<Analyzer::Expr> get(std::shared_ptr<Analyzer::Expr> arg_expr,
596  float likelihood,
597  const bool is_not);
598  std::string to_string() const override;
599 
600  private:
601  bool is_not_;
602  std::unique_ptr<Expr> arg_;
603  float likelihood_;
604 };
605 
606 /*
607  * @type ExistsExpr
608  * @brief expression for EXISTS (subquery)
609  */
610 class ExistsExpr : public Expr {
611  public:
612  explicit ExistsExpr(QuerySpec* q) : query_(q) {}
613  const QuerySpec* get_query() const { return query_.get(); }
614  std::shared_ptr<Analyzer::Expr> analyze(
615  const Catalog_Namespace::Catalog& catalog,
616  Analyzer::Query& query,
617  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
618  std::string to_string() const override;
619 
620  private:
621  std::unique_ptr<QuerySpec> query_;
622 };
623 
624 /*
625  * @type ColumnRef
626  * @brief expression for a column reference
627  */
628 class ColumnRef : public Expr {
629  public:
630  explicit ColumnRef(std::string* n1) : table_(nullptr), column_(n1) {}
631  ColumnRef(std::string* n1, std::string* n2) : table_(n1), column_(n2) {}
632  const std::string* get_table() const { return table_.get(); }
633  const std::string* get_column() const { return column_.get(); }
634  std::shared_ptr<Analyzer::Expr> analyze(
635  const Catalog_Namespace::Catalog& catalog,
636  Analyzer::Query& query,
637  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
638  std::string to_string() const override;
639 
640  private:
641  std::unique_ptr<std::string> table_;
642  std::unique_ptr<std::string> column_; // can be nullptr in the t.* case
643 };
644 
645 /*
646  * @type FunctionRef
647  * @brief expression for a function call
648  */
649 class FunctionRef : public Expr {
650  public:
651  explicit FunctionRef(std::string* n) : name_(n), distinct_(false), arg_(nullptr) {}
652  FunctionRef(std::string* n, Expr* a) : name_(n), distinct_(false), arg_(a) {}
653  FunctionRef(std::string* n, bool d, Expr* a) : name_(n), distinct_(d), arg_(a) {}
654  const std::string* get_name() const { return name_.get(); }
655  bool get_distinct() const { return distinct_; }
656  Expr* get_arg() const { return arg_.get(); }
657  std::shared_ptr<Analyzer::Expr> analyze(
658  const Catalog_Namespace::Catalog& catalog,
659  Analyzer::Query& query,
660  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
661  std::string to_string() const override;
662 
663  private:
664  std::unique_ptr<std::string> name_;
665  bool distinct_; // only true for COUNT(DISTINCT x)
666  std::unique_ptr<Expr> arg_; // for COUNT, nullptr means '*'
667 };
668 
669 class CastExpr : public Expr {
670  public:
672  std::shared_ptr<Analyzer::Expr> analyze(
673  const Catalog_Namespace::Catalog& catalog,
674  Analyzer::Query& query,
675  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
676  std::string to_string() const override {
677  return "CAST(" + arg_->to_string() + " AS " + target_type_->to_string() + ")";
678  }
679 
680  private:
681  std::unique_ptr<Expr> arg_;
682  std::unique_ptr<SQLType> target_type_;
683 };
684 
685 class ExprPair : public Node {
686  public:
687  ExprPair(Expr* e1, Expr* e2) : expr1_(e1), expr2_(e2) {}
688  const Expr* get_expr1() const { return expr1_.get(); }
689  const Expr* get_expr2() const { return expr2_.get(); }
690 
691  private:
692  std::unique_ptr<Expr> expr1_;
693  std::unique_ptr<Expr> expr2_;
694 };
695 
696 class CaseExpr : public Expr {
697  public:
698  CaseExpr(std::list<ExprPair*>* w, Expr* e) : else_expr_(e) {
699  CHECK(w);
700  for (const auto e : *w) {
701  when_then_list_.emplace_back(e);
702  }
703  delete w;
704  }
705  std::shared_ptr<Analyzer::Expr> analyze(
706  const Catalog_Namespace::Catalog& catalog,
707  Analyzer::Query& query,
708  TlistRefType allow_tlist_ref = TLIST_NONE) const override;
709  static std::shared_ptr<Analyzer::Expr> normalize(
710  const std::list<
711  std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>&,
712  const std::shared_ptr<Analyzer::Expr>,
713  const Executor* executor = nullptr);
714  std::string to_string() const override;
715 
716  private:
717  std::list<std::unique_ptr<ExprPair>> when_then_list_;
718  std::unique_ptr<Expr> else_expr_;
719 };
720 
721 /*
722  * @type TableRef
723  * @brief table reference in FROM clause
724  */
725 class TableRef : public Node {
726  public:
727  explicit TableRef(std::string* t) : table_name_(t), range_var_(nullptr) {}
728  TableRef(std::string* t, std::string* r) : table_name_(t), range_var_(r) {}
729  const std::string* get_table_name() const { return table_name_.get(); }
730  const std::string* get_range_var() const { return range_var_.get(); }
731  std::string to_string() const;
732 
733  private:
734  std::unique_ptr<std::string> table_name_;
735  std::unique_ptr<std::string> range_var_;
736 };
737 
738 /*
739  * @type Stmt
740  * @brief root super class for all SQL statements
741  */
742 class Stmt : public Node {
743  // intentionally empty
744 };
745 
746 /*
747  * @type DMLStmt
748  * @brief DML Statements
749  */
750 class DMLStmt : public Stmt {
751  public:
752  virtual void analyze(const Catalog_Namespace::Catalog& catalog,
753  Analyzer::Query& query) const = 0;
754 };
755 
756 /*
757  * @type DDLStmt
758  * @brief DDL Statements
759  */
760 class ColumnDef;
761 class DDLStmt : public Stmt {
762  public:
763  virtual void execute(const Catalog_Namespace::SessionInfo& session) = 0;
764  void setColumnDescriptor(ColumnDescriptor& cd, const ColumnDef* coldef);
765 };
766 
767 /*
768  * @type TableElement
769  * @brief elements in table definition
770  */
771 class TableElement : public Node {
772  // intentionally empty
773 };
774 
775 /*
776  * @type ColumnConstraintDef
777  * @brief integrity constraint on a column
778  */
779 class ColumnConstraintDef : public Node {
780  public:
781  ColumnConstraintDef(bool n, bool u, bool p, Literal* d)
782  : notnull_(n), unique_(u), is_primarykey_(p), defaultval_(d) {}
785  ColumnConstraintDef(std::string* t, std::string* c)
786  : notnull_(false)
787  , unique_(false)
789  , foreign_table_(t)
790  , foreign_column_(c) {}
791  bool get_notnull() const { return notnull_; }
792  bool get_unique() const { return unique_; }
793  bool get_is_primarykey() const { return is_primarykey_; }
794  const Literal* get_defaultval() const { return defaultval_.get(); }
795  const Expr* get_check_condition() const { return check_condition_.get(); }
796  const std::string* get_foreign_table() const { return foreign_table_.get(); }
797  const std::string* get_foreign_column() const { return foreign_column_.get(); }
798 
799  private:
800  bool notnull_;
801  bool unique_;
803  std::unique_ptr<Literal> defaultval_;
804  std::unique_ptr<Expr> check_condition_;
805  std::unique_ptr<std::string> foreign_table_;
806  std::unique_ptr<std::string> foreign_column_;
807 };
808 
809 /*
810  * @type CompressDef
811  * @brief Node for compression scheme definition
812  */
813 class CompressDef : public Node, public ddl_utils::Encoding {
814  public:
815  CompressDef(std::string* n, int p) : ddl_utils::Encoding(n, p) {}
816 };
817 
818 /*
819  * @type ColumnDef
820  * @brief Column definition
821  */
822 class ColumnDef : public TableElement {
823  public:
824  ColumnDef(std::string* c, SQLType* t, CompressDef* cp, ColumnConstraintDef* cc)
826  const std::string* get_column_name() const { return column_name_.get(); }
827  SQLType* get_column_type() const { return column_type_.get(); }
828  const CompressDef* get_compression() const { return compression_.get(); }
830  return column_constraint_.get();
831  }
832 
833  private:
834  std::unique_ptr<std::string> column_name_;
835  std::unique_ptr<SQLType> column_type_;
836  std::unique_ptr<CompressDef> compression_;
837  std::unique_ptr<ColumnConstraintDef> column_constraint_;
838 };
839 
840 /*
841  * @type TableConstraintDef
842  * @brief integrity constraint for table
843  */
845  // intentionally empty
846 };
847 
848 /*
849  * @type UniqueDef
850  * @brief uniqueness constraint
851  */
853  public:
854  UniqueDef(bool p, std::list<std::string*>* cl) : is_primarykey_(p) {
855  CHECK(cl);
856  for (const auto s : *cl) {
857  column_list_.emplace_back(s);
858  }
859  delete cl;
860  }
861  bool get_is_primarykey() const { return is_primarykey_; }
862  const std::list<std::unique_ptr<std::string>>& get_column_list() const {
863  return column_list_;
864  }
865 
866  private:
868  std::list<std::unique_ptr<std::string>> column_list_;
869 };
870 
871 /*
872  * @type ForeignKeyDef
873  * @brief foreign key constraint
874  */
876  public:
877  ForeignKeyDef(std::list<std::string*>* cl, std::string* t, std::list<std::string*>* fcl)
878  : foreign_table_(t) {
879  CHECK(cl);
880  for (const auto s : *cl) {
881  column_list_.emplace_back(s);
882  }
883  delete cl;
884  if (fcl) {
885  for (const auto s : *fcl) {
886  foreign_column_list_.emplace_back(s);
887  }
888  }
889  delete fcl;
890  }
891  const std::list<std::unique_ptr<std::string>>& get_column_list() const {
892  return column_list_;
893  }
894  const std::string* get_foreign_table() const { return foreign_table_.get(); }
895  const std::list<std::unique_ptr<std::string>>& get_foreign_column_list() const {
896  return foreign_column_list_;
897  }
898 
899  private:
900  std::list<std::unique_ptr<std::string>> column_list_;
901  std::unique_ptr<std::string> foreign_table_;
902  std::list<std::unique_ptr<std::string>> foreign_column_list_;
903 };
904 
905 /*
906  * @type CheckDef
907  * @brief Check constraint
908  */
909 class CheckDef : public TableConstraintDef {
910  public:
912  const Expr* get_check_condition() const { return check_condition_.get(); }
913 
914  private:
915  std::unique_ptr<Expr> check_condition_;
916 };
917 
918 /*
919  * @type SharedDictionaryDef
920  * @brief Shared dictionary hint. The underlying string dictionary will be shared with the
921  * referenced column.
922  */
924  public:
925  SharedDictionaryDef(const std::string& column,
926  const std::string& foreign_table,
927  const std::string foreign_column)
928  : column_(column), foreign_table_(foreign_table), foreign_column_(foreign_column) {}
929 
930  const std::string& get_column() const { return column_; }
931 
932  const std::string& get_foreign_table() const { return foreign_table_; }
933 
934  const std::string& get_foreign_column() const { return foreign_column_; }
935 
936  private:
937  const std::string column_;
938  const std::string foreign_table_;
939  const std::string foreign_column_;
940 };
941 
942 /*
943  * @type ShardKeyDef
944  * @brief Shard key for a table, mainly useful for distributed joins.
945  */
947  public:
948  ShardKeyDef(const std::string& column) : column_(column) {}
949 
950  const std::string& get_column() const { return column_; }
951 
952  private:
953  const std::string column_;
954 };
955 
956 /*
957  * @type NameValueAssign
958  * @brief Assignment of a string value to a named attribute
959  */
960 class NameValueAssign : public Node {
961  public:
962  NameValueAssign(std::string* n, Literal* v) : name_(n), value_(v) {}
963  const std::string* get_name() const { return name_.get(); }
964  const Literal* get_value() const { return value_.get(); }
965 
966  private:
967  std::unique_ptr<std::string> name_;
968  std::unique_ptr<Literal> value_;
969 };
970 
971 /*
972  * @type CreateTableBaseStmt
973  */
974 class CreateTableBaseStmt : public DDLStmt {
975  public:
976  virtual const std::string* get_table() const = 0;
977  virtual const std::list<std::unique_ptr<TableElement>>& get_table_element_list()
978  const = 0;
979 };
980 
981 /*
982  * @type CreateTableStmt
983  * @brief CREATE TABLE statement
984  */
986  public:
987  CreateTableStmt(std::string* tab,
988  const std::string* storage,
989  std::list<TableElement*>* table_elems,
990  bool is_temporary,
991  bool if_not_exists,
992  std::list<NameValueAssign*>* s)
993  : table_(tab), is_temporary_(is_temporary), if_not_exists_(if_not_exists) {
994  CHECK(table_elems);
995  for (const auto e : *table_elems) {
996  table_element_list_.emplace_back(e);
997  }
998  delete table_elems;
999  if (s) {
1000  for (const auto e : *s) {
1001  storage_options_.emplace_back(e);
1002  }
1003  delete s;
1004  }
1005  }
1006 
1007  CreateTableStmt(const rapidjson::Value& payload);
1008 
1009  const std::string* get_table() const override { return table_.get(); }
1010  const std::list<std::unique_ptr<TableElement>>& get_table_element_list()
1011  const override {
1012  return table_element_list_;
1013  }
1014 
1015  void execute(const Catalog_Namespace::SessionInfo& session) override;
1016  void executeDryRun(const Catalog_Namespace::SessionInfo& session,
1017  TableDescriptor& td,
1018  std::list<ColumnDescriptor>& columns,
1019  std::vector<SharedDictionaryDef>& shared_dict_defs);
1020 
1021  private:
1022  std::unique_ptr<std::string> table_;
1023  std::list<std::unique_ptr<TableElement>> table_element_list_;
1026  std::list<std::unique_ptr<NameValueAssign>> storage_options_;
1027 };
1028 
1030  public:
1031  ~QueryConnector() = default;
1032  virtual size_t getOuterFragmentCount(QueryStateProxy,
1033  std::string& sql_query_string) = 0;
1034  virtual std::vector<AggregatedResult> query(QueryStateProxy,
1035  std::string& sql_query_string,
1036  std::vector<size_t> outer_frag_indices,
1037  bool allow_interrupt) = 0;
1038 };
1039 
1042  public:
1043  size_t getOuterFragmentCount(QueryStateProxy, std::string& sql_query_string) override;
1044 
1046  std::string& sql_query_string,
1047  std::vector<size_t> outer_frag_indices,
1048  bool validate_only,
1049  bool allow_interrupt);
1050  std::vector<AggregatedResult> query(QueryStateProxy,
1051  std::string& sql_query_string,
1052  std::vector<size_t> outer_frag_indices,
1053  bool allow_interrupt) override;
1054  std::list<ColumnDescriptor> getColumnDescriptors(AggregatedResult& result,
1055  bool for_create);
1056  size_t leafCount() override { return LocalInsertConnector::leafCount(); }
1058  const Catalog_Namespace::SessionInfo& parent_session_info,
1059  const size_t leaf_idx,
1060  const Fragmenter_Namespace::InsertChunks& insert_chunks) override {
1061  return LocalInsertConnector::insertChunksToLeaf(
1062  parent_session_info, leaf_idx, insert_chunks);
1063  }
1064  void insertDataToLeaf(const Catalog_Namespace::SessionInfo& parent_session_info,
1065  const size_t leaf_idx,
1066  Fragmenter_Namespace::InsertData& insert_data) override {
1067  return LocalInsertConnector::insertDataToLeaf(
1068  parent_session_info, leaf_idx, insert_data);
1069  }
1070  void checkpoint(const Catalog_Namespace::SessionInfo& parent_session_info,
1071  int tableId) override {
1072  return LocalInsertConnector::checkpoint(parent_session_info, tableId);
1073  }
1074  void rollback(const Catalog_Namespace::SessionInfo& parent_session_info,
1075  int tableId) override {
1076  return LocalInsertConnector::rollback(parent_session_info, tableId);
1077  }
1078 };
1079 
1080 /*
1081  * @type CreateDataframeStmt
1082  * @brief CREATE DATAFRAME statement
1083  */
1085  public:
1086  CreateDataframeStmt(std::string* tab,
1087  std::list<TableElement*>* table_elems,
1088  std::string* filename,
1089  std::list<NameValueAssign*>* s)
1090  : table_(tab), filename_(filename) {
1091  CHECK(table_elems);
1092  for (const auto e : *table_elems) {
1093  table_element_list_.emplace_back(e);
1094  }
1095  delete table_elems;
1096  if (s) {
1097  for (const auto e : *s) {
1098  storage_options_.emplace_back(e);
1099  }
1100  delete s;
1101  }
1102  }
1103  CreateDataframeStmt(const rapidjson::Value& payload);
1104 
1105  const std::string* get_table() const override { return table_.get(); }
1106  const std::list<std::unique_ptr<TableElement>>& get_table_element_list()
1107  const override {
1108  return table_element_list_;
1109  }
1110 
1111  void execute(const Catalog_Namespace::SessionInfo& session) override;
1112 
1113  private:
1114  std::unique_ptr<std::string> table_;
1115  std::list<std::unique_ptr<TableElement>> table_element_list_;
1116  std::unique_ptr<std::string> filename_;
1117  std::list<std::unique_ptr<NameValueAssign>> storage_options_;
1118 };
1119 
1120 /*
1121  * @type InsertIntoTableAsSelectStmt
1122  * @brief INSERT INTO TABLE SELECT statement
1123  */
1125  public:
1126  // ITAS constructor
1127  InsertIntoTableAsSelectStmt(const rapidjson::Value& payload);
1128  InsertIntoTableAsSelectStmt(const std::string* table_name,
1129  const std::string* select_query,
1130  std::list<std::string*>* c)
1131  : table_name_(*table_name), select_query_(*select_query) {
1132  if (c) {
1133  for (auto e : *c) {
1134  column_list_.emplace_back(e);
1135  }
1136  delete c;
1137  }
1138 
1139  delete table_name;
1140  delete select_query;
1141  }
1142 
1144  const TableDescriptor* td,
1145  bool validate_table,
1146  bool for_CTAS = false);
1147  void execute(const Catalog_Namespace::SessionInfo& session) override;
1148 
1149  std::string& get_table() { return table_name_; }
1150 
1151  std::string& get_select_query() { return select_query_; }
1152 
1154 
1155  protected:
1156  std::vector<std::unique_ptr<std::string>> column_list_;
1157  std::string table_name_;
1158  std::string select_query_;
1159 };
1160 
1161 /*
1162  * @type CreateTableAsSelectStmt
1163  * @brief CREATE TABLE AS SELECT statement
1164  */
1166  public:
1167  CreateTableAsSelectStmt(const rapidjson::Value& payload);
1168  CreateTableAsSelectStmt(const std::string* table_name,
1169  const std::string* select_query,
1170  const bool is_temporary,
1171  const bool if_not_exists,
1172  std::list<NameValueAssign*>* s)
1173  : InsertIntoTableAsSelectStmt(table_name, select_query, nullptr)
1174  , is_temporary_(is_temporary)
1175  , if_not_exists_(if_not_exists) {
1176  if (s) {
1177  for (const auto& e : *s) {
1178  storage_options_.emplace_back(e);
1179  }
1180  delete s;
1181  }
1182  }
1183 
1184  void execute(const Catalog_Namespace::SessionInfo& session) override;
1185 
1186  private:
1189  std::list<std::unique_ptr<NameValueAssign>> storage_options_;
1190 };
1191 
1192 /*
1193  * @type AlterTableStmt
1194  * @brief ALTER TABLE statement
1195  *
1196  * AlterTableStmt is more a composite Stmt in that it relies upon several other Stmts to
1197  * handle the execution.
1198  */
1199 
1200 class AlterTableStmt : public DDLStmt {
1201  public:
1202  static std::unique_ptr<Parser::DDLStmt> delegate(const rapidjson::Value& payload);
1203 
1204  const std::string* get_table() const { return table_.get(); }
1205 
1206  void execute(const Catalog_Namespace::SessionInfo& session) override;
1207 
1208  private:
1209  std::unique_ptr<std::string> table_;
1210  const rapidjson::Value payload_;
1211 };
1212 
1213 /*
1214  * @type DropTableStmt
1215  * @brief DROP TABLE statement
1216  */
1217 class DropTableStmt : public DDLStmt {
1218  public:
1219  DropTableStmt(std::string* tab, bool i) : table_(tab), if_exists_(i) {}
1220  DropTableStmt(const rapidjson::Value& payload);
1221 
1222  const std::string* get_table() const { return table_.get(); }
1223  void execute(const Catalog_Namespace::SessionInfo& session) override;
1224 
1225  private:
1226  std::unique_ptr<std::string> table_;
1228 };
1229 
1230 /*
1231  * @type TruncateTableStmt
1232  * @brief TRUNCATE TABLE statement
1233  */
1234 class TruncateTableStmt : public DDLStmt {
1235  public:
1236  TruncateTableStmt(std::string* tab) : table_(tab) {}
1237  TruncateTableStmt(const rapidjson::Value& payload);
1238  const std::string* get_table() const { return table_.get(); }
1239  void execute(const Catalog_Namespace::SessionInfo& session) override;
1240 
1241  private:
1242  std::unique_ptr<std::string> table_;
1243 };
1244 
1245 class OptimizeTableStmt : public DDLStmt {
1246  public:
1247  OptimizeTableStmt(std::string* table, std::list<NameValueAssign*>* o) : table_(table) {
1248  if (!table_) {
1249  throw std::runtime_error("Table name is required for OPTIMIZE command.");
1250  }
1251  if (o) {
1252  for (const auto e : *o) {
1253  options_.emplace_back(e);
1254  }
1255  delete o;
1256  }
1257  }
1258  OptimizeTableStmt(const rapidjson::Value& payload);
1259 
1260  const std::string getTableName() const { return *(table_.get()); }
1261 
1263  for (const auto& e : options_) {
1264  if (boost::iequals(*(e->get_name()), "VACUUM")) {
1265  return true;
1266  }
1267  }
1268  return false;
1269  }
1270 
1271  void execute(const Catalog_Namespace::SessionInfo& session) override;
1272 
1273  private:
1274  std::unique_ptr<std::string> table_;
1275  std::list<std::unique_ptr<NameValueAssign>> options_;
1276 };
1277 
1278 class ValidateStmt : public DDLStmt {
1279  public:
1280  ValidateStmt(std::string* type, std::list<NameValueAssign*>* with_opts);
1281  ValidateStmt(const rapidjson::Value& payload);
1282 
1283  bool isRepairTypeRemove() const { return isRepairTypeRemove_; }
1284 
1285  const std::string getType() const { return *(type_.get()); }
1286 
1287  void execute(const Catalog_Namespace::SessionInfo& session) override { UNREACHABLE(); }
1288 
1289  private:
1290  std::unique_ptr<std::string> type_;
1291  bool isRepairTypeRemove_ = false;
1292 };
1293 
1294 class RenameDBStmt : public DDLStmt {
1295  public:
1296  RenameDBStmt(const rapidjson::Value& payload);
1297 
1298  RenameDBStmt(std::string* database_name, std::string* new_database_name)
1299  : database_name_(database_name), new_database_name_(new_database_name) {}
1300 
1301  auto const& getPreviousDatabaseName() { return database_name_; }
1302  auto const& getNewDatabaseName() { return new_database_name_; }
1303  void execute(const Catalog_Namespace::SessionInfo& session) override;
1304 
1305  private:
1306  std::unique_ptr<std::string> database_name_;
1307  std::unique_ptr<std::string> new_database_name_;
1308 };
1309 
1310 class RenameUserStmt : public DDLStmt {
1311  public:
1312  RenameUserStmt(const rapidjson::Value& payload);
1313  RenameUserStmt(std::string* username, std::string* new_username)
1314  : username_(username), new_username_(new_username) {}
1315  auto const& getOldUserName() { return username_; }
1316  auto const& getNewUserName() { return new_username_; }
1317  void execute(const Catalog_Namespace::SessionInfo& session) override;
1318 
1319  private:
1320  std::unique_ptr<std::string> username_;
1321  std::unique_ptr<std::string> new_username_;
1322 };
1323 
1324 class RenameTableStmt : public DDLStmt {
1325  public:
1326  using TableNamePair =
1327  std::pair<std::unique_ptr<std::string>, std::unique_ptr<std::string>>;
1328 
1329  // when created via ddl
1330  RenameTableStmt(const rapidjson::Value& payload);
1331 
1332  // to rename a single table
1333  RenameTableStmt(std::string* tab_name, std::string* new_tab_name);
1334 
1335  // to rename multiple tables
1336  RenameTableStmt(std::list<std::pair<std::string, std::string>> tableNames);
1337 
1338  void execute(const Catalog_Namespace::SessionInfo& session) override;
1339 
1340  private:
1341  std::list<TableNamePair> tablesToRename_;
1342 };
1343 
1344 class RenameColumnStmt : public DDLStmt {
1345  public:
1346  RenameColumnStmt(std::string* tab, std::string* col, std::string* new_col_name)
1347  : table_(tab), column_(col), new_column_name_(new_col_name) {}
1348  void execute(const Catalog_Namespace::SessionInfo& session) override;
1349 
1350  private:
1351  std::unique_ptr<std::string> table_;
1352  std::unique_ptr<std::string> column_;
1353  std::unique_ptr<std::string> new_column_name_;
1354 };
1355 
1356 class AddColumnStmt : public DDLStmt {
1357  public:
1358  AddColumnStmt(std::string* tab, ColumnDef* coldef) : table_(tab), coldef_(coldef) {}
1359  AddColumnStmt(std::string* tab, std::list<ColumnDef*>* coldefs) : table_(tab) {
1360  for (const auto coldef : *coldefs) {
1361  this->coldefs_.emplace_back(coldef);
1362  }
1363  delete coldefs;
1364  }
1365  void execute(const Catalog_Namespace::SessionInfo& session) override;
1367  const TableDescriptor* td);
1368  const std::string* get_table() const { return table_.get(); }
1369 
1370  private:
1371  std::unique_ptr<std::string> table_;
1372  std::unique_ptr<ColumnDef> coldef_;
1373  std::list<std::unique_ptr<ColumnDef>> coldefs_;
1374 };
1375 
1376 class DropColumnStmt : public DDLStmt {
1377  public:
1378  DropColumnStmt(std::string* tab, std::list<std::string*>* cols) : table_(tab) {
1379  for (const auto col : *cols) {
1380  this->columns_.emplace_back(col);
1381  }
1382  delete cols;
1383  }
1384  void execute(const Catalog_Namespace::SessionInfo& session) override;
1385  const std::string* get_table() const { return table_.get(); }
1386 
1387  private:
1388  std::unique_ptr<std::string> table_;
1389  std::list<std::unique_ptr<std::string>> columns_;
1390 };
1391 
1393  public:
1394  AlterTableParamStmt(std::string* tab, NameValueAssign* p) : table_(tab), param_(p) {}
1395  void execute(const Catalog_Namespace::SessionInfo& session) override;
1396 
1397  private:
1398  std::unique_ptr<std::string> table_;
1399  std::unique_ptr<NameValueAssign> param_;
1400 };
1401 
1402 /*
1403  * @type DumpTableStmt
1404  * @brief DUMP TABLE table TO archive_file_path
1405  */
1407  public:
1408  DumpRestoreTableStmtBase(std::string* tab,
1409  std::string* path,
1410  std::list<NameValueAssign*>* options,
1411  const bool is_restore)
1412  : table_(tab), path_(path) {
1413  for (const auto& program : {"tar", "rm", "mkdir", "mv", "cat"}) {
1414  if (boost::process::search_path(program).empty()) {
1415  throw std::runtime_error{"Required program \"" + std::string{program} +
1416  "\" was not found."};
1417  }
1418  }
1419  auto options_deleter = [](std::list<NameValueAssign*>* options) {
1420  for (auto option : *options) {
1421  delete option;
1422  }
1423  delete options;
1424  };
1425 
1426  compression_ = defaultCompression(is_restore);
1427 
1428  std::unique_ptr<std::list<NameValueAssign*>, decltype(options_deleter)> options_ptr(
1429  options, options_deleter);
1430  // specialize decompressor or break on osx bsdtar...
1431  if (options) {
1432  for (const auto option : *options) {
1433  if (boost::iequals(*option->get_name(), "compression")) {
1434  if (const auto str_literal =
1435  dynamic_cast<const StringLiteral*>(option->get_value())) {
1436  compression_ = validateCompression(*str_literal->get_stringval(), is_restore);
1437  } else {
1438  throw std::runtime_error("Compression option must be a string.");
1439  }
1440  } else {
1441  throw std::runtime_error("Invalid WITH option: " + *option->get_name());
1442  }
1443  }
1444  }
1445  }
1446 
1447  DumpRestoreTableStmtBase(const rapidjson::Value& payload, const bool is_restore);
1448 
1449  enum class CompressionType { kGZIP, kLZ4, kNONE };
1450 
1451  // default compression type, based upon available executables
1452  CompressionType defaultCompression(bool is_restore);
1453 
1454  // validate inputted compression string, check for executable
1455  CompressionType validateCompression(const std::string& compression,
1456  const bool is_restore);
1457 
1458  // construct tar option string for compression setting
1459  std::string tarCompressionStr(CompressionType compression, const bool is_restore);
1460 
1461  const std::string* getTable() const { return table_.get(); }
1462  const std::string* getPath() const { return path_.get(); }
1463  const CompressionType getCompression() const { return compression_; }
1464 
1465  protected:
1466  std::unique_ptr<std::string> table_;
1467  std::unique_ptr<std::string> path_; // dump TO file path
1469 };
1470 
1472  public:
1473  DumpTableStmt(std::string* tab, std::string* path, std::list<NameValueAssign*>* options)
1474  : DumpRestoreTableStmtBase(tab, path, options, false) {}
1475  DumpTableStmt(const rapidjson::Value& payload);
1476  void execute(const Catalog_Namespace::SessionInfo& session) override;
1477 };
1478 
1479 /*
1480  * @type RestoreTableStmt
1481  * @brief RESTORE TABLE table FROM archive_file_path
1482  */
1484  public:
1485  RestoreTableStmt(std::string* tab,
1486  std::string* path,
1487  std::list<NameValueAssign*>* options)
1488  : DumpRestoreTableStmtBase(tab, path, options, true) {}
1489  RestoreTableStmt(const rapidjson::Value& payload);
1490  void execute(const Catalog_Namespace::SessionInfo& session) override;
1491 };
1492 
1493 /*
1494  * @type CopyTableStmt
1495  * @brief COPY ... FROM ...
1496  */
1497 class CopyTableStmt : public DDLStmt {
1498  public:
1499  CopyTableStmt(std::string* t, std::string* f, std::list<NameValueAssign*>* o);
1500  CopyTableStmt(const rapidjson::Value& payload);
1501 
1502  void execute(const Catalog_Namespace::SessionInfo& session) override;
1503  void execute(const Catalog_Namespace::SessionInfo& session,
1504  const std::function<std::unique_ptr<import_export::AbstractImporter>(
1506  const TableDescriptor*,
1507  const std::string&,
1508  const import_export::CopyParams&)>& importer_factory);
1509  std::unique_ptr<std::string> return_message;
1510 
1511  std::string& get_table() const {
1512  CHECK(table_);
1513  return *table_;
1514  }
1515 
1516  bool get_success() const { return success_; }
1517 
1519 
1520  void get_deferred_copy_from_payload(std::string& table,
1521  std::string& file_name,
1522  import_export::CopyParams& copy_params,
1523  std::string& partitions) {
1524  table = *table_;
1525  file_name = deferred_copy_from_file_name_;
1526  copy_params = deferred_copy_from_copy_params_;
1527  partitions = deferred_copy_from_partitions_;
1528  was_deferred_copy_from_ = false;
1529  }
1530 
1531  private:
1532  std::unique_ptr<std::string> table_;
1533  std::unique_ptr<std::string> copy_from_source_pattern_;
1534  bool success_;
1535  std::list<std::unique_ptr<NameValueAssign>> options_;
1536 
1541 };
1542 
1543 /*
1544  * @type CreateRoleStmt
1545  * @brief CREATE ROLE statement
1546  */
1547 class CreateRoleStmt : public DDLStmt {
1548  public:
1549  CreateRoleStmt(std::string* r) : role_(r) {}
1550  CreateRoleStmt(const rapidjson::Value& payload);
1551  const std::string& get_role() const { return *role_; }
1552  void execute(const Catalog_Namespace::SessionInfo& session) override;
1553 
1554  private:
1555  std::unique_ptr<std::string> role_;
1556 };
1557 
1558 /*
1559  * @type DropRoleStmt
1560  * @brief DROP ROLE statement
1561  */
1562 class DropRoleStmt : public DDLStmt {
1563  public:
1564  DropRoleStmt(std::string* r, bool e) : role_(r), if_exists_(e) {}
1565  DropRoleStmt(const rapidjson::Value& payload);
1566  const std::string& get_role() const { return *role_; }
1567  void execute(const Catalog_Namespace::SessionInfo& session) override;
1568 
1569  private:
1570  std::unique_ptr<std::string> role_;
1572 };
1573 
1574 inline void parser_slistval_to_vector(std::list<std::string*>* l,
1575  std::vector<std::string>& v) {
1576  CHECK(l);
1577  for (auto str : *l) {
1578  v.push_back(*str);
1579  delete str;
1580  }
1581  delete l;
1582 }
1583 
1584 /*
1585  * @type GrantPrivilegesStmt
1586  * @brief GRANT PRIVILEGES statement
1587  */
1589  public:
1590  GrantPrivilegesStmt(std::list<std::string*>* p,
1591  std::string* t,
1592  std::string* o,
1593  std::list<std::string*>* g)
1594  : type_(t), target_(o) {
1597  }
1598  GrantPrivilegesStmt(const rapidjson::Value& payload);
1599 
1600  const std::vector<std::string>& get_privs() const { return privileges_; }
1601  const std::string& get_object_type() const { return *type_; }
1602  const std::string& get_object() const { return *target_; }
1603  const std::vector<std::string>& get_grantees() const { return grantees_; }
1604  void execute(const Catalog_Namespace::SessionInfo& session) override;
1605 
1606  private:
1607  std::vector<std::string> privileges_;
1608  std::unique_ptr<std::string> type_;
1609  std::unique_ptr<std::string> target_;
1610  std::vector<std::string> grantees_;
1611 };
1612 
1613 /*
1614  * @type RevokePrivilegesStmt
1615  * @brief REVOKE PRIVILEGES statement
1616  */
1618  public:
1619  RevokePrivilegesStmt(std::list<std::string*>* p,
1620  std::string* t,
1621  std::string* o,
1622  std::list<std::string*>* g)
1623  : type_(t), target_(o) {
1626  }
1627  RevokePrivilegesStmt(const rapidjson::Value& payload);
1628 
1629  const std::vector<std::string>& get_privs() const { return privileges_; }
1630  const std::string& get_object_type() const { return *type_; }
1631  const std::string& get_object() const { return *target_; }
1632  const std::vector<std::string>& get_grantees() const { return grantees_; }
1633  void execute(const Catalog_Namespace::SessionInfo& session) override;
1634 
1635  private:
1636  std::vector<std::string> privileges_;
1637  std::unique_ptr<std::string> type_;
1638  std::unique_ptr<std::string> target_;
1639  std::vector<std::string> grantees_;
1640 };
1641 
1642 /*
1643  * @type ShowPrivilegesStmt
1644  * @brief SHOW PRIVILEGES statement
1645  */
1646 class ShowPrivilegesStmt : public DDLStmt {
1647  public:
1648  ShowPrivilegesStmt(std::string* t, std::string* o, std::string* r)
1649  : object_type_(t), object_(o), role_(r) {}
1650  const std::string& get_object_type() const { return *object_type_; }
1651  const std::string& get_object() const { return *object_; }
1652  const std::string& get_role() const { return *role_; }
1653  void execute(const Catalog_Namespace::SessionInfo& session) override;
1654 
1655  private:
1656  std::unique_ptr<std::string> object_type_;
1657  std::unique_ptr<std::string> object_;
1658  std::unique_ptr<std::string> role_;
1659 };
1660 
1661 /*
1662  * @type GrantRoleStmt
1663  * @brief GRANT ROLE statement
1664  */
1665 class GrantRoleStmt : public DDLStmt {
1666  public:
1667  GrantRoleStmt(std::list<std::string*>* r, std::list<std::string*>* g) {
1670  }
1671  GrantRoleStmt(const rapidjson::Value& payload);
1672 
1673  const std::vector<std::string>& get_roles() const { return roles_; }
1674  const std::vector<std::string>& get_grantees() const { return grantees_; }
1675  void execute(const Catalog_Namespace::SessionInfo& session) override;
1676 
1677  private:
1678  std::vector<std::string> roles_;
1679  std::vector<std::string> grantees_;
1680 };
1681 
1682 /*
1683  * @type RevokeRoleStmt
1684  * @brief REVOKE ROLE statement
1685  */
1686 class RevokeRoleStmt : public DDLStmt {
1687  public:
1688  RevokeRoleStmt(std::list<std::string*>* r, std::list<std::string*>* g) {
1691  }
1692  RevokeRoleStmt(const rapidjson::Value& payload);
1693 
1694  const std::vector<std::string>& get_roles() const { return roles_; }
1695  const std::vector<std::string>& get_grantees() const { return grantees_; }
1696  void execute(const Catalog_Namespace::SessionInfo& session) override;
1697 
1698  private:
1699  std::vector<std::string> roles_;
1700  std::vector<std::string> grantees_;
1701 };
1702 
1703 /*
1704  * @type QueryExpr
1705  * @brief query expression
1706  */
1707 class QueryExpr : public Node {
1708  public:
1709  virtual void analyze(const Catalog_Namespace::Catalog& catalog,
1710  Analyzer::Query& query) const = 0;
1711 };
1712 
1713 /*
1714  * @type UnionQuery
1715  * @brief UNION or UNION ALL queries
1716  */
1717 class UnionQuery : public QueryExpr {
1718  public:
1719  UnionQuery(bool u, QueryExpr* l, QueryExpr* r) : is_unionall_(u), left_(l), right_(r) {}
1720  bool get_is_unionall() const { return is_unionall_; }
1721  const QueryExpr* get_left() const { return left_.get(); }
1722  const QueryExpr* get_right() const { return right_.get(); }
1723  void analyze(const Catalog_Namespace::Catalog& catalog,
1724  Analyzer::Query& query) const override;
1725 
1726  private:
1728  std::unique_ptr<QueryExpr> left_;
1729  std::unique_ptr<QueryExpr> right_;
1730 };
1731 
1732 class SelectEntry : public Node {
1733  public:
1734  SelectEntry(Expr* e, std::string* r) : select_expr_(e), alias_(r) {}
1735  const Expr* get_select_expr() const { return select_expr_.get(); }
1736  const std::string* get_alias() const { return alias_.get(); }
1737  std::string to_string() const;
1738 
1739  private:
1740  std::unique_ptr<Expr> select_expr_;
1741  std::unique_ptr<std::string> alias_;
1742 };
1743 
1744 /*
1745  * @type QuerySpec
1746  * @brief a simple query
1747  */
1748 class QuerySpec : public QueryExpr {
1749  public:
1750  QuerySpec(bool d,
1751  std::list<SelectEntry*>* s,
1752  std::list<TableRef*>* f,
1753  Expr* w,
1754  std::list<Expr*>* g,
1755  Expr* h)
1757  if (s) {
1758  for (const auto e : *s) {
1759  select_clause_.emplace_back(e);
1760  }
1761  delete s;
1762  }
1763  CHECK(f);
1764  for (const auto e : *f) {
1765  from_clause_.emplace_back(e);
1766  }
1767  delete f;
1768  if (g) {
1769  for (const auto e : *g) {
1770  groupby_clause_.emplace_back(e);
1771  }
1772  delete g;
1773  }
1774  }
1775  bool get_is_distinct() const { return is_distinct_; }
1776  const std::list<std::unique_ptr<SelectEntry>>& get_select_clause() const {
1777  return select_clause_;
1778  }
1779  const std::list<std::unique_ptr<TableRef>>& get_from_clause() const {
1780  return from_clause_;
1781  }
1782  const Expr* get_where_clause() const { return where_clause_.get(); }
1783  const std::list<std::unique_ptr<Expr>>& get_groupby_clause() const {
1784  return groupby_clause_;
1785  }
1786  const Expr* get_having_clause() const { return having_clause_.get(); }
1787  void analyze(const Catalog_Namespace::Catalog& catalog,
1788  Analyzer::Query& query) const override;
1789  std::string to_string() const;
1790 
1791  private:
1793  std::list<std::unique_ptr<SelectEntry>> select_clause_; /* nullptr means SELECT * */
1794  std::list<std::unique_ptr<TableRef>> from_clause_;
1795  std::unique_ptr<Expr> where_clause_;
1796  std::list<std::unique_ptr<Expr>> groupby_clause_;
1797  std::unique_ptr<Expr> having_clause_;
1798  void analyze_from_clause(const Catalog_Namespace::Catalog& catalog,
1799  Analyzer::Query& query) const;
1801  Analyzer::Query& query) const;
1803  Analyzer::Query& query) const;
1804  void analyze_group_by(const Catalog_Namespace::Catalog& catalog,
1805  Analyzer::Query& query) const;
1807  Analyzer::Query& query) const;
1808 };
1809 
1810 /*
1811  * @type OrderSpec
1812  * @brief order spec for a column in ORDER BY clause
1813  */
1814 class OrderSpec : public Node {
1815  public:
1816  OrderSpec(int n, ColumnRef* c, bool d, bool f)
1817  : colno_(n), column_(c), is_desc_(d), nulls_first_(f) {}
1818  int get_colno() const { return colno_; }
1819  const ColumnRef* get_column() const { return column_.get(); }
1820  bool get_is_desc() const { return is_desc_; }
1821  bool get_nulls_first() const { return nulls_first_; }
1822 
1823  private:
1824  int colno_; /* 0 means use column name */
1825  std::unique_ptr<ColumnRef> column_;
1826  bool is_desc_;
1828 };
1829 
1830 /*
1831  * @type SelectStmt
1832  * @brief SELECT statement
1833  */
1834 class SelectStmt : public DMLStmt {
1835  public:
1836  SelectStmt(QueryExpr* q, std::list<OrderSpec*>* o, int64_t l, int64_t f)
1837  : query_expr_(q), limit_(l), offset_(f) {
1838  if (o) {
1839  for (const auto e : *o) {
1840  orderby_clause_.emplace_back(e);
1841  }
1842  delete o;
1843  }
1844  }
1845  const QueryExpr* get_query_expr() const { return query_expr_.get(); }
1846  const std::list<std::unique_ptr<OrderSpec>>& get_orderby_clause() const {
1847  return orderby_clause_;
1848  }
1849  void analyze(const Catalog_Namespace::Catalog& catalog,
1850  Analyzer::Query& query) const override;
1851 
1852  private:
1853  std::unique_ptr<QueryExpr> query_expr_;
1854  std::list<std::unique_ptr<OrderSpec>> orderby_clause_;
1855  int64_t limit_;
1856  int64_t offset_;
1857 };
1858 
1859 /*
1860  * @type ShowCreateTableStmt
1861  * @brief shows create table statement to create table
1862  */
1864  public:
1865  ShowCreateTableStmt(std::string* tab) : table_(tab) {}
1866  ShowCreateTableStmt(const rapidjson::Value& payload);
1867 
1868  std::string getCreateStmt() { return create_stmt_; }
1869  void execute(const Catalog_Namespace::SessionInfo& session) override;
1870 
1871  private:
1872  std::unique_ptr<std::string> table_;
1873  std::string create_stmt_;
1874 };
1875 
1876 /*
1877  * @type ExportQueryStmt
1878  * @brief COPY ( query ) TO file ...
1879  */
1880 class ExportQueryStmt : public DDLStmt {
1881  public:
1882  ExportQueryStmt(std::string* q, std::string* p, std::list<NameValueAssign*>* o)
1883  : select_stmt_(q), file_path_(p) {
1884  if (o) {
1885  for (const auto e : *o) {
1886  options_.emplace_back(e);
1887  }
1888  delete o;
1889  }
1890  }
1891  ExportQueryStmt(const rapidjson::Value& payload);
1892  void execute(const Catalog_Namespace::SessionInfo& session) override;
1893  const std::string get_select_stmt() const { return *select_stmt_; }
1894 
1896 
1897  private:
1898  std::unique_ptr<std::string> select_stmt_;
1899  std::unique_ptr<std::string> file_path_;
1900  std::list<std::unique_ptr<NameValueAssign>> options_;
1901 
1902  void parseOptions(import_export::CopyParams& copy_params,
1903  // @TODO(se) move rest to CopyParams when we have a Thrift endpoint
1905  std::string& layer_name,
1908 };
1909 
1910 /*
1911  * @type CreateViewStmt
1912  * @brief CREATE VIEW statement
1913  */
1914 class CreateViewStmt : public DDLStmt {
1915  public:
1916  CreateViewStmt(const std::string& view_name,
1917  const std::string& select_query,
1918  const bool if_not_exists)
1919  : view_name_(view_name)
1920  , select_query_(select_query)
1921  , if_not_exists_(if_not_exists) {}
1922 
1923  CreateViewStmt(const rapidjson::Value& payload);
1924 
1925  const std::string& get_view_name() const { return view_name_; }
1926  const std::string& get_select_query() const { return select_query_; }
1927  void execute(const Catalog_Namespace::SessionInfo& session) override;
1928 
1929  private:
1930  std::string view_name_;
1931  std::string select_query_;
1933 };
1934 
1935 /*
1936  * @type DropViewStmt
1937  * @brief DROP VIEW statement
1938  */
1939 class DropViewStmt : public DDLStmt {
1940  public:
1941  DropViewStmt(std::string* v, bool i) : view_name_(v), if_exists_(i) {}
1942  DropViewStmt(const rapidjson::Value& payload);
1943 
1944  const std::string* get_view_name() const { return view_name_.get(); }
1945  void execute(const Catalog_Namespace::SessionInfo& session) override;
1946 
1947  private:
1948  std::unique_ptr<std::string> view_name_;
1950 };
1951 
1952 /*
1953  * @type CreateDBStmt
1954  * @brief CREATE DATABASE statement
1955  */
1956 class CreateDBStmt : public DDLStmt {
1957  public:
1958  CreateDBStmt(const rapidjson::Value& payload);
1959 
1960  CreateDBStmt(std::string* n, std::list<NameValueAssign*>* l, const bool if_not_exists)
1961  : db_name_(n), if_not_exists_(if_not_exists) {
1962  if (l) {
1963  for (const auto e : *l) {
1964  options_.emplace_back(e);
1965  }
1966  delete l;
1967  }
1968  }
1969  void execute(const Catalog_Namespace::SessionInfo& session) override;
1970 
1971  private:
1972  std::unique_ptr<std::string> db_name_;
1973  std::list<std::unique_ptr<NameValueAssign>> options_;
1975 };
1976 
1977 /*
1978  * @type DropDBStmt
1979  * @brief DROP DATABASE statement
1980  */
1981 class DropDBStmt : public DDLStmt {
1982  public:
1983  DropDBStmt(const rapidjson::Value& payload);
1984 
1985  explicit DropDBStmt(std::string* n, bool i) : db_name_(n), if_exists_(i) {}
1986  auto const& getDatabaseName() { return db_name_; }
1987  void execute(const Catalog_Namespace::SessionInfo& session) override;
1988 
1989  private:
1990  std::unique_ptr<std::string> db_name_;
1992 };
1993 
1994 /*
1995  * @type CreateUserStmt
1996  * @brief CREATE USER statement
1997  */
1998 class CreateUserStmt : public DDLStmt {
1999  public:
2000  CreateUserStmt(const rapidjson::Value& payload);
2001  CreateUserStmt(std::string* n, std::list<NameValueAssign*>* l) : user_name_(n) {
2002  if (l) {
2003  for (const auto e : *l) {
2004  options_.emplace_back(e);
2005  }
2006  delete l;
2007  }
2008  }
2009  void execute(const Catalog_Namespace::SessionInfo& session) override;
2010 
2011  private:
2012  std::unique_ptr<std::string> user_name_;
2013  std::list<std::unique_ptr<NameValueAssign>> options_;
2014 };
2015 
2016 /*
2017  * @type AlterUserStmt
2018  * @brief ALTER USER statement
2019  */
2020 class AlterUserStmt : public DDLStmt {
2021  public:
2022  AlterUserStmt(const rapidjson::Value& payload);
2023  AlterUserStmt(std::string* n, std::list<NameValueAssign*>* l) : user_name_(n) {
2024  if (l) {
2025  for (const auto e : *l) {
2026  options_.emplace_back(e);
2027  }
2028  delete l;
2029  }
2030  }
2031  void execute(const Catalog_Namespace::SessionInfo& session) override;
2032 
2033  private:
2034  std::unique_ptr<std::string> user_name_;
2035  std::list<std::unique_ptr<NameValueAssign>> options_;
2036 };
2037 
2038 /*
2039  * @type DropUserStmt
2040  * @brief DROP USER statement
2041  */
2042 class DropUserStmt : public DDLStmt {
2043  public:
2044  DropUserStmt(const rapidjson::Value& payload);
2045  DropUserStmt(std::string* n, bool e) : user_name_(n), if_exists_(e) {}
2046  auto const& getUserName() { return user_name_; }
2047  void execute(const Catalog_Namespace::SessionInfo& session) override;
2048 
2049  private:
2050  std::unique_ptr<std::string> user_name_;
2052 };
2053 
2054 /*
2055  * @type InsertStmt
2056  * @brief super class for INSERT statements
2057  */
2058 class InsertStmt : public DMLStmt {
2059  public:
2060  InsertStmt(std::string* t, std::list<std::string*>* c) : table_(t) {
2061  if (c) {
2062  for (const auto e : *c) {
2063  column_list_.emplace_back(e);
2064  }
2065  delete c;
2066  }
2067  }
2068  const std::string* get_table() const { return table_.get(); }
2069  const std::list<std::unique_ptr<std::string>>& get_column_list() const {
2070  return column_list_;
2071  }
2072  void analyze(const Catalog_Namespace::Catalog& catalog,
2073  Analyzer::Query& query) const override = 0;
2074 
2075  protected:
2076  std::unique_ptr<std::string> table_;
2077  std::list<std::unique_ptr<std::string>> column_list_;
2078 };
2079 
2080 class ValuesList : public Node {
2081  public:
2082  ValuesList() = default;
2083  ValuesList(std::list<Expr*>* values) {
2084  CHECK(values);
2085  for (const auto v : *values) {
2086  value_list.emplace_back(v);
2087  }
2088  delete values;
2089  }
2090 
2091  void push_back(Expr* value) { value_list.emplace_back(value); }
2092 
2093  const std::list<std::unique_ptr<Expr>>& get_value_list() const { return value_list; }
2094 
2095  private:
2096  std::list<std::unique_ptr<Expr>> value_list;
2097 };
2098 
2099 /*
2100  * @type InsertValuesStmt
2101  * @brief INSERT INTO ... VALUES ...
2102  */
2104  public:
2105  InsertValuesStmt(const rapidjson::Value& payload);
2106  InsertValuesStmt(std::string* t, std::list<std::string*>* c, std::list<Expr*>* v)
2107  : InsertStmt(t, c) {
2108  UNREACHABLE() << "Legacy inserts should not be called anymore";
2109  }
2110 
2111  const std::vector<std::unique_ptr<ValuesList>>& get_value_lists() const {
2112  return values_lists_;
2113  }
2114 
2115  void analyze(const Catalog_Namespace::Catalog& catalog,
2116  Analyzer::Query& query) const override;
2117 
2118  void execute(const Catalog_Namespace::SessionInfo& session);
2119 
2121 
2122  private:
2123  std::vector<std::unique_ptr<ValuesList>> values_lists_;
2124 };
2125 
2126 /*
2127  * @type Assignment
2128  * @brief assignment in UPDATE statement
2129  */
2130 class Assignment : public Node {
2131  public:
2132  Assignment(std::string* c, Expr* a) : column_(c), assignment_(a) {}
2133  const std::string* get_column() const { return column_.get(); }
2134  const Expr* get_assignment() const { return assignment_.get(); }
2135 
2136  private:
2137  std::unique_ptr<std::string> column_;
2138  std::unique_ptr<Expr> assignment_;
2139 };
2140 
2141 /*
2142  * @type UpdateStmt
2143  * @brief UPDATE statement
2144  */
2145 class UpdateStmt : public DMLStmt {
2146  public:
2147  UpdateStmt(std::string* t, std::list<Assignment*>* a, Expr* w)
2148  : table_(t), where_clause_(w) {
2149  CHECK(a);
2150  for (const auto e : *a) {
2151  assignment_list_.emplace_back(e);
2152  }
2153  delete a;
2154  }
2155  const std::string* get_table() const { return table_.get(); }
2156  const std::list<std::unique_ptr<Assignment>>& get_assignment_list() const {
2157  return assignment_list_;
2158  }
2159  const Expr* get_where_clause() const { return where_clause_.get(); }
2160  void analyze(const Catalog_Namespace::Catalog& catalog,
2161  Analyzer::Query& query) const override;
2162 
2163  private:
2164  std::unique_ptr<std::string> table_;
2165  std::list<std::unique_ptr<Assignment>> assignment_list_;
2166  std::unique_ptr<Expr> where_clause_;
2167 };
2168 
2169 /*
2170  * @type DeleteStmt
2171  * @brief DELETE statement
2172  */
2173 class DeleteStmt : public DMLStmt {
2174  public:
2175  DeleteStmt(std::string* t, Expr* w) : table_(t), where_clause_(w) {}
2176  const std::string* get_table() const { return table_.get(); }
2177  const Expr* get_where_clause() const { return where_clause_.get(); }
2178  void analyze(const Catalog_Namespace::Catalog& catalog,
2179  Analyzer::Query& query) const override;
2180 
2181  private:
2182  std::unique_ptr<std::string> table_;
2183  std::unique_ptr<Expr> where_clause_;
2184 };
2185 
2186 template <typename LITERAL_TYPE>
2188 
2189 template <>
2191  template <typename T>
2192  decltype(auto) operator()(T t) {
2193  const std::string property_name(boost::to_upper_copy<std::string>(*t->get_name()));
2194  if (!dynamic_cast<const IntLiteral*>(t->get_value())) {
2195  throw std::runtime_error(property_name + " must be an integer literal.");
2196  }
2197  const auto val = static_cast<const IntLiteral*>(t->get_value())->get_intval();
2198  if (val <= 0) {
2199  throw std::runtime_error(property_name + " must be a positive number.");
2200  }
2201  return val;
2202  }
2203 };
2204 
2206  template <typename T>
2207  decltype(auto) operator()(T t) {
2208  const std::string property_name(boost::to_upper_copy<std::string>(*t->get_name()));
2209  if (!dynamic_cast<const IntLiteral*>(t->get_value())) {
2210  throw std::runtime_error(property_name + " must be an integer literal.");
2211  }
2212  const auto val = static_cast<const IntLiteral*>(t->get_value())->get_intval();
2213  if (val < 0) {
2214  throw std::runtime_error(property_name + " must be greater than or equal to 0.");
2215  }
2216  return val;
2217  }
2218 };
2219 
2220 template <>
2222  template <typename T>
2223  decltype(auto) operator()(T t) {
2224  const auto val = static_cast<const StringLiteral*>(t->get_value())->get_stringval();
2225  CHECK(val);
2226  const auto val_upper = boost::to_upper_copy<std::string>(*val);
2227  return val_upper;
2228  }
2229 };
2230 
2232  template <typename T>
2233  decltype(auto) operator()(T t) {
2234  const auto val = static_cast<const StringLiteral*>(t->get_value())->get_stringval();
2235  CHECK(val);
2236  return *val;
2237  }
2238 };
2239 
2240 template <typename T>
2241 struct ShouldInvalidateSessionsByDB : public std::false_type {};
2242 template <typename T>
2243 struct ShouldInvalidateSessionsByUser : public std::false_type {};
2244 
2245 template <>
2246 struct ShouldInvalidateSessionsByDB<DropDBStmt> : public std::true_type {};
2247 template <>
2248 struct ShouldInvalidateSessionsByUser<DropUserStmt> : public std::true_type {};
2249 template <>
2250 struct ShouldInvalidateSessionsByDB<RenameDBStmt> : public std::true_type {};
2251 template <>
2252 struct ShouldInvalidateSessionsByUser<RenameUserStmt> : public std::true_type {};
2253 
2260 std::unique_ptr<Parser::Stmt> create_stmt_for_query(
2261  const std::string& queryStr,
2262  const Catalog_Namespace::SessionInfo& session_info);
2263 
2264 std::unique_ptr<Parser::Stmt> create_stmt_for_json(const std::string& query_json);
2265 
2267  const std::string& query_json,
2268  std::shared_ptr<Catalog_Namespace::SessionInfo const> session_ptr);
2269 
2270 } // namespace Parser
2271 
2272 #endif // PARSERNODE_H_
DEVICE auto upper_bound(ARGS &&...args)
Definition: gpu_enabled.h:123
std::unique_ptr< Expr > expr2_
Definition: ParserNode.h:693
virtual void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const =0
const ColumnConstraintDef * get_column_constraint() const
Definition: ParserNode.h:829
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:301
DumpRestoreTableStmtBase(std::string *tab, std::string *path, std::list< NameValueAssign * > *options, const bool is_restore)
Definition: ParserNode.h:1408
ExistsExpr(QuerySpec *q)
Definition: ParserNode.h:612
const std::string foreign_column_
Definition: ParserNode.h:939
std::string & get_table() const
Definition: ParserNode.h:1511
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:129
QuerySpec(bool d, std::list< SelectEntry * > *s, std::list< TableRef * > *f, Expr *w, std::list< Expr * > *g, Expr *h)
Definition: ParserNode.h:1750
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)
std::unique_ptr< SubqueryExpr > subquery_
Definition: ParserNode.h:396
std::unique_ptr< std::string > username_
Definition: ParserNode.h:1320
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 >, const Executor *executor=nullptr)
std::vector< std::string > privileges_
Definition: ParserNode.h:1607
const Literal * get_value() const
Definition: ParserNode.h:964
LikelihoodExpr(bool n, Expr *a, float l)
Definition: ParserNode.h:587
CreateDBStmt(const rapidjson::Value &payload)
const std::string & get_column() const
Definition: ParserNode.h:950
const std::string * get_table() const
Definition: ParserNode.h:2176
const Expr * get_arg() const
Definition: ParserNode.h:589
std::unique_ptr< std::string > foreign_table_
Definition: ParserNode.h:805
IntLiteral(int64_t i)
Definition: ParserNode.h:155
bool get_is_desc() const
Definition: ParserNode.h:1820
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:497
std::unique_ptr< Expr > where_clause_
Definition: ParserNode.h:2183
RevokePrivilegesStmt(std::list< std::string * > *p, std::string *t, std::string *o, std::list< std::string * > *g)
Definition: ParserNode.h:1619
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
void get_deferred_copy_from_payload(std::string &table, std::string &file_name, import_export::CopyParams &copy_params, std::string &partitions)
Definition: ParserNode.h:1520
GrantPrivilegesStmt(std::list< std::string * > *p, std::string *t, std::string *o, std::list< std::string * > *g)
Definition: ParserNode.h:1590
std::unique_ptr< Expr > right_
Definition: ParserNode.h:322
ExportQueryStmt(std::string *q, std::string *p, std::list< NameValueAssign * > *o)
Definition: ParserNode.h:1882
ValuesList()=default
RestoreTableStmt(std::string *tab, std::string *path, std::list< NameValueAssign * > *options)
Definition: ParserNode.h:1485
const std::string * get_table() const
Definition: ParserNode.h:1204
std::unique_ptr< std::string > stringval_
Definition: ParserNode.h:146
std::string to_string() const override
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1307
std::unique_ptr< std::string > view_name_
Definition: ParserNode.h:1948
SQLType * get_column_type() const
Definition: ParserNode.h:827
float get_likelihood() const
Definition: ParserNode.h:590
const std::string * get_table() const override
Definition: ParserNode.h:1009
std::list< std::unique_ptr< NameValueAssign > > storage_options_
Definition: ParserNode.h:1117
void setColumnDescriptor(ColumnDescriptor &cd, const ColumnDef *coldef)
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string * get_table() const
Definition: ParserNode.h:2068
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1990
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:114
std::unique_ptr< Expr > assignment_
Definition: ParserNode.h:2138
std::unique_ptr< std::string > target_
Definition: ParserNode.h:1609
const std::string * get_table() const
Definition: ParserNode.h:632
const std::string * get_column() const
Definition: ParserNode.h:2133
std::unique_ptr< std::string > user_name_
Definition: ParserNode.h:2034
SQLTypes
Definition: sqltypes.h:38
std::unique_ptr< Expr > check_condition_
Definition: ParserNode.h:915
void executeDryRun(const Catalog_Namespace::SessionInfo &session, TableDescriptor &td, std::list< ColumnDescriptor > &columns, std::vector< SharedDictionaryDef > &shared_dict_defs)
std::unique_ptr< Expr > having_clause_
Definition: ParserNode.h:1797
const Expr * get_arg() const
Definition: ParserNode.h:432
SqlType(SQLTypes type, int param1, int param2, bool is_array, int array_size)
Definition: DdlUtils.cpp:38
void parseOptions(import_export::CopyParams &copy_params, import_export::QueryExporter::FileType &file_type, std::string &layer_name, import_export::QueryExporter::FileCompression &file_compression, import_export::QueryExporter::ArrayNullHandling &array_null_handling)
void execute(const Catalog_Namespace::SessionInfo &session) override
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< std::string > copy_from_source_pattern_
Definition: ParserNode.h:1533
CreateTableStmt(std::string *tab, const std::string *storage, std::list< TableElement * > *table_elems, bool is_temporary, bool if_not_exists, std::list< NameValueAssign * > *s)
Definition: ParserNode.h:987
RenameUserStmt(const rapidjson::Value &payload)
std::unique_ptr< Expr > select_expr_
Definition: ParserNode.h:1740
std::list< std::unique_ptr< Expr > > groupby_clause_
Definition: ParserNode.h:1796
virtual const std::list< std::unique_ptr< TableElement > > & get_table_element_list() const =0
const std::list< std::unique_ptr< TableElement > > & get_table_element_list() const override
Definition: ParserNode.h:1106
std::list< std::unique_ptr< TableElement > > table_element_list_
Definition: ParserNode.h:1023
CastExpr(Expr *a, SQLType *t)
Definition: ParserNode.h:671
float get_floatval() const
Definition: ParserNode.h:198
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:2035
DropViewStmt(std::string *v, bool i)
Definition: ParserNode.h:1941
size_t getOuterFragmentCount(QueryStateProxy, std::string &sql_query_string) override
std::unique_ptr< std::string > table_
Definition: ParserNode.h:641
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:358
std::unique_ptr< Expr > lower_
Definition: ParserNode.h:444
FixedPtLiteral(std::string *n)
Definition: ParserNode.h:176
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:602
SQLType(SQLTypes t, int p1)
Definition: ParserNode.h:75
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1274
const std::string getType() const
Definition: ParserNode.h:1285
std::unique_ptr< std::string > fixedptval_
Definition: ParserNode.h:188
SQLQualifier
Definition: sqldefs.h:71
const std::string & get_role() const
Definition: ParserNode.h:1566
static std::shared_ptr< Analyzer::Expr > analyzeValue(const int64_t intval)
Definition: ParserNode.cpp:162
const Expr * get_pattern_string() const
Definition: ParserNode.h:533
const std::string column_
Definition: ParserNode.h:937
std::string to_string() const
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1242
std::unique_ptr< std::string > return_message
Definition: ParserNode.h:1509
RenameDBStmt(const rapidjson::Value &payload)
StringLiteral(std::string *s)
Definition: ParserNode.h:135
const Expr * get_select_expr() const
Definition: ParserNode.h:1735
DoubleLiteral(double d)
Definition: ParserNode.h:217
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:420
SQLOps
Definition: sqldefs.h:29
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
const std::string getTableName() const
Definition: ParserNode.h:1260
DropUserStmt(std::string *n, bool e)
Definition: ParserNode.h:2045
std::vector< std::string > grantees_
Definition: ParserNode.h:1700
InsertStmt(std::string *t, std::list< std::string * > *c)
Definition: ParserNode.h:2060
std::string to_string() const override
void populateData(QueryStateProxy, const TableDescriptor *td, bool validate_table, bool for_CTAS=false)
std::string to_string() const override
Definition: ParserNode.h:676
std::string to_string() const override
std::unique_ptr< Expr > left_
Definition: ParserNode.h:321
InsertValuesStmt(std::string *t, std::list< std::string * > *c, std::list< Expr * > *v)
Definition: ParserNode.h:2106
std::unique_ptr< Expr > target_value_
Definition: ParserNode.h:575
const Expr * get_check_condition() const
Definition: ParserNode.h:795
UpdateStmt(std::string *t, std::list< Assignment * > *a, Expr *w)
Definition: ParserNode.h:2147
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:243
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const 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, const Executor *executor=nullptr)
Definition: ParserNode.cpp:371
const Expr * get_target_value() const
Definition: ParserNode.h:559
std::unique_ptr< Expr > upper_bound_
Definition: ParserNode.h:577
const std::string * get_table() const
Definition: ParserNode.h:1222
std::string to_string() const override
Definition: ParserNode.h:185
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:2013
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:681
bool get_is_not() const
Definition: ParserNode.h:496
#define UNREACHABLE()
Definition: Logger.h:267
const std::list< std::unique_ptr< OrderSpec > > & get_orderby_clause() const
Definition: ParserNode.h:1846
AddColumnStmt(std::string *tab, std::list< ColumnDef * > *coldefs)
Definition: ParserNode.h:1359
std::unique_ptr< std::string > table_
Definition: ParserNode.h:2182
std::string to_string() const override=0
std::unique_ptr< std::string > column_name_
Definition: ParserNode.h:834
const std::list< std::unique_ptr< std::string > > & get_foreign_column_list() const
Definition: ParserNode.h:895
std::unique_ptr< std::string > new_username_
Definition: ParserNode.h:1321
DropColumnStmt(std::string *tab, std::list< std::string * > *cols)
Definition: ParserNode.h:1378
std::unique_ptr< std::string > file_path_
Definition: ParserNode.h:1899
void execute(const Catalog_Namespace::SessionInfo &session) override
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string & get_foreign_table() const
Definition: ParserNode.h:932
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:216
std::string tarCompressionStr(CompressionType compression, const bool is_restore)
SQLOps get_optype() const
Definition: ParserNode.h:303
Expr * get_arg() const
Definition: ParserNode.h:656
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:229
std::string deferred_copy_from_partitions_
Definition: ParserNode.h:1540
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override=0
std::string to_string() const override
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1574
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:207
OptimizeTableStmt(std::string *table, std::list< NameValueAssign * > *o)
Definition: ParserNode.h:1247
const Literal * get_defaultval() const
Definition: ParserNode.h:794
std::unique_ptr< std::string > column_
Definition: ParserNode.h:1352
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:532
std::unique_ptr< QuerySpec > query_
Definition: ParserNode.h:621
CaseExpr(std::list< ExprPair * > *w, Expr *e)
Definition: ParserNode.h:698
ShardKeyDef(const std::string &column)
Definition: ParserNode.h:948
CreateDBStmt(std::string *n, std::list< NameValueAssign * > *l, const bool if_not_exists)
Definition: ParserNode.h:1960
std::unique_ptr< std::string > user_name_
Definition: ParserNode.h:2012
QueryConnector * leafs_connector_
Definition: ParserNode.h:1895
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1114
static void check_pattern_expr(const std::string &pattern_str, char escape_char)
Definition: ParserNode.cpp:738
std::unique_ptr< SQLType > column_type_
Definition: ParserNode.h:835
std::list< std::unique_ptr< Assignment > > assignment_list_
Definition: ParserNode.h:2165
const Expr * get_where_clause() const
Definition: ParserNode.h:2159
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::vector< std::string > & get_roles() const
Definition: ParserNode.h:1673
std::string to_string() const override
void rollback(const Catalog_Namespace::SessionInfo &parent_session_info, int tableId) override
Definition: ParserNode.h:1074
bool get_is_unionall() const
Definition: ParserNode.h:1720
Fragmenter_Namespace::InsertDataLoader::InsertConnector * leafs_connector_
Definition: ParserNode.h:2120
std::unique_ptr< std::string > table_
Definition: ParserNode.h:2164
SQLType(SQLTypes t, int p1, int p2, bool a)
Definition: ParserNode.h:76
AlterTableParamStmt(std::string *tab, NameValueAssign *p)
Definition: ParserNode.h:1394
const std::string & get_column() const
Definition: ParserNode.h:930
TableRef(std::string *t, std::string *r)
Definition: ParserNode.h:728
std::unique_ptr< SQLType > target_type_
Definition: ParserNode.h:682
const std::string * get_table() const
Definition: ParserNode.h:2155
const Expr * get_arg() const
Definition: ParserNode.h:477
AggregatedResult query(QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool validate_only, bool allow_interrupt)
DropDBStmt(std::string *n, bool i)
Definition: ParserNode.h:1985
const Expr * get_arg() const
Definition: ParserNode.h:497
SQLType(SQLTypes t, bool a, int array_size)
Definition: ParserNode.h:79
std::unique_ptr< Expr > else_expr_
Definition: ParserNode.h:718
std::list< std::unique_ptr< Expr > > value_list_
Definition: ParserNode.h:290
static bool translate_to_like_pattern(std::string &pattern_str, char escape_char)
Definition: ParserNode.cpp:744
void execute(const Catalog_Namespace::SessionInfo &session) override
void execute_stmt_for_json(const std::string &query_json, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
const std::list< std::unique_ptr< Expr > > & get_value_list() const
Definition: ParserNode.h:412
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1209
ColumnConstraintDef(bool n, bool u, bool p, Literal *d)
Definition: ParserNode.h:781
bool get_is_not() const
Definition: ParserNode.h:368
ColumnRef(std::string *n1, std::string *n2)
Definition: ParserNode.h:631
SelectStmt(QueryExpr *q, std::list< OrderSpec * > *o, int64_t l, int64_t f)
Definition: ParserNode.h:1836
void execute(const Catalog_Namespace::SessionInfo &session) override
constexpr double f
Definition: Utm.h:31
SQLType(SQLTypes t)
Definition: ParserNode.h:74
bool was_deferred_copy_from() const
Definition: ParserNode.h:1518
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1398
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:514
std::unique_ptr< std::string > table_
Definition: ParserNode.h:2076
std::unique_ptr< std::string > name_
Definition: ParserNode.h:664
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string & get_object_type() const
Definition: ParserNode.h:1601
CompressionType defaultCompression(bool is_restore)
const Expr * get_escape_string() const
Definition: ParserNode.h:499
std::unique_ptr< CompressDef > compression_
Definition: ParserNode.h:836
const Expr * get_lower_bound() const
Definition: ParserNode.h:560
IsNullExpr(bool n, Expr *a)
Definition: ParserNode.h:348
const std::string & get_object() const
Definition: ParserNode.h:1651
auto const & getPreviousDatabaseName()
Definition: ParserNode.h:1301
std::unique_ptr< Expr > escape_string_
Definition: ParserNode.h:516
constexpr double a
Definition: Utm.h:32
void execute(const Catalog_Namespace::SessionInfo &session) override
void analyze_having_clause(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1306
std::string to_string() const override
const Expr * get_like_string() const
Definition: ParserNode.h:498
const std::string get_select_stmt() const
Definition: ParserNode.h:1893
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1632
std::unique_ptr< Expr > expr1_
Definition: ParserNode.h:692
void execute(const Catalog_Namespace::SessionInfo &session) override
const Expr * get_arg() const
Definition: ParserNode.h:369
std::list< std::unique_ptr< std::string > > columns_
Definition: ParserNode.h:1389
std::string to_string() const override
Definition: ParserNode.h:143
std::vector< std::string > roles_
Definition: ParserNode.h:1699
const std::string & get_role() const
Definition: ParserNode.h:1652
bool get_calc_encoded_length() const
Definition: ParserNode.h:457
const SubqueryExpr * get_subquery() const
Definition: ParserNode.h:388
const std::list< std::unique_ptr< SelectEntry > > & get_select_clause() const
Definition: ParserNode.h:1776
const std::string * getPath() const
Definition: ParserNode.h:1462
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1371
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:136
std::string to_string() const override
Definition: ParserNode.h:265
const std::string * getTable() const
Definition: ParserNode.h:1461
InSubquery(bool n, Expr *a, SubqueryExpr *q)
Definition: ParserNode.h:387
CreateRoleStmt(std::string *r)
Definition: ParserNode.h:1549
const std::string * get_table_name() const
Definition: ParserNode.h:729
bool get_success() const
Definition: ParserNode.h:1516
const ColumnRef * get_column() const
Definition: ParserNode.h:1819
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:1973
const Expr * get_right() const
Definition: ParserNode.h:305
const std::string * get_stringval() const
Definition: ParserNode.h:136
std::unique_ptr< std::string > select_stmt_
Definition: ParserNode.h:1898
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:879
CONSTEXPR DEVICE bool is_null(const T &value)
Definition: ParserNode.h:1732
std::string to_string() const override
Definition: ParserNode.h:243
ExprPair(Expr *e1, Expr *e2)
Definition: ParserNode.h:687
const std::string * get_fixedptval() const
Definition: ParserNode.h:177
std::vector< std::string > roles_
Definition: ParserNode.h:1678
const std::string & get_role() const
Definition: ParserNode.h:1551
std::vector< std::string > grantees_
Definition: ParserNode.h:1610
std::list< std::unique_ptr< NameValueAssign > > storage_options_
Definition: ParserNode.h:1189
bool get_is_not() const
Definition: ParserNode.h:531
ForeignKeyDef(std::list< std::string * > *cl, std::string *t, std::list< std::string * > *fcl)
Definition: ParserNode.h:877
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1695
std::list< std::unique_ptr< ColumnDef > > coldefs_
Definition: ParserNode.h:1373
std::unique_ptr< std::string > type_
Definition: ParserNode.h:1290
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:155
std::unique_ptr< Parser::Stmt > create_stmt_for_json(const std::string &query_json)
std::list< TableNamePair > tablesToRename_
Definition: ParserNode.h:1341
const std::list< std::unique_ptr< std::string > > & get_column_list() const
Definition: ParserNode.h:2069
const std::list< std::unique_ptr< Expr > > & get_value_list() const
Definition: ParserNode.h:282
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
void checkpoint(const Catalog_Namespace::SessionInfo &parent_session_info, int tableId) override
Definition: ParserNode.h:1070
SharedDictionaryDef(const std::string &column, const std::string &foreign_table, const std::string foreign_column)
Definition: ParserNode.h:925
const Expr * get_upper_bound() const
Definition: ParserNode.h:561
std::unique_ptr< std::string > role_
Definition: ParserNode.h:1555
const Expr * get_check_condition() const
Definition: ParserNode.h:912
const QueryExpr * get_left() const
Definition: ParserNode.h:1721
virtual const std::string * get_table() const =0
const std::string & get_foreign_column() const
Definition: ParserNode.h:934
std::unique_ptr< std::string > type_
Definition: ParserNode.h:1637
void analyze_where_clause(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string * get_table() const
Definition: ParserNode.h:1238
auto const & getUserName()
Definition: ParserNode.h:2046
int64_t get_intval() const
Definition: ParserNode.h:156
void execute(const Catalog_Namespace::SessionInfo &session) override
const Expr * get_upper() const
Definition: ParserNode.h:434
std::unique_ptr< ColumnRef > column_
Definition: ParserNode.h:1825
std::string deferred_copy_from_file_name_
Definition: ParserNode.h:1538
const std::list< std::unique_ptr< std::string > > & get_column_list() const
Definition: ParserNode.h:862
const Expr * get_where_clause() const
Definition: ParserNode.h:2177
const std::list< std::unique_ptr< Expr > > & get_value_list() const
Definition: ParserNode.h:2093
ColumnDef(std::string *c, SQLType *t, CompressDef *cp, ColumnConstraintDef *cc)
Definition: ParserNode.h:824
void execute(const Catalog_Namespace::SessionInfo &session) override
std::string select_query_
Definition: ParserNode.h:1931
RevokeRoleStmt(std::list< std::string * > *r, std::list< std::string * > *g)
Definition: ParserNode.h:1688
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< ColumnConstraintDef > column_constraint_
Definition: ParserNode.h:837
const std::string * get_column_name() const
Definition: ParserNode.h:826
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string & get_select_query() const
Definition: ParserNode.h:1926
DropRoleStmt(std::string *r, bool e)
Definition: ParserNode.h:1564
const Expr * get_having_clause() const
Definition: ParserNode.h:1786
std::string to_string() const override
FunctionRef(std::string *n, Expr *a)
Definition: ParserNode.h:652
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:666
std::unique_ptr< NameValueAssign > param_
Definition: ParserNode.h:1399
RenameTableStmt(const rapidjson::Value &payload)
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:1168
specifies the content in-memory of a row in the column metadata table
const Expr * get_where_clause() const
Definition: ParserNode.h:1782
const std::string * get_alias() const
Definition: ParserNode.h:1736
void execute(const Catalog_Namespace::SessionInfo &session) override
CheckDef(Expr *c)
Definition: ParserNode.h:911
std::unique_ptr< std::string > object_
Definition: ParserNode.h:1657
BetweenExpr(bool n, Expr *a, Expr *l, Expr *u)
Definition: ParserNode.h:429
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1226
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:1275
std::string to_string() const override
Definition: ParserNode.h:203
const std::vector< std::string > & get_roles() const
Definition: ParserNode.h:1694
const std::string foreign_table_
Definition: ParserNode.h:938
std::list< std::unique_ptr< TableRef > > from_clause_
Definition: ParserNode.h:1794
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1466
bool g_enable_smem_group_by true
std::unique_ptr< std::string > new_column_name_
Definition: ParserNode.h:1353
std::unique_ptr< Expr > pattern_string_
Definition: ParserNode.h:548
static void erase_cntl_chars(std::string &like_str, char escape_char)
Definition: ParserNode.cpp:661
std::unique_ptr< Expr > where_clause_
Definition: ParserNode.h:1795
std::vector< std::string > grantees_
Definition: ParserNode.h:1639
std::unique_ptr< std::string > path_
Definition: ParserNode.h:1467
const std::string * get_name() const
Definition: ParserNode.h:654
std::string to_string() const
AddColumnStmt(std::string *tab, ColumnDef *coldef)
Definition: ParserNode.h:1358
bool get_is_primarykey() const
Definition: ParserNode.h:861
std::unique_ptr< QueryExpr > left_
Definition: ParserNode.h:1728
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1532
std::unique_ptr< std::string > name_
Definition: ParserNode.h:967
std::unique_ptr< Literal > value_
Definition: ParserNode.h:968
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:547
std::unique_ptr< std::string > user_name_
Definition: ParserNode.h:2050
void check_executable(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
DropUserStmt(const rapidjson::Value &payload)
virtual void execute(const Catalog_Namespace::SessionInfo &session)=0
void execute(const Catalog_Namespace::SessionInfo &session) override
int get_colno() const
Definition: ParserNode.h:1818
void execute(const Catalog_Namespace::SessionInfo &session) override
SQLType(SQLTypes t, int p1, int p2, bool a, int array_size)
Definition: ParserNode.h:77
std::unique_ptr< std::string > role_
Definition: ParserNode.h:1570
std::string to_string() const override
TruncateTableStmt(std::string *tab)
Definition: ParserNode.h:1236
std::unique_ptr< std::string > table_name_
Definition: ParserNode.h:734
GrantRoleStmt(std::list< std::string * > *r, std::list< std::string * > *g)
Definition: ParserNode.h:1667
const std::list< std::unique_ptr< Expr > > & get_groupby_clause() const
Definition: ParserNode.h:1783
UnionQuery(bool u, QueryExpr *l, QueryExpr *r)
Definition: ParserNode.h:1719
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
const std::string * get_name() const
Definition: ParserNode.h:963
virtual ~Node()
Definition: ParserNode.h:65
void execute(const Catalog_Namespace::SessionInfo &session) override
void execute(const Catalog_Namespace::SessionInfo &session) override
Definition: ParserNode.h:1287
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:871
const std::string * get_range_var() const
Definition: ParserNode.h:730
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:287
bool get_distinct() const
Definition: ParserNode.h:655
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< Expr > partition_count_
Definition: ParserNode.h:578
Definition: sqldefs.h:71
static std::shared_ptr< Analyzer::Expr > analyzeValue(const std::string &stringval, const bool is_null)
Definition: ParserNode.cpp:143
DEVICE auto lower_bound(ARGS &&...args)
Definition: gpu_enabled.h:78
void insertDataToLeaf(const Catalog_Namespace::SessionInfo &parent_session_info, const size_t leaf_idx, Fragmenter_Namespace::InsertData &insert_data) override
Definition: ParserNode.h:1064
std::pair< std::unique_ptr< std::string >, std::unique_ptr< std::string >> TableNamePair
Definition: ParserNode.h:1327
std::string to_string() const override
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1603
void execute(const Catalog_Namespace::SessionInfo &session) override
const CompressDef * get_compression() const
Definition: ParserNode.h:828
const std::list< std::unique_ptr< TableElement > > & get_table_element_list() const override
Definition: ParserNode.h:1010
CreateUserStmt(std::string *n, std::list< NameValueAssign * > *l)
Definition: ParserNode.h:2001
std::string to_string() const override
Definition: ParserNode.cpp:272
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:1900
const Expr * get_lower() const
Definition: ParserNode.h:433
void execute(const Catalog_Namespace::SessionInfo &session) override
bool get_is_not() const
Definition: ParserNode.h:431
ArrayLiteral(std::list< Expr * > *v)
Definition: ParserNode.h:275
InExpr(bool n, Expr *a)
Definition: ParserNode.h:367
const std::list< std::unique_ptr< std::string > > & get_column_list() const
Definition: ParserNode.h:891
import_export::CopyParams deferred_copy_from_copy_params_
Definition: ParserNode.h:1539
bool isRepairTypeRemove() const
Definition: ParserNode.h:1283
DropTableStmt(std::string *tab, bool i)
Definition: ParserNode.h:1219
std::unique_ptr< Expr > where_clause_
Definition: ParserNode.h:2166
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override=0
std::vector< std::string > grantees_
Definition: ParserNode.h:1679
std::unique_ptr< QuerySpec > query_
Definition: ParserNode.h:343
CompressDef(std::string *n, int p)
Definition: ParserNode.h:815
InsertIntoTableAsSelectStmt(const rapidjson::Value &payload)
Encoding(std::string *encoding_name, int encoding_param)
Definition: DdlUtils.cpp:202
std::unique_ptr< Expr > like_string_
Definition: ParserNode.h:515
std::list< std::unique_ptr< std::string > > column_list_
Definition: ParserNode.h:2077
SQLQualifier opqualifier_
Definition: ParserNode.h:320
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:775
InsertIntoTableAsSelectStmt(const std::string *table_name, const std::string *select_query, std::list< std::string * > *c)
Definition: ParserNode.h:1128
InValues(bool n, Expr *a, std::list< Expr * > *v)
Definition: ParserNode.h:405
const std::string * get_foreign_table() const
Definition: ParserNode.h:894
std::string to_string() const override
Definition: ParserNode.h:162
NameValueAssign(std::string *n, Literal *v)
Definition: ParserNode.h:962
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:953
std::list< std::unique_ptr< NameValueAssign > > storage_options_
Definition: ParserNode.h:1026
const std::string column_
Definition: ParserNode.h:953
std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const override
CharLengthExpr(Expr *a, bool e)
Definition: ParserNode.h:455
void execute(const Catalog_Namespace::SessionInfo &session) override
std::string to_string() const override
static std::shared_ptr< Analyzer::Expr > analyzeValue(const int64_t numericval, const int scale, const int precision)
Definition: ParserNode.cpp:187
auto const & getNewUserName()
Definition: ParserNode.h:1316
std::unique_ptr< Expr > check_condition_
Definition: ParserNode.h:804
std::unique_ptr< QueryExpr > right_
Definition: ParserNode.h:1729
std::string to_string() const override
std::unique_ptr< std::string > foreign_column_
Definition: ParserNode.h:806
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:640
const std::vector< std::unique_ptr< ValuesList > > & get_value_lists() const
Definition: ParserNode.h:2111
CreateViewStmt(const std::string &view_name, const std::string &select_query, const bool if_not_exists)
Definition: ParserNode.h:1916
void push_back(Expr *value)
Definition: ParserNode.h:2091
const std::string * get_foreign_table() const
Definition: ParserNode.h:796
virtual std::string to_string() const =0
virtual size_t getOuterFragmentCount(QueryStateProxy, std::string &sql_query_string)=0
const Expr * get_partition_count() const
Definition: ParserNode.h:562
void analyze_from_clause(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
bool get_nulls_first() const
Definition: ParserNode.h:1821
std::unique_ptr< std::string > type_
Definition: ParserNode.h:1608
std::list< std::unique_ptr< SelectEntry > > select_clause_
Definition: ParserNode.h:1793
std::vector< std::unique_ptr< std::string > > column_list_
Definition: ParserNode.h:1156
bool shouldVacuumDeletedRows() const
Definition: ParserNode.h:1262
TableRef(std::string *t)
Definition: ParserNode.h:727
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1872
std::unique_ptr< std::string > alias_
Definition: ParserNode.h:1741
bool get_is_not() const
Definition: ParserNode.h:349
InsertValuesStmt(const rapidjson::Value &payload)
virtual std::vector< AggregatedResult > query(QueryStateProxy, std::string &sql_query_string, std::vector< size_t > outer_frag_indices, bool allow_interrupt)=0
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1972
std::unique_ptr< Expr > escape_string_
Definition: ParserNode.h:549
RenameUserStmt(std::string *username, std::string *new_username)
Definition: ParserNode.h:1313
std::string to_string() const override
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:830
std::string to_string() const override
bool get_is_primarykey() const
Definition: ParserNode.h:793
virtual std::shared_ptr< Analyzer::Expr > analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query, TlistRefType allow_tlist_ref=TLIST_NONE) const =0
bool g_enable_watchdog false
Definition: Execute.cpp:79
std::unique_ptr< std::string > target_
Definition: ParserNode.h:1638
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:517
std::unique_ptr< std::string > column_
Definition: ParserNode.h:2137
#define CHECK(condition)
Definition: Logger.h:223
Assignment(std::string *c, Expr *a)
Definition: ParserNode.h:2132
std::list< std::unique_ptr< std::string > > foreign_column_list_
Definition: ParserNode.h:902
std::unique_ptr< Expr > upper_
Definition: ParserNode.h:445
std::unique_ptr< std::string > range_var_
Definition: ParserNode.h:735
CreateDataframeStmt(std::string *tab, std::list< TableElement * > *table_elems, std::string *filename, std::list< NameValueAssign * > *s)
Definition: ParserNode.h:1086
std::list< std::unique_ptr< OrderSpec > > orderby_clause_
Definition: ParserNode.h:1854
const std::vector< std::string > & get_privs() const
Definition: ParserNode.h:1600
std::vector< std::string > privileges_
Definition: ParserNode.h:1636
CopyTableStmt(std::string *t, std::string *f, std::list< NameValueAssign * > *o)
ShowCreateTableStmt(std::string *tab)
Definition: ParserNode.h:1865
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:198
std::list< std::unique_ptr< NameValueAssign > > options_
Definition: ParserNode.h:1535
bool get_is_distinct() const
Definition: ParserNode.h:1775
std::string to_string() const override
Definition: ParserNode.h:223
const std::string & get_object_type() const
Definition: ParserNode.h:1650
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:485
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:525
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1674
ColumnConstraintDef(std::string *t, std::string *c)
Definition: ParserNode.h:785
SubqueryExpr(QuerySpec *q)
Definition: ParserNode.h:334
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:606
bool get_is_not() const
Definition: ParserNode.h:588
std::string to_string() const override
Definition: ParserNode.h:126
const std::string * get_foreign_column() const
Definition: ParserNode.h:797
void execute(const Catalog_Namespace::SessionInfo &session) override
std::string to_string() const override
std::list< std::unique_ptr< std::string > > column_list_
Definition: ParserNode.h:868
std::vector< std::unique_ptr< ValuesList > > values_lists_
Definition: ParserNode.h:2123
The data to be inserted using the fragment manager.
Definition: Fragmenter.h:68
const std::string * get_table() const
Definition: ParserNode.h:1385
const Expr * get_left() const
Definition: ParserNode.h:304
const rapidjson::Value payload_
Definition: ParserNode.h:1210
std::list< std::unique_ptr< std::string > > column_list_
Definition: ParserNode.h:900
const std::vector< std::string > & get_privs() const
Definition: ParserNode.h:1629
void analyze_group_by(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const
std::unique_ptr< std::string > role_
Definition: ParserNode.h:1658
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
const Expr * get_expr2() const
Definition: ParserNode.h:689
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:680
std::list< ColumnDescriptor > getColumnDescriptors(AggregatedResult &result, bool for_create)
const std::string * get_view_name() const
Definition: ParserNode.h:1944
const QuerySpec * get_query() const
Definition: ParserNode.h:613
const std::string * get_table() const override
Definition: ParserNode.h:1105
std::unique_ptr< Literal > defaultval_
Definition: ParserNode.h:803
std::unique_ptr< QueryExpr > query_expr_
Definition: ParserNode.h:1853
WidthBucketExpr(Expr *t, Expr *l, Expr *u, Expr *p)
Definition: ParserNode.h:557
auto const & getOldUserName()
Definition: ParserNode.h:1315
const std::string & get_object() const
Definition: ParserNode.h:1631
std::unique_ptr< std::string > foreign_table_
Definition: ParserNode.h:901
void execute(const Catalog_Namespace::SessionInfo &session)
ColumnRef(std::string *n1)
Definition: ParserNode.h:630
std::string to_string() const override
std::string to_string() const override
const QuerySpec * get_query() const
Definition: ParserNode.h:335
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1351
constexpr double n
Definition: Utm.h:38
std::unique_ptr< std::string > column_
Definition: ParserNode.h:642
const std::string & get_view_name() const
Definition: ParserNode.h:1925
AlterUserStmt(const rapidjson::Value &payload)
LikeExpr(bool n, bool i, Expr *a, Expr *l, Expr *e)
Definition: ParserNode.h:494
std::string view_name_
Definition: ParserNode.h:1930
const Expr * get_escape_string() const
Definition: ParserNode.h:534
std::list< std::unique_ptr< ExprPair > > when_then_list_
Definition: ParserNode.h:717
FunctionRef(std::string *n)
Definition: ParserNode.h:651
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:178
std::unique_ptr< Expr > lower_bound_
Definition: ParserNode.h:576
OperExpr(SQLOps t, Expr *l, Expr *r)
Definition: ParserNode.h:299
std::list< std::unique_ptr< TableElement > > table_element_list_
Definition: ParserNode.h:1115
const CompressionType getCompression() const
Definition: ParserNode.h:1463
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:505
const QueryExpr * get_query_expr() const
Definition: ParserNode.h:1845
RenameColumnStmt(std::string *tab, std::string *col, std::string *new_col_name)
Definition: ParserNode.h:1346
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:568
auto const & getNewDatabaseName()
Definition: ParserNode.h:1302
ValuesList(std::list< Expr * > *values)
Definition: ParserNode.h:2083
CreateTableAsSelectStmt(const rapidjson::Value &payload)
CompressionType validateCompression(const std::string &compression, const bool is_restore)
const std::list< std::unique_ptr< Assignment > > & get_assignment_list() const
Definition: ParserNode.h:2156
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:850
FunctionRef(std::string *n, bool d, Expr *a)
Definition: ParserNode.h:653
DropDBStmt(const rapidjson::Value &payload)
AlterUserStmt(std::string *n, std::list< NameValueAssign * > *l)
Definition: ParserNode.h:2023
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1022
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:465
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< Parser::Stmt > create_stmt_for_query(const std::string &queryStr, const Catalog_Namespace::SessionInfo &session_info)
RenameDBStmt(std::string *database_name, std::string *new_database_name)
Definition: ParserNode.h:1298
const Expr * get_arg() const
Definition: ParserNode.h:456
OrderSpec(int n, ColumnRef *c, bool d, bool f)
Definition: ParserNode.h:1816
std::list< std::unique_ptr< Expr > > value_list
Definition: ParserNode.h:2096
void insertChunksToLeaf(const Catalog_Namespace::SessionInfo &parent_session_info, const size_t leaf_idx, const Fragmenter_Namespace::InsertChunks &insert_chunks) override
Definition: ParserNode.h:1057
CreateUserStmt(const rapidjson::Value &payload)
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:443
void execute(const Catalog_Namespace::SessionInfo &session) override
double get_doubleval() const
Definition: ParserNode.h:218
RegexpExpr(bool n, Expr *a, Expr *p, Expr *e)
Definition: ParserNode.h:529
const std::string & get_object_type() const
Definition: ParserNode.h:1630
std::unique_ptr< std::string > filename_
Definition: ParserNode.h:1116
ShowPrivilegesStmt(std::string *t, std::string *o, std::string *r)
Definition: ParserNode.h:1648
UniqueDef(bool p, std::list< std::string * > *cl)
Definition: ParserNode.h:854
void execute(const Catalog_Namespace::SessionInfo &session) override
const std::string * get_table() const
Definition: ParserNode.h:1368
SelectEntry(Expr *e, std::string *r)
Definition: ParserNode.h:1734
const QueryExpr * get_right() const
Definition: ParserNode.h:1722
std::unique_ptr< std::string > object_type_
Definition: ParserNode.h:1656
void analyze(const Catalog_Namespace::Catalog &catalog, Analyzer::Query &query) const override
std::string to_string() const override
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1388
const Expr * get_expr1() const
Definition: ParserNode.h:688
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:620
static std::unique_ptr< Parser::DDLStmt > delegate(const rapidjson::Value &payload)
const std::string & get_object() const
Definition: ParserNode.h:1602
const std::string * get_column() const
Definition: ParserNode.h:633
size_t leafCount() override
Definition: ParserNode.h:1056
void execute(const Catalog_Namespace::SessionInfo &session) override
std::unique_ptr< ColumnDef > coldef_
Definition: ParserNode.h:1372
std::unique_ptr< Expr > arg_
Definition: ParserNode.h:378
static void check_like_expr(const std::string &like_str, char escape_char)
Definition: ParserNode.cpp:634
DumpTableStmt(std::string *tab, std::string *path, std::list< NameValueAssign * > *options)
Definition: ParserNode.h:1473
const std::list< std::unique_ptr< TableRef > > & get_from_clause() const
Definition: ParserNode.h:1779
auto const & getDatabaseName()
Definition: ParserNode.h:1986
DeleteStmt(std::string *t, Expr *w)
Definition: ParserNode.h:2175
const Expr * get_assignment() const
Definition: ParserNode.h:2134