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