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