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