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