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