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