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