OmniSciDB  72180abbfe
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Analyzer.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 ANALYZER_H
25 #define ANALYZER_H
26 
27 #include "../Shared/Logger.h"
28 
29 #include <cstdint>
30 #include <iostream>
31 #include <list>
32 #include <set>
33 #include <string>
34 #include <type_traits>
35 #include <utility>
36 #include <vector>
37 
38 #include "../Shared/geo_types.h"
39 #include "../Shared/sqldefs.h"
40 #include "../Shared/sqltypes.h"
41 
42 namespace Analyzer {
43 class Expr;
44 }
45 
46 namespace Catalog_Namespace {
47 class Catalog;
48 }
49 
50 template <typename Tp, typename... Args>
51 inline typename std::enable_if<std::is_base_of<Analyzer::Expr, Tp>::value,
52  std::shared_ptr<Tp>>::type
53 makeExpr(Args&&... args) {
54  return std::make_shared<Tp>(std::forward<Args>(args)...);
55 }
56 
57 namespace Analyzer {
58 
59 class ColumnVar;
60 class TargetEntry;
61 class Expr;
62 using DomainSet = std::list<const Expr*>;
63 
64 /*
65  * @type Expr
66  * @brief super class for all expressions in parse trees and in query plans
67  */
68 class Expr : public std::enable_shared_from_this<Expr> {
69  public:
70  Expr(SQLTypes t, bool notnull) : type_info(t, notnull), contains_agg(false) {}
71  Expr(SQLTypes t, int d, bool notnull)
72  : type_info(t, d, 0, notnull), contains_agg(false) {}
73  Expr(SQLTypes t, int d, int s, bool notnull)
74  : type_info(t, d, s, notnull), contains_agg(false) {}
75  Expr(const SQLTypeInfo& ti, bool has_agg = false)
76  : type_info(ti), contains_agg(has_agg) {}
77  virtual ~Expr() {}
78  std::shared_ptr<Analyzer::Expr> get_shared_ptr() { return shared_from_this(); }
79  const SQLTypeInfo& get_type_info() const { return type_info; }
80  void set_type_info(const SQLTypeInfo& ti) { type_info = ti; }
81  bool get_contains_agg() const { return contains_agg; }
82  void set_contains_agg(bool a) { contains_agg = a; }
83  virtual std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info);
84  virtual void check_group_by(
85  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const {};
86  virtual std::shared_ptr<Analyzer::Expr> deep_copy()
87  const = 0; // make a deep copy of self
88  /*
89  * @brief normalize_simple_predicate only applies to boolean expressions.
90  * it checks if it is an expression comparing a column
91  * with a constant. if so, it returns a normalized copy of the predicate with ColumnVar
92  * always as the left operand with rte_idx set to the rte_idx of the ColumnVar.
93  * it returns nullptr with rte_idx set to -1 otherwise.
94  */
95  virtual std::shared_ptr<Analyzer::Expr> normalize_simple_predicate(int& rte_idx) const {
96  rte_idx = -1;
97  return nullptr;
98  }
99  /*
100  * @brief seperate conjunctive predicates into scan predicates, join predicates and
101  * constant predicates.
102  */
103  virtual void group_predicates(std::list<const Expr*>& scan_predicates,
104  std::list<const Expr*>& join_predicates,
105  std::list<const Expr*>& const_predicates) const {}
106  /*
107  * @brief collect_rte_idx collects the indices of all the range table
108  * entries involved in an expression
109  */
110  virtual void collect_rte_idx(std::set<int>& rte_idx_set) const {}
111  /*
112  * @brief collect_column_var collects all unique ColumnVar nodes in an expression
113  * If include_agg = false, it does not include to ColumnVar nodes inside
114  * the argument to AggExpr's. Otherwise, they are included.
115  * It does not make copies of the ColumnVar
116  */
117  virtual void collect_column_var(
118  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
119  colvar_set,
120  bool include_agg) const {}
121  /*
122  * @brief rewrite_with_targetlist rewrite ColumnVar's in expression with entries in a
123  * targetlist. targetlist expressions are expected to be only Var's or AggExpr's.
124  * returns a new expression copy
125  */
126  virtual std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
127  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const {
128  return deep_copy();
129  };
130  /*
131  * @brief rewrite_with_child_targetlist rewrite ColumnVar's in expression with entries
132  * in a child plan's targetlist. targetlist expressions are expected to be only Var's or
133  * ColumnVar's returns a new expression copy
134  */
135  virtual std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
136  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const {
137  return deep_copy();
138  };
139  /*
140  * @brief rewrite_agg_to_var rewrite ColumnVar's in expression with entries in an
141  * AggPlan's targetlist. targetlist expressions are expected to be only Var's or
142  * ColumnVar's or AggExpr's All AggExpr's are written into Var's. returns a new
143  * expression copy
144  */
145  virtual std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
146  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const {
147  return deep_copy();
148  }
149  virtual bool operator==(const Expr& rhs) const = 0;
150  virtual std::string toString() const = 0;
151  virtual void print() const { std::cout << toString(); }
152 
153  virtual void add_unique(std::list<const Expr*>& expr_list) const;
154  /*
155  * @brief find_expr traverse Expr hierarchy and adds the node pointer to
156  * the expr_list if the function f returns true.
157  * Duplicate Expr's are not added the list.
158  * Cannot use std::set because we don't have an ordering function.
159  */
160  virtual void find_expr(bool (*f)(const Expr*),
161  std::list<const Expr*>& expr_list) const {
162  if (f(this)) {
163  add_unique(expr_list);
164  }
165  }
166  /*
167  * @brief decompress adds cast operator to decompress encoded result
168  */
169  std::shared_ptr<Analyzer::Expr> decompress();
170  /*
171  * @brief perform domain analysis on Expr and fill in domain
172  * information in domain_set. Empty domain_set means no information.
173  */
174  virtual void get_domain(DomainSet& domain_set) const { domain_set.clear(); }
175 
176  protected:
177  SQLTypeInfo type_info; // SQLTypeInfo of the return result of this expression
179 };
180 
181 using ExpressionPtr = std::shared_ptr<Analyzer::Expr>;
182 using ExpressionPtrList = std::list<ExpressionPtr>;
183 using ExpressionPtrVector = std::vector<ExpressionPtr>;
184 
185 /*
186  * @type ColumnVar
187  * @brief expression that evaluates to the value of a column in a given row from a base
188  * table. It is used in parse trees and is only used in Scan nodes in a query plan for
189  * scanning a table while Var nodes are used for all other plans.
190  */
191 class ColumnVar : public Expr {
192  public:
193  ColumnVar(const SQLTypeInfo& ti, int r, int c, int i)
194  : Expr(ti), table_id(r), column_id(c), rte_idx(i) {}
195  int get_table_id() const { return table_id; }
196  int get_column_id() const { return column_id; }
197  int get_rte_idx() const { return rte_idx; }
199  int get_comp_param() const { return type_info.get_comp_param(); }
200  void check_group_by(
201  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
202  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
203  void group_predicates(std::list<const Expr*>& scan_predicates,
204  std::list<const Expr*>& join_predicates,
205  std::list<const Expr*>& const_predicates) const override;
206  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
207  rte_idx_set.insert(rte_idx);
208  }
209  static bool colvar_comp(const ColumnVar* l, const ColumnVar* r) {
210  return l->get_table_id() < r->get_table_id() ||
211  (l->get_table_id() == r->get_table_id() &&
212  l->get_column_id() < r->get_column_id());
213  }
215  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
216  colvar_set,
217  bool include_agg) const override {
218  colvar_set.insert(this);
219  }
220  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
221  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
222  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
223  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
224  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
225  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
226  bool operator==(const Expr& rhs) const override;
227  std::string toString() const override;
228 
229  protected:
230  int table_id; // the global table id
231  int column_id; // the column id
232  int rte_idx; // 0-based range table index, used for table ordering in multi-joins
233 };
234 
235 /*
236  * @type ExpressionTuple
237  * @brief A tuple of expressions on the side of an equi-join on multiple columns.
238  * Not to be used in any other context.
239  */
240 class ExpressionTuple : public Expr {
241  public:
242  ExpressionTuple(const std::vector<std::shared_ptr<Analyzer::Expr>>& tuple)
243  : Expr(SQLTypeInfo()), tuple_(tuple){};
244 
245  const std::vector<std::shared_ptr<Analyzer::Expr>>& getTuple() const { return tuple_; }
246 
247  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
248 
249  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
250 
251  bool operator==(const Expr& rhs) const override;
252  std::string toString() const override;
253 
254  private:
255  const std::vector<std::shared_ptr<Analyzer::Expr>> tuple_;
256 };
257 
258 /*
259  * @type Var
260  * @brief expression that evaluates to the value of a column in a given row generated
261  * from a query plan node. It is only used in plan nodes above Scan nodes.
262  * The row can be produced by either the inner or the outer plan in case of a join.
263  * It inherits from ColumnVar to keep track of the lineage through the plan nodes.
264  * The table_id will be set to 0 if the Var does not correspond to an original column
265  * value.
266  */
267 class Var : public ColumnVar {
268  public:
270  Var(const SQLTypeInfo& ti, int r, int c, int i, WhichRow o, int v)
271  : ColumnVar(ti, r, c, i), which_row(o), varno(v) {}
272  Var(const SQLTypeInfo& ti, WhichRow o, int v)
273  : ColumnVar(ti, 0, 0, -1), which_row(o), varno(v) {}
274  WhichRow get_which_row() const { return which_row; }
276  int get_varno() const { return varno; }
277  void set_varno(int n) { varno = n; }
278  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
279  std::string toString() const override;
280  void check_group_by(
281  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
282  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
283  rte_idx_set.insert(-1);
284  }
285  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
286  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
287  return deep_copy();
288  }
289  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
290  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
291  return deep_copy();
292  }
293  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
294  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
295 
296  private:
297  WhichRow which_row; // indicate which row this Var should project from. It can be from
298  // the outer input plan or the inner input plan (for joins) or the
299  // output row in the current plan.
300  int varno; // the column number in the row. 1-based
301 };
302 
303 /*
304  * @type Constant
305  * @brief expression for a constant value
306  */
307 class Constant : public Expr {
308  public:
309  Constant(SQLTypes t, bool n) : Expr(t, !n), is_null(n) {
310  if (n) {
311  set_null_value();
312  } else {
313  type_info.set_notnull(true);
314  }
315  }
316  Constant(SQLTypes t, bool n, Datum v) : Expr(t, !n), is_null(n), constval(v) {
317  if (n) {
318  set_null_value();
319  } else {
320  type_info.set_notnull(true);
321  }
322  }
323  Constant(const SQLTypeInfo& ti, bool n, Datum v) : Expr(ti), is_null(n), constval(v) {
324  if (n) {
325  set_null_value();
326  } else {
327  type_info.set_notnull(true);
328  }
329  }
331  bool n,
332  const std::list<std::shared_ptr<Analyzer::Expr>>& l)
333  : Expr(ti), is_null(n), constval(Datum{0}), value_list(l) {}
334  ~Constant() override;
335  bool get_is_null() const { return is_null; }
336  Datum get_constval() const { return constval; }
337  void set_constval(Datum d) { constval = d; }
338  const std::list<std::shared_ptr<Analyzer::Expr>>& get_value_list() const {
339  return value_list;
340  }
341  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
342  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) override;
343  bool operator==(const Expr& rhs) const override;
344  std::string toString() const override;
345 
346  private:
347  bool is_null; // constant is NULL
348  Datum constval; // the constant value
349  const std::list<std::shared_ptr<Analyzer::Expr>> value_list;
350  void cast_number(const SQLTypeInfo& new_type_info);
351  void cast_string(const SQLTypeInfo& new_type_info);
352  void cast_from_string(const SQLTypeInfo& new_type_info);
353  void cast_to_string(const SQLTypeInfo& new_type_info);
354  void do_cast(const SQLTypeInfo& new_type_info);
355  void set_null_value();
356 };
357 
358 /*
359  * @type UOper
360  * @brief represents unary operator expressions. operator types include
361  * kUMINUS, kISNULL, kEXISTS, kCAST
362  */
363 class UOper : public Expr {
364  public:
365  UOper(const SQLTypeInfo& ti, bool has_agg, SQLOps o, std::shared_ptr<Analyzer::Expr> p)
366  : Expr(ti, has_agg), optype(o), operand(p) {}
367  UOper(SQLTypes t, SQLOps o, std::shared_ptr<Analyzer::Expr> p)
368  : Expr(t, o == kISNULL ? true : p->get_type_info().get_notnull())
369  , optype(o)
370  , operand(p) {}
371  SQLOps get_optype() const { return optype; }
372  const Expr* get_operand() const { return operand.get(); }
373  const std::shared_ptr<Analyzer::Expr> get_own_operand() const { return operand; }
374  void check_group_by(
375  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
376  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
377  void group_predicates(std::list<const Expr*>& scan_predicates,
378  std::list<const Expr*>& join_predicates,
379  std::list<const Expr*>& const_predicates) const override;
380  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
381  operand->collect_rte_idx(rte_idx_set);
382  }
384  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
385  colvar_set,
386  bool include_agg) const override {
387  operand->collect_column_var(colvar_set, include_agg);
388  }
389  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
390  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
391  return makeExpr<UOper>(
392  type_info, contains_agg, optype, operand->rewrite_with_targetlist(tlist));
393  }
394  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
395  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
396  return makeExpr<UOper>(
397  type_info, contains_agg, optype, operand->rewrite_with_child_targetlist(tlist));
398  }
399  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
400  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
401  return makeExpr<UOper>(
402  type_info, contains_agg, optype, operand->rewrite_agg_to_var(tlist));
403  }
404  bool operator==(const Expr& rhs) const override;
405  std::string toString() const override;
406  void find_expr(bool (*f)(const Expr*),
407  std::list<const Expr*>& expr_list) const override;
408  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) override;
409 
410  private:
411  SQLOps optype; // operator type, e.g., kUMINUS, kISNULL, kEXISTS
412  std::shared_ptr<Analyzer::Expr> operand; // operand expression
413 };
414 
415 /*
416  * @type BinOper
417  * @brief represents binary operator expressions. it includes all
418  * comparison, arithmetic and boolean binary operators. it handles ANY/ALL qualifiers
419  * in case the right_operand is a subquery.
420  */
421 class BinOper : public Expr {
422  public:
423  BinOper(const SQLTypeInfo& ti,
424  bool has_agg,
425  SQLOps o,
426  SQLQualifier q,
427  std::shared_ptr<Analyzer::Expr> l,
428  std::shared_ptr<Analyzer::Expr> r)
429  : Expr(ti, has_agg), optype(o), qualifier(q), left_operand(l), right_operand(r) {}
431  SQLOps o,
432  SQLQualifier q,
433  std::shared_ptr<Analyzer::Expr> l,
434  std::shared_ptr<Analyzer::Expr> r)
435  : Expr(t, l->get_type_info().get_notnull() && r->get_type_info().get_notnull())
436  , optype(o)
437  , qualifier(q)
438  , left_operand(l)
439  , right_operand(r) {}
440  SQLOps get_optype() const { return optype; }
441  bool is_overlaps_oper() const { return optype == kOVERLAPS; }
443  const Expr* get_left_operand() const { return left_operand.get(); }
444  const Expr* get_right_operand() const { return right_operand.get(); }
445  const std::shared_ptr<Analyzer::Expr> get_own_left_operand() const {
446  return left_operand;
447  }
448  const std::shared_ptr<Analyzer::Expr> get_own_right_operand() const {
449  return right_operand;
450  }
452  const SQLTypeInfo& left_type,
453  const SQLTypeInfo& right_type,
454  SQLTypeInfo* new_left_type,
455  SQLTypeInfo* new_right_type);
456  static SQLTypeInfo common_numeric_type(const SQLTypeInfo& type1,
457  const SQLTypeInfo& type2);
458  static SQLTypeInfo common_string_type(const SQLTypeInfo& type1,
459  const SQLTypeInfo& type2);
460  void check_group_by(
461  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
462  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
463  std::shared_ptr<Analyzer::Expr> normalize_simple_predicate(int& rte_idx) const override;
464  void group_predicates(std::list<const Expr*>& scan_predicates,
465  std::list<const Expr*>& join_predicates,
466  std::list<const Expr*>& const_predicates) const override;
467  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
468  left_operand->collect_rte_idx(rte_idx_set);
469  right_operand->collect_rte_idx(rte_idx_set);
470  }
472  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
473  colvar_set,
474  bool include_agg) const override {
475  left_operand->collect_column_var(colvar_set, include_agg);
476  right_operand->collect_column_var(colvar_set, include_agg);
477  }
478  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
479  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
480  return makeExpr<BinOper>(type_info,
481  contains_agg,
482  optype,
483  qualifier,
484  left_operand->rewrite_with_targetlist(tlist),
485  right_operand->rewrite_with_targetlist(tlist));
486  }
487  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
488  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
489  return makeExpr<BinOper>(type_info,
490  contains_agg,
491  optype,
492  qualifier,
493  left_operand->rewrite_with_child_targetlist(tlist),
494  right_operand->rewrite_with_child_targetlist(tlist));
495  }
496  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
497  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
498  return makeExpr<BinOper>(type_info,
499  contains_agg,
500  optype,
501  qualifier,
502  left_operand->rewrite_agg_to_var(tlist),
503  right_operand->rewrite_agg_to_var(tlist));
504  }
505  bool operator==(const Expr& rhs) const override;
506  std::string toString() const override;
507  void find_expr(bool (*f)(const Expr*),
508  std::list<const Expr*>& expr_list) const override;
510  const std::shared_ptr<Analyzer::Expr> cast_operand,
511  const std::shared_ptr<Analyzer::Expr> const_operand);
512 
513  private:
514  SQLOps optype; // operator type, e.g., kLT, kAND, kPLUS, etc.
515  SQLQualifier qualifier; // qualifier kANY, kALL or kONE. Only relevant with
516  // right_operand is Subquery
517  std::shared_ptr<Analyzer::Expr> left_operand; // the left operand expression
518  std::shared_ptr<Analyzer::Expr> right_operand; // the right operand expression
519 };
520 
521 class Query;
522 
523 /*
524  * @type Subquery
525  * @brief subquery expression. Note that the type of the expression is the type of the
526  * TargetEntry in the subquery instead of the set.
527  */
528 class Subquery : public Expr {
529  public:
530  Subquery(const SQLTypeInfo& ti, Query* q)
531  : Expr(ti), parsetree(q) /*, plan(nullptr)*/ {}
532  ~Subquery() override;
533  const Query* get_parsetree() const { return parsetree; }
534  // const Plan *get_plan() const { return plan; }
535  // void set_plan(Plan *p) { plan = p; } // subquery plan is set by the optimizer
536  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) override;
537  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
538  void group_predicates(std::list<const Expr*>& scan_predicates,
539  std::list<const Expr*>& join_predicates,
540  std::list<const Expr*>& const_predicates) const override {
541  CHECK(false);
542  }
543  void collect_rte_idx(std::set<int>& rte_idx_set) const override { CHECK(false); }
545  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
546  colvar_set,
547  bool include_agg) const override {
548  CHECK(false);
549  }
550  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
551  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
552  abort();
553  }
554  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
555  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
556  abort();
557  }
558  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
559  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
560  abort();
561  }
562  bool operator==(const Expr& rhs) const override {
563  CHECK(false);
564  return false;
565  }
566  std::string toString() const override;
567  void find_expr(bool (*f)(const Expr*),
568  std::list<const Expr*>& expr_list) const override {
569  CHECK(false);
570  }
571 
572  private:
573  Query* parsetree; // parse tree of the subquery
574 };
575 
576 /*
577  * @type InValues
578  * @brief represents predicate expr IN (v1, v2, ...)
579  * v1, v2, ... are can be either Constant or Parameter.
580  */
581 class InValues : public Expr {
582  public:
583  InValues(std::shared_ptr<Analyzer::Expr> a,
584  const std::list<std::shared_ptr<Analyzer::Expr>>& l);
585  const Expr* get_arg() const { return arg.get(); }
586  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
587  const std::list<std::shared_ptr<Analyzer::Expr>>& get_value_list() const {
588  return value_list;
589  }
590  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
591  void group_predicates(std::list<const Expr*>& scan_predicates,
592  std::list<const Expr*>& join_predicates,
593  std::list<const Expr*>& const_predicates) const override;
594  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
595  arg->collect_rte_idx(rte_idx_set);
596  }
598  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
599  colvar_set,
600  bool include_agg) const override {
601  arg->collect_column_var(colvar_set, include_agg);
602  }
603  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
604  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
605  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
606  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
607  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
608  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
609  bool operator==(const Expr& rhs) const override;
610  std::string toString() const override;
611  void find_expr(bool (*f)(const Expr*),
612  std::list<const Expr*>& expr_list) const override;
613 
614  private:
615  std::shared_ptr<Analyzer::Expr> arg; // the argument left of IN
616  const std::list<std::shared_ptr<Analyzer::Expr>>
617  value_list; // the list of values right of IN
618 };
619 
620 /*
621  * @type InIntegerSet
622  * @brief represents predicate expr IN (v1, v2, ...) for the case where the right
623  * hand side is a list of integers or dictionary-encoded strings generated
624  * by a IN subquery. Avoids the overhead of storing a list of shared pointers
625  * to Constant objects, making it more suitable for IN sub-queries usage.
626  * v1, v2, ... are integers
627  */
628 class InIntegerSet : public Expr {
629  public:
630  InIntegerSet(const std::shared_ptr<const Analyzer::Expr> a,
631  const std::vector<int64_t>& values,
632  const bool not_null);
633 
634  const Expr* get_arg() const { return arg.get(); }
635 
636  const std::vector<int64_t>& get_value_list() const { return value_list; }
637 
638  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
639 
640  bool operator==(const Expr& rhs) const override;
641  std::string toString() const override;
642 
643  private:
644  const std::shared_ptr<const Analyzer::Expr> arg; // the argument left of IN
645  const std::vector<int64_t> value_list; // the list of values right of IN
646 };
647 
648 /*
649  * @type CharLengthExpr
650  * @brief expression for the CHAR_LENGTH expression.
651  * arg must evaluate to char, varchar or text.
652  */
653 class CharLengthExpr : public Expr {
654  public:
655  CharLengthExpr(std::shared_ptr<Analyzer::Expr> a, bool e)
656  : Expr(kINT, a->get_type_info().get_notnull()), arg(a), calc_encoded_length(e) {}
657  const Expr* get_arg() const { return arg.get(); }
658  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
660  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
661  void group_predicates(std::list<const Expr*>& scan_predicates,
662  std::list<const Expr*>& join_predicates,
663  std::list<const Expr*>& const_predicates) const override;
664  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
665  arg->collect_rte_idx(rte_idx_set);
666  }
668  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
669  colvar_set,
670  bool include_agg) const override {
671  arg->collect_column_var(colvar_set, include_agg);
672  }
673  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
674  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
675  return makeExpr<CharLengthExpr>(arg->rewrite_with_targetlist(tlist),
677  }
678  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
679  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
680  return makeExpr<CharLengthExpr>(arg->rewrite_with_child_targetlist(tlist),
682  }
683  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
684  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
685  return makeExpr<CharLengthExpr>(arg->rewrite_agg_to_var(tlist), calc_encoded_length);
686  }
687  bool operator==(const Expr& rhs) const override;
688  std::string toString() const override;
689  void find_expr(bool (*f)(const Expr*),
690  std::list<const Expr*>& expr_list) const override;
691 
692  private:
693  std::shared_ptr<Analyzer::Expr> arg;
695 };
696 
697 /*
698  * @type KeyForStringExpr
699  * @brief expression for the KEY_FOR_STRING expression.
700  * arg must be a dict encoded column, not str literal.
701  */
702 class KeyForStringExpr : public Expr {
703  public:
704  KeyForStringExpr(std::shared_ptr<Analyzer::Expr> a)
705  : Expr(kINT, a->get_type_info().get_notnull()), arg(a) {}
706  const Expr* get_arg() const { return arg.get(); }
707  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
708  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
709  void group_predicates(std::list<const Expr*>& scan_predicates,
710  std::list<const Expr*>& join_predicates,
711  std::list<const Expr*>& const_predicates) const override;
712  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
713  arg->collect_rte_idx(rte_idx_set);
714  }
716  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
717  colvar_set,
718  bool include_agg) const override {
719  arg->collect_column_var(colvar_set, include_agg);
720  }
721  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
722  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
723  return makeExpr<KeyForStringExpr>(arg->rewrite_with_targetlist(tlist));
724  }
725  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
726  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
727  return makeExpr<KeyForStringExpr>(arg->rewrite_with_child_targetlist(tlist));
728  }
729  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
730  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
731  return makeExpr<KeyForStringExpr>(arg->rewrite_agg_to_var(tlist));
732  }
733  bool operator==(const Expr& rhs) const override;
734  std::string toString() const override;
735  void find_expr(bool (*f)(const Expr*),
736  std::list<const Expr*>& expr_list) const override;
737 
738  private:
739  std::shared_ptr<Analyzer::Expr> arg;
740 };
741 
747 class LowerExpr : public Expr {
748  public:
749  LowerExpr(std::shared_ptr<Analyzer::Expr> arg) : Expr(arg->get_type_info()), arg(arg) {}
750 
751  const Expr* get_arg() const { return arg.get(); }
752 
753  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
754 
755  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
756  arg->collect_rte_idx(rte_idx_set);
757  }
758 
760  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
761  colvar_set,
762  bool include_agg) const override {
763  arg->collect_column_var(colvar_set, include_agg);
764  }
765 
766  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
767  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
768  return makeExpr<LowerExpr>(arg->rewrite_with_targetlist(tlist));
769  }
770 
771  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
772  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
773  return makeExpr<LowerExpr>(arg->rewrite_with_child_targetlist(tlist));
774  }
775 
776  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
777  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
778  return makeExpr<LowerExpr>(arg->rewrite_agg_to_var(tlist));
779  }
780 
781  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
782 
783  void group_predicates(std::list<const Expr*>& scan_predicates,
784  std::list<const Expr*>& join_predicates,
785  std::list<const Expr*>& const_predicates) const override;
786 
787  bool operator==(const Expr& rhs) const override;
788 
789  std::string toString() const override;
790 
791  void find_expr(bool (*f)(const Expr*),
792  std::list<const Expr*>& expr_list) const override;
793 
794  private:
795  std::shared_ptr<Analyzer::Expr> arg;
796 };
797 
798 /*
799  * @type CardinalityExpr
800  * @brief expression for the CARDINALITY expression.
801  * arg must evaluate to array (or multiset when supported).
802  */
803 class CardinalityExpr : public Expr {
804  public:
805  CardinalityExpr(std::shared_ptr<Analyzer::Expr> a)
806  : Expr(kINT, a->get_type_info().get_notnull()), arg(a) {}
807  const Expr* get_arg() const { return arg.get(); }
808  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
809  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
810  void group_predicates(std::list<const Expr*>& scan_predicates,
811  std::list<const Expr*>& join_predicates,
812  std::list<const Expr*>& const_predicates) const override;
813  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
814  arg->collect_rte_idx(rte_idx_set);
815  }
817  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
818  colvar_set,
819  bool include_agg) const override {
820  arg->collect_column_var(colvar_set, include_agg);
821  }
822  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
823  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
824  return makeExpr<CardinalityExpr>(arg->rewrite_with_targetlist(tlist));
825  }
826  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
827  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
828  return makeExpr<CardinalityExpr>(arg->rewrite_with_child_targetlist(tlist));
829  }
830  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
831  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
832  return makeExpr<CardinalityExpr>(arg->rewrite_agg_to_var(tlist));
833  }
834  bool operator==(const Expr& rhs) const override;
835  std::string toString() const override;
836  void find_expr(bool (*f)(const Expr*),
837  std::list<const Expr*>& expr_list) const override;
838 
839  private:
840  std::shared_ptr<Analyzer::Expr> arg;
841 };
842 
843 /*
844  * @type LikeExpr
845  * @brief expression for the LIKE predicate.
846  * arg must evaluate to char, varchar or text.
847  */
848 class LikeExpr : public Expr {
849  public:
850  LikeExpr(std::shared_ptr<Analyzer::Expr> a,
851  std::shared_ptr<Analyzer::Expr> l,
852  std::shared_ptr<Analyzer::Expr> e,
853  bool i,
854  bool s)
855  : Expr(kBOOLEAN, a->get_type_info().get_notnull())
856  , arg(a)
857  , like_expr(l)
858  , escape_expr(e)
859  , is_ilike(i)
860  , is_simple(s) {}
861  const Expr* get_arg() const { return arg.get(); }
862  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
863  const Expr* get_like_expr() const { return like_expr.get(); }
864  const Expr* get_escape_expr() const { return escape_expr.get(); }
865  bool get_is_ilike() const { return is_ilike; }
866  bool get_is_simple() const { return is_simple; }
867  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
868  void group_predicates(std::list<const Expr*>& scan_predicates,
869  std::list<const Expr*>& join_predicates,
870  std::list<const Expr*>& const_predicates) const override;
871  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
872  arg->collect_rte_idx(rte_idx_set);
873  }
875  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
876  colvar_set,
877  bool include_agg) const override {
878  arg->collect_column_var(colvar_set, include_agg);
879  }
880  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
881  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
882  return makeExpr<LikeExpr>(arg->rewrite_with_targetlist(tlist),
883  like_expr->deep_copy(),
884  escape_expr ? escape_expr->deep_copy() : nullptr,
885  is_ilike,
886  is_simple);
887  }
888  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
889  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
890  return makeExpr<LikeExpr>(arg->rewrite_with_child_targetlist(tlist),
891  like_expr->deep_copy(),
892  escape_expr ? escape_expr->deep_copy() : nullptr,
893  is_ilike,
894  is_simple);
895  }
896  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
897  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
898  return makeExpr<LikeExpr>(arg->rewrite_agg_to_var(tlist),
899  like_expr->deep_copy(),
900  escape_expr ? escape_expr->deep_copy() : nullptr,
901  is_ilike,
902  is_simple);
903  }
904  bool operator==(const Expr& rhs) const override;
905  std::string toString() const override;
906  void find_expr(bool (*f)(const Expr*),
907  std::list<const Expr*>& expr_list) const override;
908 
909  private:
910  std::shared_ptr<Analyzer::Expr> arg; // the argument to the left of LIKE
911  std::shared_ptr<Analyzer::Expr> like_expr; // expression that evaluates to like string
912  std::shared_ptr<Analyzer::Expr>
913  escape_expr; // expression that evaluates to escape string, can be nullptr
914  bool is_ilike; // is this ILIKE?
915  bool is_simple; // is this simple, meaning we can use fast path search (fits '%str%'
916  // pattern with no inner '%','_','[',']'
917 };
918 
919 /*
920  * @type RegexpExpr
921  * @brief expression for REGEXP.
922  * arg must evaluate to char, varchar or text.
923  */
924 class RegexpExpr : public Expr {
925  public:
926  RegexpExpr(std::shared_ptr<Analyzer::Expr> a,
927  std::shared_ptr<Analyzer::Expr> p,
928  std::shared_ptr<Analyzer::Expr> e)
929  : Expr(kBOOLEAN, a->get_type_info().get_notnull())
930  , arg(a)
931  , pattern_expr(p)
932  , escape_expr(e) {}
933  const Expr* get_arg() const { return arg.get(); }
934  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
935  const Expr* get_pattern_expr() const { return pattern_expr.get(); }
936  const Expr* get_escape_expr() const { return escape_expr.get(); }
937  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
938  void group_predicates(std::list<const Expr*>& scan_predicates,
939  std::list<const Expr*>& join_predicates,
940  std::list<const Expr*>& const_predicates) const override;
941  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
942  arg->collect_rte_idx(rte_idx_set);
943  }
945  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
946  colvar_set,
947  bool include_agg) const override {
948  arg->collect_column_var(colvar_set, include_agg);
949  }
950  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
951  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
952  return makeExpr<RegexpExpr>(arg->rewrite_with_targetlist(tlist),
953  pattern_expr->deep_copy(),
954  escape_expr ? escape_expr->deep_copy() : nullptr);
955  }
956  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
957  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
958  return makeExpr<RegexpExpr>(arg->rewrite_with_child_targetlist(tlist),
959  pattern_expr->deep_copy(),
960  escape_expr ? escape_expr->deep_copy() : nullptr);
961  }
962  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
963  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
964  return makeExpr<RegexpExpr>(arg->rewrite_agg_to_var(tlist),
965  pattern_expr->deep_copy(),
966  escape_expr ? escape_expr->deep_copy() : nullptr);
967  }
968  bool operator==(const Expr& rhs) const override;
969  std::string toString() const override;
970  void find_expr(bool (*f)(const Expr*),
971  std::list<const Expr*>& expr_list) const override;
972 
973  private:
974  std::shared_ptr<Analyzer::Expr> arg; // the argument to the left of REGEXP
975  std::shared_ptr<Analyzer::Expr>
976  pattern_expr; // expression that evaluates to pattern string
977  std::shared_ptr<Analyzer::Expr>
978  escape_expr; // expression that evaluates to escape string, can be nullptr
979 };
980 
981 /*
982  * @type LikelihoodExpr
983  * @brief expression for LIKELY and UNLIKELY boolean identity functions.
984  */
985 class LikelihoodExpr : public Expr {
986  public:
987  LikelihoodExpr(std::shared_ptr<Analyzer::Expr> a, float l = 0.5)
988  : Expr(kBOOLEAN, a->get_type_info().get_notnull()), arg(a), likelihood(l) {}
989  const Expr* get_arg() const { return arg.get(); }
990  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
991  float get_likelihood() const { return likelihood; }
992  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
993  void group_predicates(std::list<const Expr*>& scan_predicates,
994  std::list<const Expr*>& join_predicates,
995  std::list<const Expr*>& const_predicates) const override;
996  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
997  arg->collect_rte_idx(rte_idx_set);
998  }
1000  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1001  colvar_set,
1002  bool include_agg) const override {
1003  arg->collect_column_var(colvar_set, include_agg);
1004  }
1005  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1006  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1007  return makeExpr<LikelihoodExpr>(arg->rewrite_with_targetlist(tlist), likelihood);
1008  }
1009  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1010  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1011  return makeExpr<LikelihoodExpr>(arg->rewrite_with_child_targetlist(tlist),
1012  likelihood);
1013  }
1014  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1015  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1016  return makeExpr<LikelihoodExpr>(arg->rewrite_agg_to_var(tlist), likelihood);
1017  }
1018  bool operator==(const Expr& rhs) const override;
1019  std::string toString() const override;
1020  void find_expr(bool (*f)(const Expr*),
1021  std::list<const Expr*>& expr_list) const override;
1022 
1023  private:
1024  std::shared_ptr<Analyzer::Expr> arg; // the argument to LIKELY, UNLIKELY
1025  float likelihood;
1026 };
1027 
1028 /*
1029  * @type AggExpr
1030  * @brief expression for builtin SQL aggregates.
1031  */
1032 class AggExpr : public Expr {
1033  public:
1035  SQLAgg a,
1036  std::shared_ptr<Analyzer::Expr> g,
1037  bool d,
1038  std::shared_ptr<Analyzer::Constant> e)
1039  : Expr(ti, true), aggtype(a), arg(g), is_distinct(d), error_rate(e) {}
1041  SQLAgg a,
1042  Expr* g,
1043  bool d,
1044  std::shared_ptr<Analyzer::Constant> e,
1045  int idx)
1046  : Expr(SQLTypeInfo(t, g == nullptr ? true : g->get_type_info().get_notnull()), true)
1047  , aggtype(a)
1048  , arg(g)
1049  , is_distinct(d)
1050  , error_rate(e) {}
1051  SQLAgg get_aggtype() const { return aggtype; }
1052  Expr* get_arg() const { return arg.get(); }
1053  std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
1054  bool get_is_distinct() const { return is_distinct; }
1055  std::shared_ptr<Analyzer::Constant> get_error_rate() const { return error_rate; }
1056  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1057  void group_predicates(std::list<const Expr*>& scan_predicates,
1058  std::list<const Expr*>& join_predicates,
1059  std::list<const Expr*>& const_predicates) const override;
1060  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
1061  if (arg) {
1062  arg->collect_rte_idx(rte_idx_set);
1063  }
1064  };
1066  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1067  colvar_set,
1068  bool include_agg) const override {
1069  if (include_agg && arg != nullptr) {
1070  arg->collect_column_var(colvar_set, include_agg);
1071  }
1072  }
1073  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1074  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1075  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1076  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1077  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1078  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1079  bool operator==(const Expr& rhs) const override;
1080  std::string toString() const override;
1081  void find_expr(bool (*f)(const Expr*),
1082  std::list<const Expr*>& expr_list) const override;
1083 
1084  private:
1085  SQLAgg aggtype; // aggregate type: kAVG, kMIN, kMAX, kSUM, kCOUNT
1086  std::shared_ptr<Analyzer::Expr> arg; // argument to aggregate
1087  bool is_distinct; // true only if it is for COUNT(DISTINCT x)
1088  std::shared_ptr<Analyzer::Constant> error_rate; // error rate of kAPPROX_COUNT_DISTINCT
1089 };
1090 
1091 /*
1092  * @type CaseExpr
1093  * @brief the CASE-WHEN-THEN-ELSE expression
1094  */
1095 class CaseExpr : public Expr {
1096  public:
1098  bool has_agg,
1099  const std::list<std::pair<std::shared_ptr<Analyzer::Expr>,
1100  std::shared_ptr<Analyzer::Expr>>>& w,
1101  std::shared_ptr<Analyzer::Expr> e)
1102  : Expr(ti, has_agg), expr_pair_list(w), else_expr(e) {}
1103  const std::list<
1104  std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>&
1106  return expr_pair_list;
1107  }
1108  const Expr* get_else_expr() const { return else_expr.get(); }
1109  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1110  void check_group_by(
1111  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1112  void group_predicates(std::list<const Expr*>& scan_predicates,
1113  std::list<const Expr*>& join_predicates,
1114  std::list<const Expr*>& const_predicates) const override;
1115  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1116  void collect_column_var(
1117  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1118  colvar_set,
1119  bool include_agg) const override;
1120  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1121  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1122  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1123  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1124  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1125  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1126  bool operator==(const Expr& rhs) const override;
1127  std::string toString() const override;
1128  void find_expr(bool (*f)(const Expr*),
1129  std::list<const Expr*>& expr_list) const override;
1130  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) override;
1131  void get_domain(DomainSet& domain_set) const override;
1132 
1133  private:
1134  std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
1135  expr_pair_list; // a pair of expressions for each WHEN expr1 THEN expr2. expr1
1136  // must be of boolean type. all expr2's must be of compatible
1137  // types and will be promoted to the common type.
1138  std::shared_ptr<Analyzer::Expr> else_expr; // expression for ELSE. nullptr if omitted.
1139 };
1140 
1141 /*
1142  * @type ExtractExpr
1143  * @brief the EXTRACT expression
1144  */
1145 class ExtractExpr : public Expr {
1146  public:
1148  bool has_agg,
1149  ExtractField f,
1150  std::shared_ptr<Analyzer::Expr> e)
1151  : Expr(ti, has_agg), field_(f), from_expr_(e) {}
1152  ExtractField get_field() const { return field_; }
1153  const Expr* get_from_expr() const { return from_expr_.get(); }
1154  const std::shared_ptr<Analyzer::Expr> get_own_from_expr() const { return from_expr_; }
1155  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1156  void check_group_by(
1157  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1158  void group_predicates(std::list<const Expr*>& scan_predicates,
1159  std::list<const Expr*>& join_predicates,
1160  std::list<const Expr*>& const_predicates) const override;
1161  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1162  void collect_column_var(
1163  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1164  colvar_set,
1165  bool include_agg) const override;
1166  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1167  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1168  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1169  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1170  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1171  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1172  bool operator==(const Expr& rhs) const override;
1173  std::string toString() const override;
1174  void find_expr(bool (*f)(const Expr*),
1175  std::list<const Expr*>& expr_list) const override;
1176 
1177  private:
1179  std::shared_ptr<Analyzer::Expr> from_expr_;
1180 };
1181 
1182 /*
1183  * @type DateaddExpr
1184  * @brief the DATEADD expression
1185  */
1186 class DateaddExpr : public Expr {
1187  public:
1189  const DateaddField f,
1190  const std::shared_ptr<Analyzer::Expr> number,
1191  const std::shared_ptr<Analyzer::Expr> datetime)
1192  : Expr(ti, false), field_(f), number_(number), datetime_(datetime) {}
1193  DateaddField get_field() const { return field_; }
1194  const Expr* get_number_expr() const { return number_.get(); }
1195  const Expr* get_datetime_expr() const { return datetime_.get(); }
1196  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1197  void check_group_by(
1198  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1199  void group_predicates(std::list<const Expr*>& scan_predicates,
1200  std::list<const Expr*>& join_predicates,
1201  std::list<const Expr*>& const_predicates) const override;
1202  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1203  void collect_column_var(
1204  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1205  colvar_set,
1206  bool include_agg) const override;
1207  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1208  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1209  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1210  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1211  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1212  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1213  bool operator==(const Expr& rhs) const override;
1214  std::string toString() const override;
1215  void find_expr(bool (*f)(const Expr*),
1216  std::list<const Expr*>& expr_list) const override;
1217 
1218  private:
1220  const std::shared_ptr<Analyzer::Expr> number_;
1221  const std::shared_ptr<Analyzer::Expr> datetime_;
1222 };
1223 
1224 /*
1225  * @type DatediffExpr
1226  * @brief the DATEDIFF expression
1227  */
1228 class DatediffExpr : public Expr {
1229  public:
1231  const DatetruncField f,
1232  const std::shared_ptr<Analyzer::Expr> start,
1233  const std::shared_ptr<Analyzer::Expr> end)
1234  : Expr(ti, false), field_(f), start_(start), end_(end) {}
1235  DatetruncField get_field() const { return field_; }
1236  const Expr* get_start_expr() const { return start_.get(); }
1237  const Expr* get_end_expr() const { return end_.get(); }
1238  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1239  void check_group_by(
1240  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1241  void group_predicates(std::list<const Expr*>& scan_predicates,
1242  std::list<const Expr*>& join_predicates,
1243  std::list<const Expr*>& const_predicates) const override;
1244  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1245  void collect_column_var(
1246  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1247  colvar_set,
1248  bool include_agg) const override;
1249  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1250  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1251  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1252  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1253  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1254  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1255  bool operator==(const Expr& rhs) const override;
1256  std::string toString() const override;
1257  void find_expr(bool (*f)(const Expr*),
1258  std::list<const Expr*>& expr_list) const override;
1259 
1260  private:
1262  const std::shared_ptr<Analyzer::Expr> start_;
1263  const std::shared_ptr<Analyzer::Expr> end_;
1264 };
1265 
1266 /*
1267  * @type DatetruncExpr
1268  * @brief the DATE_TRUNC expression
1269  */
1270 class DatetruncExpr : public Expr {
1271  public:
1273  bool has_agg,
1274  DatetruncField f,
1275  std::shared_ptr<Analyzer::Expr> e)
1276  : Expr(ti, has_agg), field_(f), from_expr_(e) {}
1277  DatetruncField get_field() const { return field_; }
1278  const Expr* get_from_expr() const { return from_expr_.get(); }
1279  const std::shared_ptr<Analyzer::Expr> get_own_from_expr() const { return from_expr_; }
1280  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1281  void check_group_by(
1282  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1283  void group_predicates(std::list<const Expr*>& scan_predicates,
1284  std::list<const Expr*>& join_predicates,
1285  std::list<const Expr*>& const_predicates) const override;
1286  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1287  void collect_column_var(
1288  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1289  colvar_set,
1290  bool include_agg) const override;
1291  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1292  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1293  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1294  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1295  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1296  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1297  bool operator==(const Expr& rhs) const override;
1298  std::string toString() const override;
1299  void find_expr(bool (*f)(const Expr*),
1300  std::list<const Expr*>& expr_list) const override;
1301 
1302  private:
1304  std::shared_ptr<Analyzer::Expr> from_expr_;
1305 };
1306 
1307 class FunctionOper : public Expr {
1308  public:
1310  const std::string& name,
1311  const std::vector<std::shared_ptr<Analyzer::Expr>>& args)
1312  : Expr(ti, false), name_(name), args_(args) {}
1313 
1314  std::string getName() const { return name_; }
1315 
1316  size_t getArity() const { return args_.size(); }
1317 
1318  const Analyzer::Expr* getArg(const size_t i) const {
1319  CHECK_LT(i, args_.size());
1320  return args_[i].get();
1321  }
1322 
1323  std::shared_ptr<Analyzer::Expr> getOwnArg(const size_t i) const {
1324  CHECK_LT(i, args_.size());
1325  return args_[i];
1326  }
1327 
1328  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1329 
1330  bool operator==(const Expr& rhs) const override;
1331  std::string toString() const override;
1332 
1333  private:
1334  const std::string name_;
1335  const std::vector<std::shared_ptr<Analyzer::Expr>> args_;
1336 };
1337 
1339  public:
1341  const SQLTypeInfo& ti,
1342  const std::string& name,
1343  const std::vector<std::shared_ptr<Analyzer::Expr>>& args)
1344  : FunctionOper(ti, name, args) {}
1345 
1346  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1347 
1348  bool operator==(const Expr& rhs) const override;
1349 };
1350 
1351 /*
1352  * @type OffsetInFragment
1353  * @brief The offset of a row in the current fragment. To be used by updates.
1354  */
1355 class OffsetInFragment : public Expr {
1356  public:
1358 
1359  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1360 
1361  bool operator==(const Expr& rhs) const override;
1362  std::string toString() const override;
1363 };
1364 
1365 /*
1366  * @type OrderEntry
1367  * @brief represents an entry in ORDER BY clause.
1368  */
1369 struct OrderEntry {
1370  OrderEntry(int t, bool d, bool nf) : tle_no(t), is_desc(d), nulls_first(nf){};
1372  std::string toString() const;
1373  void print() const { std::cout << toString(); }
1374  int tle_no; /* targetlist entry number: 1-based */
1375  bool is_desc; /* true if order is DESC */
1376  bool nulls_first; /* true if nulls are ordered first. otherwise last. */
1377 };
1378 
1379 /*
1380  * @type WindowFunction
1381  * @brief A window function.
1382  */
1383 class WindowFunction : public Expr {
1384  public:
1386  const SqlWindowFunctionKind kind,
1387  const std::vector<std::shared_ptr<Analyzer::Expr>>& args,
1388  const std::vector<std::shared_ptr<Analyzer::Expr>>& partition_keys,
1389  const std::vector<std::shared_ptr<Analyzer::Expr>>& order_keys,
1390  const std::vector<OrderEntry>& collation)
1391  : Expr(ti)
1392  , kind_(kind)
1393  , args_(args)
1394  , partition_keys_(partition_keys)
1395  , order_keys_(order_keys)
1396  , collation_(collation){};
1397 
1398  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1399 
1400  bool operator==(const Expr& rhs) const override;
1401  std::string toString() const override;
1402 
1404 
1405  const std::vector<std::shared_ptr<Analyzer::Expr>>& getArgs() const { return args_; }
1406 
1407  const std::vector<std::shared_ptr<Analyzer::Expr>>& getPartitionKeys() const {
1408  return partition_keys_;
1409  }
1410 
1411  const std::vector<std::shared_ptr<Analyzer::Expr>>& getOrderKeys() const {
1412  return order_keys_;
1413  }
1414 
1415  const std::vector<OrderEntry>& getCollation() const { return collation_; }
1416 
1417  private:
1419  const std::vector<std::shared_ptr<Analyzer::Expr>> args_;
1420  const std::vector<std::shared_ptr<Analyzer::Expr>> partition_keys_;
1421  const std::vector<std::shared_ptr<Analyzer::Expr>> order_keys_;
1422  const std::vector<OrderEntry> collation_;
1423 };
1424 
1425 /*
1426  * @type ArrayExpr
1427  * @brief Corresponds to ARRAY[] statements in SQL
1428  */
1429 
1430 class ArrayExpr : public Expr {
1431  public:
1432  ArrayExpr(SQLTypeInfo const& array_ti,
1433  ExpressionPtrVector const& array_exprs,
1434  bool is_null = false,
1435  bool local_alloc = false)
1436  : Expr(array_ti)
1437  , contained_expressions_(array_exprs)
1438  , local_alloc_(local_alloc)
1439  , is_null_(is_null) {}
1440 
1441  Analyzer::ExpressionPtr deep_copy() const override;
1442  std::string toString() const override;
1443  bool operator==(Expr const& rhs) const override;
1444  size_t getElementCount() const { return contained_expressions_.size(); }
1445  bool isLocalAlloc() const { return local_alloc_; }
1446  bool isNull() const { return is_null_; }
1447 
1448  const Analyzer::Expr* getElement(const size_t i) const {
1449  CHECK_LT(i, contained_expressions_.size());
1450  return contained_expressions_[i].get();
1451  }
1452 
1453  private:
1456  bool is_null_; // constant is NULL
1457 };
1458 
1459 /*
1460  * @type GeoUOper
1461  * @brief Geo unary operation
1462  */
1463 class GeoUOper : public Expr {
1464  public:
1466  const SQLTypeInfo& ti,
1467  const SQLTypeInfo& ti0,
1468  const std::vector<std::shared_ptr<Analyzer::Expr>>& args)
1469  : Expr(ti), op_(op), ti0_(ti0), args0_(args){};
1470 
1471  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1472 
1473  bool operator==(const Expr& rhs) const override;
1474  std::string toString() const override;
1475 
1477  const SQLTypeInfo getTypeInfo0() const { return ti0_; }
1478  const std::vector<std::shared_ptr<Analyzer::Expr>>& getArgs0() const { return args0_; }
1479 
1480  private:
1482  SQLTypeInfo ti0_; // Type of geo input 0 (or geo output)
1483  const std::vector<std::shared_ptr<Analyzer::Expr>> args0_;
1484 };
1485 
1486 /*
1487  * @type GeoBinOper
1488  * @brief Geo binary operation
1489  */
1490 class GeoBinOper : public Expr {
1491  public:
1493  const SQLTypeInfo& ti,
1494  const SQLTypeInfo& ti0,
1495  const SQLTypeInfo& ti1,
1496  const std::vector<std::shared_ptr<Analyzer::Expr>>& args0,
1497  const std::vector<std::shared_ptr<Analyzer::Expr>>& args1)
1498  : Expr(ti), op_(op), ti0_(ti0), ti1_(ti1), args0_(args0), args1_(args1){};
1499 
1500  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1501 
1502  bool operator==(const Expr& rhs) const override;
1503  std::string toString() const override;
1504 
1506  const SQLTypeInfo getTypeInfo0() const { return ti0_; }
1507  const SQLTypeInfo getTypeInfo1() const { return ti1_; }
1508  const std::vector<std::shared_ptr<Analyzer::Expr>>& getArgs0() const { return args0_; }
1509  const std::vector<std::shared_ptr<Analyzer::Expr>>& getArgs1() const { return args1_; }
1510 
1511  private:
1513  SQLTypeInfo ti0_; // Type of geo input 0 (or geo output)
1514  SQLTypeInfo ti1_; // Type of geo input 1
1515  const std::vector<std::shared_ptr<Analyzer::Expr>> args0_;
1516  const std::vector<std::shared_ptr<Analyzer::Expr>> args1_;
1517 };
1518 
1519 /*
1520  * @type TargetEntry
1521  * @brief Target list defines a relational projection. It is a list of TargetEntry's.
1522  */
1524  public:
1525  TargetEntry(const std::string& n, std::shared_ptr<Analyzer::Expr> e, bool u)
1526  : resname(n), expr(e), unnest(u) {}
1527  virtual ~TargetEntry() {}
1528  const std::string& get_resname() const { return resname; }
1529  void set_resname(const std::string& name) { resname = name; }
1530  Expr* get_expr() const { return expr.get(); }
1531  std::shared_ptr<Expr> get_own_expr() const { return expr; }
1532  void set_expr(std::shared_ptr<Analyzer::Expr> e) { expr = e; }
1533  bool get_unnest() const { return unnest; }
1534  std::string toString() const;
1535  void print() const { std::cout << toString(); }
1536 
1537  private:
1538  std::string resname; // alias name, e.g., SELECT salary + bonus AS compensation,
1539  std::shared_ptr<Analyzer::Expr> expr; // expression to evaluate for the value
1540  bool unnest; // unnest a collection type
1541 };
1542 
1543 class RangeTableEntry;
1544 
1545 /*
1546  * @type Query
1547  * @brief parse tree for a query
1548  */
1549 class Query {
1550  public:
1552  : is_distinct(false)
1553  , where_predicate(nullptr)
1554  , having_predicate(nullptr)
1555  , order_by(nullptr)
1556  , next_query(nullptr)
1557  , is_unionall(false)
1558  , stmt_type(kSELECT)
1559  , num_aggs(0)
1560  , result_table_id(0)
1561  , limit(0)
1562  , offset(0) {}
1563  virtual ~Query();
1564  bool get_is_distinct() const { return is_distinct; }
1565  int get_num_aggs() const { return num_aggs; }
1566  const std::vector<std::shared_ptr<TargetEntry>>& get_targetlist() const {
1567  return targetlist;
1568  }
1569  std::vector<std::shared_ptr<TargetEntry>>& get_targetlist_nonconst() {
1570  return targetlist;
1571  }
1572  const std::vector<RangeTableEntry*>& get_rangetable() const { return rangetable; }
1573  const Expr* get_where_predicate() const { return where_predicate.get(); }
1574  const std::list<std::shared_ptr<Analyzer::Expr>>& get_group_by() const {
1575  return group_by;
1576  };
1577  const Expr* get_having_predicate() const { return having_predicate.get(); }
1578  const std::list<OrderEntry>* get_order_by() const { return order_by; }
1579  const Query* get_next_query() const { return next_query; }
1581  bool get_is_unionall() const { return is_unionall; }
1582  int get_result_table_id() const { return result_table_id; }
1583  const std::list<int>& get_result_col_list() const { return result_col_list; }
1584  void set_result_col_list(const std::list<int>& col_list) { result_col_list = col_list; }
1585  void set_result_table_id(int id) { result_table_id = id; }
1586  void set_is_distinct(bool d) { is_distinct = d; }
1587  void set_where_predicate(std::shared_ptr<Analyzer::Expr> p) { where_predicate = p; }
1588  void set_group_by(std::list<std::shared_ptr<Analyzer::Expr>>& g) { group_by = g; }
1589  void set_having_predicate(std::shared_ptr<Analyzer::Expr> p) { having_predicate = p; }
1590  void set_order_by(std::list<OrderEntry>* o) { order_by = o; }
1591  void set_next_query(Query* q) { next_query = q; }
1592  void set_is_unionall(bool u) { is_unionall = u; }
1594  void set_num_aggs(int a) { num_aggs = a; }
1595  int get_rte_idx(const std::string& range_var_name) const;
1596  RangeTableEntry* get_rte(int rte_idx) const { return rangetable[rte_idx]; }
1597  void add_rte(RangeTableEntry* rte);
1598  void add_tle(std::shared_ptr<TargetEntry> tle) { targetlist.push_back(tle); }
1599  int64_t get_limit() const { return limit; }
1600  void set_limit(int64_t l) { limit = l; }
1601  int64_t get_offset() const { return offset; }
1602  void set_offset(int64_t o) { offset = o; }
1603 
1604  private:
1605  bool is_distinct; // true only if SELECT DISTINCT
1606  std::vector<std::shared_ptr<TargetEntry>> targetlist; // represents the SELECT clause
1607  std::vector<RangeTableEntry*> rangetable; // represents the FROM clause for SELECT. For
1608  // INSERT, DELETE, UPDATE the result table is
1609  // always the first entry in rangetable.
1610  std::shared_ptr<Analyzer::Expr> where_predicate; // represents the WHERE clause
1611  std::list<std::shared_ptr<Analyzer::Expr>> group_by; // represents the GROUP BY clause
1612  std::shared_ptr<Analyzer::Expr> having_predicate; // represents the HAVING clause
1613  std::list<OrderEntry>* order_by; // represents the ORDER BY clause
1614  Query* next_query; // the next query to UNION
1615  bool is_unionall; // true only if it is UNION ALL
1617  int num_aggs; // number of aggregate functions in query
1618  int result_table_id; // for INSERT statements only
1619  std::list<int> result_col_list; // for INSERT statement only
1620  int64_t limit; // row count for LIMIT clause. 0 means ALL
1621  int64_t offset; // offset in OFFSET clause. 0 means no offset.
1622 };
1623 } // namespace Analyzer
1624 
1625 inline std::shared_ptr<Analyzer::Var> var_ref(const Analyzer::Expr* expr,
1626  const Analyzer::Var::WhichRow which_row,
1627  const int varno) {
1628  const auto col_expr = dynamic_cast<const Analyzer::ColumnVar*>(expr);
1629  const int table_id = col_expr ? col_expr->get_table_id() : 0;
1630  const int column_id = col_expr ? col_expr->get_column_id() : 0;
1631  const int rte_idx = col_expr ? col_expr->get_rte_idx() : -1;
1632  return makeExpr<Analyzer::Var>(
1633  expr->get_type_info(), table_id, column_id, rte_idx, which_row, varno);
1634 }
1635 
1636 // Returns true iff the two expression lists are equal (same size and each element are
1637 // equal).
1638 bool expr_list_match(const std::vector<std::shared_ptr<Analyzer::Expr>>& lhs,
1639  const std::vector<std::shared_ptr<Analyzer::Expr>>& rhs);
1640 
1641 // Remove a cast operator if present.
1642 std::shared_ptr<Analyzer::Expr> remove_cast(const std::shared_ptr<Analyzer::Expr>& expr);
1643 
1644 #endif // ANALYZER_H
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2914
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1024
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:3149
std::list< ExpressionPtr > ExpressionPtrList
Definition: Analyzer.h:182
int get_table_id() const
Definition: Analyzer.h:195
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:974
Query * next_query
Definition: Analyzer.h:1614
CaseExpr(const SQLTypeInfo &ti, bool has_agg, const std::list< std::pair< std::shared_ptr< Analyzer::Expr >, std::shared_ptr< Analyzer::Expr >>> &w, std::shared_ptr< Analyzer::Expr > e)
Definition: Analyzer.h:1097
InIntegerSet(const std::shared_ptr< const Analyzer::Expr > a, const std::vector< int64_t > &values, const bool not_null)
Definition: Analyzer.cpp:1545
virtual void get_domain(DomainSet &domain_set) const
Definition: Analyzer.h:174
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1837
bool operator==(const Expr &rhs) const override
Definition: Analyzer.h:562
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:597
TargetEntry(const std::string &n, std::shared_ptr< Analyzer::Expr > e, bool u)
Definition: Analyzer.h:1525
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:282
Query * parsetree
Definition: Analyzer.h:573
const std::list< std::shared_ptr< Analyzer::Expr > > & get_value_list() const
Definition: Analyzer.h:338
SQLAgg
Definition: sqldefs.h:71
float get_likelihood() const
Definition: Analyzer.h:991
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1986
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:285
std::shared_ptr< Analyzer::Expr > expr
Definition: Analyzer.h:1539
virtual bool operator==(const Expr &rhs) const =0
std::string toString() const override
Definition: Analyzer.cpp:2533
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1403
Var(const SQLTypeInfo &ti, int r, int c, int i, WhichRow o, int v)
Definition: Analyzer.h:270
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:206
virtual ~Expr()
Definition: Analyzer.h:77
Expr(SQLTypes t, int d, int s, bool notnull)
Definition: Analyzer.h:73
bool unnest
Definition: Analyzer.h:1540
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1531
InValues(std::shared_ptr< Analyzer::Expr > a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
Definition: Analyzer.cpp:1527
const Expr * get_from_expr() const
Definition: Analyzer.h:1153
static bool simple_predicate_has_simple_cast(const std::shared_ptr< Analyzer::Expr > cast_operand, const std::shared_ptr< Analyzer::Expr > const_operand)
Definition: Analyzer.cpp:1392
Constant(const SQLTypeInfo &ti, bool n, Datum v)
Definition: Analyzer.h:323
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:934
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2290
std::string toString() const override
Definition: Analyzer.cpp:2380
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2889
Var(const SQLTypeInfo &ti, WhichRow o, int v)
Definition: Analyzer.h:272
void get_domain(DomainSet &domain_set) const override
Definition: Analyzer.cpp:3051
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2008
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:755
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2110
const Expr * get_else_expr() const
Definition: Analyzer.h:1108
const SQLTypeInfo getTypeInfo0() const
Definition: Analyzer.h:1506
void set_contains_agg(bool a)
Definition: Analyzer.h:82
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:208
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs0() const
Definition: Analyzer.h:1508
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:3118
const std::vector< int64_t > & get_value_list() const
Definition: Analyzer.h:636
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2806
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2102
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:753
OrderEntry(int t, bool d, bool nf)
Definition: Analyzer.h:1370
const Expr * get_escape_expr() const
Definition: Analyzer.h:864
virtual std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
Definition: Analyzer.h:126
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:739
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:816
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1915
std::shared_ptr< Analyzer::Expr > decompress()
Definition: Analyzer.cpp:671
size_t getArity() const
Definition: Analyzer.h:1316
Definition: Analyzer.h:1523
DatediffExpr(const SQLTypeInfo &ti, const DatetruncField f, const std::shared_ptr< Analyzer::Expr > start, const std::shared_ptr< Analyzer::Expr > end)
Definition: Analyzer.h:1230
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:86
std::shared_ptr< Analyzer::Expr > remove_cast(const std::shared_ptr< Analyzer::Expr > &expr)
Definition: Analyzer.cpp:3196
static bool colvar_comp(const ColumnVar *l, const ColumnVar *r)
Definition: Analyzer.h:209
SQLTypes
Definition: sqltypes.h:39
void add_rte(RangeTableEntry *rte)
Definition: Analyzer.cpp:1345
const SQLTypeInfo getTypeInfo0() const
Definition: Analyzer.h:1477
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:412
AggExpr(SQLTypes t, SQLAgg a, Expr *g, bool d, std::shared_ptr< Analyzer::Constant > e, int idx)
Definition: Analyzer.h:1040
EncodingType
Definition: encodetypes.h:22
virtual void print() const
Definition: Analyzer.h:151
std::list< int > result_col_list
Definition: Analyzer.h:1619
void set_varno(int n)
Definition: Analyzer.h:277
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:693
std::list< std::pair< std::shared_ptr< Analyzer::Expr >, std::shared_ptr< Analyzer::Expr > > > expr_pair_list
Definition: Analyzer.h:1135
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:214
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1682
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1972
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:394
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2307
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:496
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:990
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1958
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2150
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1467
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:944
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2836
SQLQualifier
Definition: sqldefs.h:69
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:2779
std::shared_ptr< Analyzer::Expr > right_operand
Definition: Analyzer.h:518
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:1060
SQLStmtType stmt_type
Definition: Analyzer.h:1616
std::shared_ptr< Analyzer::Constant > get_error_rate() const
Definition: Analyzer.h:1055
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:978
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:193
const Query * get_parsetree() const
Definition: Analyzer.h:533
bool operator==(Expr const &rhs) const override
Definition: Analyzer.cpp:2326
ExtractField get_field() const
Definition: Analyzer.h:1152
std::shared_ptr< Analyzer::Constant > error_rate
Definition: Analyzer.h:1088
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1805
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1564
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:130
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:126
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:289
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:95
const Expr * get_escape_expr() const
Definition: Analyzer.h:936
const Expr * get_right_operand() const
Definition: Analyzer.h:444
SQLOps
Definition: sqldefs.h:29
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1648
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:2966
std::string toString() const override
Definition: Analyzer.cpp:2727
std::shared_ptr< Analyzer::Expr > get_shared_ptr()
Definition: Analyzer.h:78
virtual void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const
Definition: Analyzer.h:84
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:874
std::list< std::shared_ptr< Analyzer::Expr > > group_by
Definition: Analyzer.h:1611
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:615
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:80
void print() const
Definition: Analyzer.h:1535
const std::vector< std::shared_ptr< Analyzer::Expr > > args0_
Definition: Analyzer.h:1483
SQLTypeInfo ti0_
Definition: Analyzer.h:1513
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:558
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:911
bool get_is_null() const
Definition: Analyzer.h:335
const std::vector< std::shared_ptr< Analyzer::Expr > > args0_
Definition: Analyzer.h:1515
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:996
std::string toString() const override
Definition: Analyzer.cpp:3140
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:826
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3005
int tle_no
Definition: Analyzer.h:1374
~OrderEntry()
Definition: Analyzer.h:1371
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:134
std::shared_ptr< Analyzer::Var > var_ref(const Analyzer::Expr *expr, const Analyzer::Var::WhichRow which_row, const int varno)
Definition: Analyzer.h:1625
const std::shared_ptr< const Analyzer::Expr > arg
Definition: Analyzer.h:644
const std::shared_ptr< Analyzer::Expr > get_own_operand() const
Definition: Analyzer.h:373
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:194
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:198
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:487
void cast_from_string(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:1059
bool get_contains_agg() const
Definition: Analyzer.h:81
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3046
GeoBinOper(const Geo_namespace::GeoBase::GeoOp op, const SQLTypeInfo &ti, const SQLTypeInfo &ti0, const SQLTypeInfo &ti1, const std::vector< std::shared_ptr< Analyzer::Expr >> &args0, const std::vector< std::shared_ptr< Analyzer::Expr >> &args1)
Definition: Analyzer.h:1492
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
Definition: Analyzer.cpp:1302
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1009
const SQLTypeInfo getTypeInfo1() const
Definition: Analyzer.h:1507
std::shared_ptr< Analyzer::Expr > ExpressionPtr
Definition: Analyzer.h:181
const Expr * get_arg() const
Definition: Analyzer.h:933
const std::vector< std::shared_ptr< Analyzer::Expr > > order_keys_
Definition: Analyzer.h:1421
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1950
void set_order_by(std::list< OrderEntry > *o)
Definition: Analyzer.h:1590
Expr * get_arg() const
Definition: Analyzer.h:1052
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2233
DatetruncField get_field() const
Definition: Analyzer.h:1277
const std::list< OrderEntry > * get_order_by() const
Definition: Analyzer.h:1578
void set_result_col_list(const std::list< int > &col_list)
Definition: Analyzer.h:1584
const Expr * get_arg() const
Definition: Analyzer.h:989
void set_which_row(WhichRow r)
Definition: Analyzer.h:275
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
Definition: Analyzer.cpp:1283
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1086
const Expr * get_where_predicate() const
Definition: Analyzer.h:1573
int get_num_aggs() const
Definition: Analyzer.h:1565
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:3158
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:880
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:59
const std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1335
const std::vector< std::shared_ptr< Analyzer::Expr > > partition_keys_
Definition: Analyzer.h:1420
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2212
void set_offset(int64_t o)
Definition: Analyzer.h:1602
UOper(SQLTypes t, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:367
~Constant() override
Definition: Analyzer.cpp:41
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2142
SQLQualifier qualifier
Definition: Analyzer.h:515
bool isNull() const
Definition: Analyzer.h:1446
std::string toString() const override
Definition: Analyzer.cpp:2663
const std::vector< std::shared_ptr< Analyzer::Expr > > & getOrderKeys() const
Definition: Analyzer.h:1411
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1578
std::string toString() const override
Definition: Analyzer.cpp:2442
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:478
SQLTypeInfo type_info
Definition: Analyzer.h:177
const std::vector< OrderEntry > & getCollation() const
Definition: Analyzer.h:1415
EncodingType get_compression() const
Definition: Analyzer.h:198
std::list< const Expr * > DomainSet
Definition: Analyzer.h:62
virtual void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const
Definition: Analyzer.h:117
void set_constval(Datum d)
Definition: Analyzer.h:337
const Expr * get_arg() const
Definition: Analyzer.h:861
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:725
std::enable_if< std::is_base_of< Analyzer::Expr, Tp >::value, std::shared_ptr< Tp > >::type makeExpr(Args &&...args)
Definition: Analyzer.h:53
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2867
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.h:538
std::string toString() const override
Definition: Analyzer.cpp:2389
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:1377
const std::string & get_resname() const
Definition: Analyzer.h:1528
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1944
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:962
~Subquery() override
Definition: Analyzer.cpp:47
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:554
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2250
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:678
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:956
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:544
int get_rte_idx(const std::string &range_var_name) const
Definition: Analyzer.cpp:1334
void cast_string(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:1048
void set_type_info(const SQLTypeInfo &ti)
Definition: Analyzer.h:80
const std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1419
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3029
std::string toString() const override
Definition: Analyzer.cpp:2411
const std::shared_ptr< Analyzer::Expr > get_own_from_expr() const
Definition: Analyzer.h:1279
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:69
std::string toString() const override
Definition: Analyzer.cpp:2510
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:771
LikelihoodExpr(std::shared_ptr< Analyzer::Expr > a, float l=0.5)
Definition: Analyzer.h:987
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2131
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2789
BinOper(const SQLTypeInfo &ti, bool has_agg, SQLOps o, SQLQualifier q, std::shared_ptr< Analyzer::Expr > l, std::shared_ptr< Analyzer::Expr > r)
Definition: Analyzer.h:423
std::string toString() const override
Definition: Analyzer.cpp:2574
std::string toString() const override
Definition: Analyzer.cpp:2596
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:830
std::string toString() const override
Definition: Analyzer.cpp:2544
bool get_calc_encoded_length() const
Definition: Analyzer.h:659
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1828
std::string toString() const override
Definition: Analyzer.cpp:2704
DatetruncField field_
Definition: Analyzer.h:1303
std::string toString() const override
Definition: Analyzer.cpp:2681
SQLOps get_optype() const
Definition: Analyzer.h:440
std::shared_ptr< Analyzer::Expr > left_operand
Definition: Analyzer.h:517
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2311
const std::vector< std::shared_ptr< Analyzer::Expr > > args1_
Definition: Analyzer.h:1516
std::string toString() const
Definition: Analyzer.cpp:2757
const Query * get_next_query() const
Definition: Analyzer.h:1579
std::shared_ptr< Analyzer::Expr > normalize_simple_predicate(int &rte_idx) const override
Definition: Analyzer.cpp:1416
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:617
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:152
static SQLTypeInfo common_string_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:394
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:467
DatetruncExpr(const SQLTypeInfo &ti, bool has_agg, DatetruncField f, std::shared_ptr< Analyzer::Expr > e)
Definition: Analyzer.h:1272
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1459
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:471
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:163
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.h:567
Expr(const SQLTypeInfo &ti, bool has_agg=false)
Definition: Analyzer.h:75
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1869
const DatetruncField field_
Definition: Analyzer.h:1261
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1592
CHECK(cgen_state)
const std::vector< std::shared_ptr< Analyzer::Expr > > & getTuple() const
Definition: Analyzer.h:245
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:2971
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1992
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs() const
Definition: Analyzer.h:1405
RangeTableEntry * get_rte(int rte_idx) const
Definition: Analyzer.h:1596
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:2962
const std::shared_ptr< Analyzer::Expr > get_own_from_expr() const
Definition: Analyzer.h:1154
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2854
DateaddField
Definition: DateAdd.h:42
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:888
const Geo_namespace::GeoBase::GeoOp op_
Definition: Analyzer.h:1512
std::vector< std::shared_ptr< TargetEntry > > targetlist
Definition: Analyzer.h:1606
std::string toString() const override
Definition: Analyzer.cpp:2556
const DateaddField field_
Definition: Analyzer.h:1219
DatetruncField
Definition: DateTruncate.h:42
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:108
std::shared_ptr< Analyzer::Expr > from_expr_
Definition: Analyzer.h:1304
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:586
bool expr_list_match(const std::vector< std::shared_ptr< Analyzer::Expr >> &lhs, const std::vector< std::shared_ptr< Analyzer::Expr >> &rhs)
Definition: Analyzer.cpp:3183
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:795
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2525
Subquery(const SQLTypeInfo &ti, Query *q)
Definition: Analyzer.h:530
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs0() const
Definition: Analyzer.h:1478
std::shared_ptr< Analyzer::Expr > getOwnArg(const size_t i) const
Definition: Analyzer.h:1323
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:383
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:380
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:179
Expr * get_expr() const
Definition: Analyzer.h:1530
int64_t get_offset() const
Definition: Analyzer.h:1601
std::string toString() const override
Definition: Analyzer.cpp:2374
GeoUOper(const Geo_namespace::GeoBase::GeoOp op, const SQLTypeInfo &ti, const SQLTypeInfo &ti0, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
Definition: Analyzer.h:1465
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:1365
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1263
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2273
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:822
std::string toString() const override
Definition: Analyzer.cpp:2585
WhichRow get_which_row() const
Definition: Analyzer.h:274
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3034
void set_expr(std::shared_ptr< Analyzer::Expr > e)
Definition: Analyzer.h:1532
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2198
const std::shared_ptr< Analyzer::Expr > number_
Definition: Analyzer.h:1220
ArrayExpr(SQLTypeInfo const &array_ti, ExpressionPtrVector const &array_exprs, bool is_null=false, bool local_alloc=false)
Definition: Analyzer.h:1432
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:349
std::string resname
Definition: Analyzer.h:1538
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:2521
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2281
bool get_is_distinct() const
Definition: Analyzer.h:1564
std::string toString() const override
Definition: Analyzer.cpp:2673
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:673
static SQLTypeInfo common_numeric_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:434
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:2976
SQLTypeInfo ti1_
Definition: Analyzer.h:1514
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1846
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:550
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1606
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2014
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1262
virtual ~TargetEntry()
Definition: Analyzer.h:1527
int get_varno() const
Definition: Analyzer.h:276
std::string toString() const
Definition: Analyzer.cpp:2767
bool get_is_simple() const
Definition: Analyzer.h:866
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:813
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1620
bool nulls_first
Definition: Analyzer.h:1376
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:2980
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:658
int64_t get_limit() const
Definition: Analyzer.h:1599
bool get_is_distinct() const
Definition: Analyzer.h:1054
FunctionOperWithCustomTypeHandling(const SQLTypeInfo &ti, const std::string &name, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
Definition: Analyzer.h:1340
bool get_unnest() const
Definition: Analyzer.h:1533
Geo_namespace::GeoBase::GeoOp getOp() const
Definition: Analyzer.h:1505
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2119
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:667
const std::vector< OrderEntry > collation_
Definition: Analyzer.h:1422
bool g_enable_smem_group_by true
ExtractExpr(const SQLTypeInfo &ti, bool has_agg, ExtractField f, std::shared_ptr< Analyzer::Expr > e)
Definition: Analyzer.h:1147
const Expr * get_start_expr() const
Definition: Analyzer.h:1236
void do_cast(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:1128
std::string toString() const override
Definition: Analyzer.cpp:2396
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1726
Constant(const SQLTypeInfo &ti, bool n, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
Definition: Analyzer.h:330
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2358
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2933
void set_num_aggs(int a)
Definition: Analyzer.h:1594
void set_group_by(std::list< std::shared_ptr< Analyzer::Expr >> &g)
Definition: Analyzer.h:1588
WhichRow which_row
Definition: Analyzer.h:297
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1886
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3012
void add_tle(std::shared_ptr< TargetEntry > tle)
Definition: Analyzer.h:1598
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1696
void set_next_query(Query *q)
Definition: Analyzer.h:1591
bool get_is_unionall() const
Definition: Analyzer.h:1581
int get_result_table_id() const
Definition: Analyzer.h:1582
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:3110
size_t getElementCount() const
Definition: Analyzer.h:1444
SQLStmtType
Definition: sqldefs.h:101
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:910
const std::vector< std::shared_ptr< Analyzer::Expr > > tuple_
Definition: Analyzer.h:255
void set_having_predicate(std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:1589
void set_result_table_id(int id)
Definition: Analyzer.h:1585
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:721
const std::vector< int64_t > value_list
Definition: Analyzer.h:645
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:389
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:683
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:2952
const Expr * get_pattern_expr() const
Definition: Analyzer.h:935
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:664
#define CHECK_LT(x, y)
Definition: Logger.h:207
int64_t offset
Definition: Analyzer.h:1621
virtual std::string toString() const =0
ExpressionPtrVector contained_expressions_
Definition: Analyzer.h:1454
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1860
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1662
UOper(const SQLTypeInfo &ti, bool has_agg, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:365
const Expr * get_from_expr() const
Definition: Analyzer.h:1278
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2943
virtual ~Query()
Definition: Analyzer.cpp:51
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2845
const Expr * get_datetime_expr() const
Definition: Analyzer.h:1195
void set_is_distinct(bool d)
Definition: Analyzer.h:1586
WindowFunction(const SQLTypeInfo &ti, const SqlWindowFunctionKind kind, const std::vector< std::shared_ptr< Analyzer::Expr >> &args, const std::vector< std::shared_ptr< Analyzer::Expr >> &partition_keys, const std::vector< std::shared_ptr< Analyzer::Expr >> &order_keys, const std::vector< OrderEntry > &collation)
Definition: Analyzer.h:1385
int get_comp_param() const
Definition: Analyzer.h:199
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:265
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:215
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:175
bool is_null(const T &v, const SQLTypeInfo &t)
bool isLocalAlloc() const
Definition: Analyzer.h:1445
std::string toString() const override
Definition: Analyzer.cpp:2659
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:776
const Expr * get_like_expr() const
Definition: Analyzer.h:863
std::vector< std::shared_ptr< TargetEntry > > & get_targetlist_nonconst()
Definition: Analyzer.h:1569
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:766
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2798
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1740
const Analyzer::Expr * getArg(const size_t i) const
Definition: Analyzer.h:1318
RegexpExpr(std::shared_ptr< Analyzer::Expr > a, std::shared_ptr< Analyzer::Expr > p, std::shared_ptr< Analyzer::Expr > e)
Definition: Analyzer.h:926
std::string toString() const override
Definition: Analyzer.cpp:2677
int get_rte_idx() const
Definition: Analyzer.h:197
const Expr * get_operand() const
Definition: Analyzer.h:372
Analyzer::ExpressionPtr deep_copy() const override
Definition: Analyzer.cpp:203
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:729
Datum get_constval() const
Definition: Analyzer.h:336
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2818
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2035
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1634
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:950
void set_is_unionall(bool u)
Definition: Analyzer.h:1592
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
Definition: Analyzer.cpp:1257
const Expr * get_arg() const
Definition: Analyzer.h:657
void set_resname(const std::string &name)
Definition: Analyzer.h:1529
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:759
const std::list< std::shared_ptr< Analyzer::Expr > > & get_value_list() const
Definition: Analyzer.h:587
std::string toString() const override
Definition: Analyzer.cpp:2668
std::vector< RangeTableEntry * > rangetable
Definition: Analyzer.h:1607
std::shared_ptr< Analyzer::Expr > from_expr_
Definition: Analyzer.h:1179
std::string toString() const override
Definition: Analyzer.cpp:2602
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2000
Expression class for the LOWER (lowercase) string function. The &quot;arg&quot; constructor parameter must be a...
Definition: Analyzer.h:747
virtual std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:685
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:1372
void cast_number(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:753
ExtractField
virtual void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const
Definition: Analyzer.h:160
virtual std::shared_ptr< Analyzer::Expr > deep_copy() const =0
SqlWindowFunctionKind
Definition: sqldefs.h:82
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:871
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:63
SQLTypeInfo ti0_
Definition: Analyzer.h:1482
void set_where_predicate(std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:1587
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:266
void set_stmt_type(SQLStmtType t)
Definition: Analyzer.h:1593
const Expr * get_having_predicate() const
Definition: Analyzer.h:1577
DateaddField get_field() const
Definition: Analyzer.h:1193
SQLAgg get_aggtype() const
Definition: Analyzer.h:1051
std::string toString() const override
Definition: Analyzer.cpp:2689
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:808
virtual std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
Definition: Analyzer.h:145
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:146
const std::shared_ptr< Analyzer::Expr > datetime_
Definition: Analyzer.h:1221
KeyForStringExpr(std::shared_ptr< Analyzer::Expr > a)
Definition: Analyzer.h:704
Constant(SQLTypes t, bool n)
Definition: Analyzer.h:309
const Expr * get_arg() const
Definition: Analyzer.h:706
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2923
std::shared_ptr< Expr > get_own_expr() const
Definition: Analyzer.h:1531
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:840
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1819
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2899
virtual std::shared_ptr< Analyzer::Expr > normalize_simple_predicate(int &rte_idx) const
Definition: Analyzer.h:95
bool g_enable_watchdog false
Definition: Execute.cpp:74
void set_notnull(bool n)
Definition: sqltypes.h:354
virtual void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const
Definition: Analyzer.h:103
const Expr * get_end_expr() const
Definition: Analyzer.h:1237
SQLStmtType get_stmt_type() const
Definition: Analyzer.h:1580
LikeExpr(std::shared_ptr< Analyzer::Expr > a, std::shared_ptr< Analyzer::Expr > l, std::shared_ptr< Analyzer::Expr > e, bool i, bool s)
Definition: Analyzer.h:850
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2161
ExtractField field_
Definition: Analyzer.h:1178
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1966
BinOper(SQLTypes t, SQLOps o, SQLQualifier q, std::shared_ptr< Analyzer::Expr > l, std::shared_ptr< Analyzer::Expr > r)
Definition: Analyzer.h:430
bool is_desc
Definition: Analyzer.h:1375
std::string toString() const override
Definition: Analyzer.cpp:2563
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
Definition: Analyzer.cpp:1328
std::shared_ptr< Analyzer::Expr > having_predicate
Definition: Analyzer.h:1612
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:707
Expr(SQLTypes t, int d, bool notnull)
Definition: Analyzer.h:71
void cast_to_string(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:1067
virtual void collect_rte_idx(std::set< int > &rte_idx_set) const
Definition: Analyzer.h:110
const std::list< std::shared_ptr< Analyzer::Expr > > & get_group_by() const
Definition: Analyzer.h:1574
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:122
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:543
std::vector< ExpressionPtr > ExpressionPtrVector
Definition: Analyzer.h:183
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1481
std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:1053
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:114
DateaddExpr(const SQLTypeInfo &ti, const DateaddField f, const std::shared_ptr< Analyzer::Expr > number, const std::shared_ptr< Analyzer::Expr > datetime)
Definition: Analyzer.h:1188
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:913
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1550
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:896
const Expr * get_left_operand() const
Definition: Analyzer.h:443
bool is_overlaps_oper() const
Definition: Analyzer.h:441
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:189
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:99
CharLengthExpr(std::shared_ptr< Analyzer::Expr > a, bool e)
Definition: Analyzer.h:655
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:2992
ExpressionTuple(const std::vector< std::shared_ptr< Analyzer::Expr >> &tuple)
Definition: Analyzer.h:242
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2880
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:999
Definition: sqltypes.h:46
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1929
const SqlWindowFunctionKind kind_
Definition: Analyzer.h:1418
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:1349
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:862
int get_column_id() const
Definition: Analyzer.h:196
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:399
std::string toString() const override
Definition: Analyzer.cpp:2506
const std::shared_ptr< Analyzer::Expr > get_own_right_operand() const
Definition: Analyzer.h:448
Constant(SQLTypes t, bool n, Datum v)
Definition: Analyzer.h:316
std::string getName() const
Definition: Analyzer.h:1314
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:1065
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2299
void print() const
Definition: Analyzer.h:1373
const Expr * get_arg() const
Definition: Analyzer.h:634
std::shared_ptr< Analyzer::Expr > where_predicate
Definition: Analyzer.h:1610
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1014
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:715
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1005
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2085
Definition: Analyzer.h:1369
void set_limit(int64_t l)
Definition: Analyzer.h:1600
Geo_namespace::GeoBase::GeoOp getOp() const
Definition: Analyzer.h:1476
std::string toString() const override
Definition: Analyzer.cpp:2567
void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const override
Definition: Analyzer.cpp:1711
const std::list< int > & get_result_col_list() const
Definition: Analyzer.h:1583
const std::vector< std::shared_ptr< Analyzer::Expr > > & getPartitionKeys() const
Definition: Analyzer.h:1407
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:138
int64_t limit
Definition: Analyzer.h:1620
bool contains_agg
Definition: Analyzer.h:178
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:594
const Expr * get_arg() const
Definition: Analyzer.h:807
const Geo_namespace::GeoBase::GeoOp op_
Definition: Analyzer.h:1481
DatetruncField get_field() const
Definition: Analyzer.h:1235
const std::vector< std::shared_ptr< TargetEntry > > & get_targetlist() const
Definition: Analyzer.h:1566
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2827
std::list< OrderEntry > * order_by
Definition: Analyzer.h:1613
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:84
std::shared_ptr< Analyzer::Expr > pattern_expr
Definition: Analyzer.h:976
AggExpr(const SQLTypeInfo &ti, SQLAgg a, std::shared_ptr< Analyzer::Expr > g, bool d, std::shared_ptr< Analyzer::Constant > e)
Definition: Analyzer.h:1034
const std::vector< RangeTableEntry * > & get_rangetable() const
Definition: Analyzer.h:1572
std::string toString() const override
Definition: Analyzer.cpp:2642
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3040
std::shared_ptr< Analyzer::Expr > else_expr
Definition: Analyzer.h:1138
const Expr * get_arg() const
Definition: Analyzer.h:585
const std::shared_ptr< Analyzer::Expr > get_own_left_operand() const
Definition: Analyzer.h:445
virtual std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
Definition: Analyzer.h:135
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:155
static SQLTypeInfo analyze_type_info(SQLOps op, const SQLTypeInfo &left_type, const SQLTypeInfo &right_type, SQLTypeInfo *new_left_type, SQLTypeInfo *new_right_type)
Definition: Analyzer.cpp:219
SQLOps get_optype() const
Definition: Analyzer.h:371
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs1() const
Definition: Analyzer.h:1509
const std::list< std::pair< std::shared_ptr< Analyzer::Expr >, std::shared_ptr< Analyzer::Expr > > > & get_expr_pair_list() const
Definition: Analyzer.h:1105
FunctionOper(const SQLTypeInfo &ti, const std::string &name, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
Definition: Analyzer.h:1309
const Expr * get_arg() const
Definition: Analyzer.h:751
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:2998
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:712
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3018
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1923
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:184
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2180
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2346
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1778
CardinalityExpr(std::shared_ptr< Analyzer::Expr > a)
Definition: Analyzer.h:805
SQLOps optype
Definition: Analyzer.h:411
const Expr * get_number_expr() const
Definition: Analyzer.h:1194
const std::string name_
Definition: Analyzer.h:1334
bool get_is_ilike() const
Definition: Analyzer.h:865
LowerExpr(std::shared_ptr< Analyzer::Expr > arg)
Definition: Analyzer.h:749
const Analyzer::Expr * getElement(const size_t i) const
Definition: Analyzer.h:1448
SQLQualifier get_qualifier() const
Definition: Analyzer.h:442
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1901
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1754
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:941
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1907