OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analyzer.h
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, 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 
22 #ifndef ANALYZER_H
23 #define ANALYZER_H
24 
25 #include "Geospatial/Types.h"
26 #include "Logger/Logger.h"
27 #include "Shared/sqldefs.h"
28 #include "Shared/sqltypes.h"
29 
30 #include <cstdint>
31 #include <iostream>
32 #include <list>
33 #include <optional>
34 #include <set>
35 #include <string>
36 #include <type_traits>
37 #include <utility>
38 #include <vector>
39 
40 namespace Analyzer {
41 class Expr;
42 }
43 
44 namespace Catalog_Namespace {
45 class Catalog;
46 }
47 
48 template <typename Tp, typename... Args>
49 inline typename std::enable_if<std::is_base_of<Analyzer::Expr, Tp>::value,
50  std::shared_ptr<Tp>>::type
51 makeExpr(Args&&... args) {
52  return std::make_shared<Tp>(std::forward<Args>(args)...);
53 }
54 
55 namespace Analyzer {
56 
57 class ColumnVar;
58 class TargetEntry;
59 class Expr;
60 using DomainSet = std::list<const Expr*>;
61 
62 /*
63  * @type Expr
64  * @brief super class for all expressions in parse trees and in query plans
65  */
66 class Expr : public std::enable_shared_from_this<Expr> {
67  public:
68  Expr(SQLTypes t, bool notnull) : type_info(t, notnull), contains_agg(false) {}
69  Expr(SQLTypes t, int d, bool notnull)
70  : type_info(t, d, 0, notnull), contains_agg(false) {}
71  Expr(SQLTypes t, int d, int s, bool notnull)
72  : type_info(t, d, s, notnull), contains_agg(false) {}
73  Expr(const SQLTypeInfo& ti, bool has_agg = false)
74  : type_info(ti), contains_agg(has_agg) {}
75  virtual ~Expr() {}
76  std::shared_ptr<Analyzer::Expr> get_shared_ptr() { return shared_from_this(); }
77  const SQLTypeInfo& get_type_info() const { return type_info; }
78  void set_type_info(const SQLTypeInfo& ti) { type_info = ti; }
79  bool get_contains_agg() const { return contains_agg; }
80  void set_contains_agg(bool a) { contains_agg = a; }
81  virtual std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info);
82  virtual void check_group_by(
83  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const {};
84  virtual std::shared_ptr<Analyzer::Expr> deep_copy()
85  const = 0; // make a deep copy of self
86  /*
87  * @brief normalize_simple_predicate only applies to boolean expressions.
88  * it checks if it is an expression comparing a column
89  * with a constant. if so, it returns a normalized copy of the predicate with ColumnVar
90  * always as the left operand with rte_idx set to the rte_idx of the ColumnVar.
91  * it returns nullptr with rte_idx set to -1 otherwise.
92  */
93  virtual std::shared_ptr<Analyzer::Expr> normalize_simple_predicate(int& rte_idx) const {
94  rte_idx = -1;
95  return nullptr;
96  }
97  /*
98  * @brief seperate conjunctive predicates into scan predicates, join predicates and
99  * constant predicates.
100  */
101  virtual void group_predicates(std::list<const Expr*>& scan_predicates,
102  std::list<const Expr*>& join_predicates,
103  std::list<const Expr*>& const_predicates) const {}
104  /*
105  * @brief collect_rte_idx collects the indices of all the range table
106  * entries involved in an expression
107  */
108  virtual void collect_rte_idx(std::set<int>& rte_idx_set) const {}
109  /*
110  * @brief collect_column_var collects all unique ColumnVar nodes in an expression
111  * If include_agg = false, it does not include to ColumnVar nodes inside
112  * the argument to AggExpr's. Otherwise, they are included.
113  * It does not make copies of the ColumnVar
114  */
115  virtual void collect_column_var(
116  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
117  colvar_set,
118  bool include_agg) const {}
119  /*
120  * @brief rewrite_with_targetlist rewrite ColumnVar's in expression with entries in a
121  * targetlist. targetlist expressions are expected to be only Var's or AggExpr's.
122  * returns a new expression copy
123  */
124  virtual std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
125  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const {
126  return deep_copy();
127  };
128  /*
129  * @brief rewrite_with_child_targetlist rewrite ColumnVar's in expression with entries
130  * in a child plan's targetlist. targetlist expressions are expected to be only Var's or
131  * ColumnVar's returns a new expression copy
132  */
133  virtual std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
134  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const {
135  return deep_copy();
136  };
137  /*
138  * @brief rewrite_agg_to_var rewrite ColumnVar's in expression with entries in an
139  * AggPlan's targetlist. targetlist expressions are expected to be only Var's or
140  * ColumnVar's or AggExpr's All AggExpr's are written into Var's. returns a new
141  * expression copy
142  */
143  virtual std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
144  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const {
145  return deep_copy();
146  }
147  virtual bool operator==(const Expr& rhs) const = 0;
148  virtual std::string toString() const = 0;
149  virtual void print() const { std::cout << toString(); }
150 
151  virtual void add_unique(std::list<const Expr*>& expr_list) const;
152  /*
153  * @brief find_expr traverse Expr hierarchy and adds the node pointer to
154  * the expr_list if the function f returns true.
155  * Duplicate Expr's are not added the list.
156  * Cannot use std::set because we don't have an ordering function.
157  */
158  virtual void find_expr(bool (*f)(const Expr*),
159  std::list<const Expr*>& expr_list) const {
160  if (f(this)) {
161  add_unique(expr_list);
162  }
163  }
164  /*
165  * @brief decompress adds cast operator to decompress encoded result
166  */
167  std::shared_ptr<Analyzer::Expr> decompress();
168  /*
169  * @brief perform domain analysis on Expr and fill in domain
170  * information in domain_set. Empty domain_set means no information.
171  */
172  virtual void get_domain(DomainSet& domain_set) const { domain_set.clear(); }
173 
174  protected:
175  SQLTypeInfo type_info; // SQLTypeInfo of the return result of this expression
177 };
178 
179 using ExpressionPtr = std::shared_ptr<Analyzer::Expr>;
180 using ExpressionPtrList = std::list<ExpressionPtr>;
181 using ExpressionPtrVector = std::vector<ExpressionPtr>;
182 
183 /*
184  * @type ColumnVar
185  * @brief expression that evaluates to the value of a column in a given row from a base
186  * table. It is used in parse trees and is only used in Scan nodes in a query plan for
187  * scanning a table while Var nodes are used for all other plans.
188  */
189 class ColumnVar : public Expr {
190  public:
191  ColumnVar(const SQLTypeInfo& ti, int r, int c, int i)
192  : Expr(ti), table_id(r), column_id(c), rte_idx(i) {}
193  int get_table_id() const { return table_id; }
194  int get_column_id() const { return column_id; }
195  int get_rte_idx() const { return rte_idx; }
197  int get_comp_param() const { return type_info.get_comp_param(); }
198  void check_group_by(
199  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
200  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
201  void group_predicates(std::list<const Expr*>& scan_predicates,
202  std::list<const Expr*>& join_predicates,
203  std::list<const Expr*>& const_predicates) const override;
204  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
205  rte_idx_set.insert(rte_idx);
206  }
207  static bool colvar_comp(const ColumnVar* l, const ColumnVar* r) {
208  return l->get_table_id() < r->get_table_id() ||
209  (l->get_table_id() == r->get_table_id() &&
210  l->get_column_id() < r->get_column_id());
211  }
213  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
214  colvar_set,
215  bool include_agg) const override {
216  colvar_set.insert(this);
217  }
218  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
219  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
220  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
221  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
222  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
223  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
224  bool operator==(const Expr& rhs) const override;
225  std::string toString() const override;
226 
227  protected:
228  int table_id; // the global table id
229  int column_id; // the column id
230  int rte_idx; // 0-based range table index, used for table ordering in multi-joins
231 };
232 
233 /*
234  * @type ExpressionTuple
235  * @brief A tuple of expressions on the side of an equi-join on multiple columns.
236  * Not to be used in any other context.
237  */
238 class ExpressionTuple : public Expr {
239  public:
240  ExpressionTuple(const std::vector<std::shared_ptr<Analyzer::Expr>>& tuple)
241  : Expr(SQLTypeInfo()), tuple_(tuple){};
242 
243  const std::vector<std::shared_ptr<Analyzer::Expr>>& getTuple() const { return tuple_; }
244 
245  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
246 
247  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
248 
249  bool operator==(const Expr& rhs) const override;
250  std::string toString() const override;
251 
252  private:
253  const std::vector<std::shared_ptr<Analyzer::Expr>> tuple_;
254 };
255 
256 /*
257  * @type Var
258  * @brief expression that evaluates to the value of a column in a given row generated
259  * from a query plan node. It is only used in plan nodes above Scan nodes.
260  * The row can be produced by either the inner or the outer plan in case of a join.
261  * It inherits from ColumnVar to keep track of the lineage through the plan nodes.
262  * The table_id will be set to 0 if the Var does not correspond to an original column
263  * value.
264  */
265 class Var : public ColumnVar {
266  public:
268  Var(const SQLTypeInfo& ti, int r, int c, int i, WhichRow o, int v)
269  : ColumnVar(ti, r, c, i), which_row(o), varno(v) {}
270  Var(const SQLTypeInfo& ti, WhichRow o, int v)
271  : ColumnVar(ti, 0, 0, -1), which_row(o), varno(v) {}
272  WhichRow get_which_row() const { return which_row; }
274  int get_varno() const { return varno; }
275  void set_varno(int n) { varno = n; }
276  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
277  std::string toString() const override;
278  void check_group_by(
279  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
280  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
281  rte_idx_set.insert(-1);
282  }
283  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
284  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
285  return deep_copy();
286  }
287  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
288  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
289  return deep_copy();
290  }
291  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
292  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
293 
294  private:
295  WhichRow which_row; // indicate which row this Var should project from. It can be from
296  // the outer input plan or the inner input plan (for joins) or the
297  // output row in the current plan.
298  int varno; // the column number in the row. 1-based
299 };
300 
301 /*
302  * @type Constant
303  * @brief expression for a constant value
304  */
305 class Constant : public Expr {
306  public:
307  Constant(SQLTypes t, bool n) : Expr(t, !n), is_null(n) {
308  if (n) {
309  set_null_value();
310  } else {
311  type_info.set_notnull(true);
312  }
313  }
314  Constant(SQLTypes t, bool n, Datum v) : Expr(t, !n), is_null(n), constval(v) {
315  if (n) {
316  set_null_value();
317  } else {
318  type_info.set_notnull(true);
319  }
320  }
321  Constant(const SQLTypeInfo& ti, bool n, Datum v) : Expr(ti), is_null(n), constval(v) {
322  if (n) {
323  set_null_value();
324  } else {
325  type_info.set_notnull(true);
326  }
327  }
329  bool n,
330  const std::list<std::shared_ptr<Analyzer::Expr>>& l)
331  : Expr(ti), is_null(n), constval(Datum{0}), value_list(l) {}
332  ~Constant() override;
333  bool get_is_null() const { return is_null; }
334  Datum get_constval() const { return constval; }
335  void set_constval(Datum d) { constval = d; }
336  const std::list<std::shared_ptr<Analyzer::Expr>>& get_value_list() const {
337  return value_list;
338  }
339  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
340  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) override;
341  bool operator==(const Expr& rhs) const override;
342  std::string toString() const override;
343 
344  protected:
345  bool is_null; // constant is NULL
346  Datum constval; // the constant value
347  const std::list<std::shared_ptr<Analyzer::Expr>> value_list;
348  void cast_number(const SQLTypeInfo& new_type_info);
349  void cast_string(const SQLTypeInfo& new_type_info);
350  void cast_from_string(const SQLTypeInfo& new_type_info);
351  void cast_to_string(const SQLTypeInfo& new_type_info);
352  void do_cast(const SQLTypeInfo& new_type_info);
353  void set_null_value();
354 };
355 
356 /*
357  * @type UOper
358  * @brief represents unary operator expressions. operator types include
359  * kUMINUS, kISNULL, kEXISTS, kCAST
360  */
361 class UOper : public Expr {
362  public:
363  UOper(const SQLTypeInfo& ti, bool has_agg, SQLOps o, std::shared_ptr<Analyzer::Expr> p)
364  : Expr(ti, has_agg), optype(o), operand(p) {}
365  UOper(SQLTypes t, SQLOps o, std::shared_ptr<Analyzer::Expr> p)
366  : Expr(t, o == kISNULL ? true : p->get_type_info().get_notnull())
367  , optype(o)
368  , operand(p) {}
369  SQLOps get_optype() const { return optype; }
370  const Expr* get_operand() const { return operand.get(); }
371  const std::shared_ptr<Analyzer::Expr> get_own_operand() const { return operand; }
372  void check_group_by(
373  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
374  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
375  void group_predicates(std::list<const Expr*>& scan_predicates,
376  std::list<const Expr*>& join_predicates,
377  std::list<const Expr*>& const_predicates) const override;
378  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
379  operand->collect_rte_idx(rte_idx_set);
380  }
382  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
383  colvar_set,
384  bool include_agg) const override {
385  operand->collect_column_var(colvar_set, include_agg);
386  }
387  std::shared_ptr<Analyzer::Expr> rewrite_with_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_targetlist(tlist));
391  }
392  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
393  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
394  return makeExpr<UOper>(
395  type_info, contains_agg, optype, operand->rewrite_with_child_targetlist(tlist));
396  }
397  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
398  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
399  return makeExpr<UOper>(
400  type_info, contains_agg, optype, operand->rewrite_agg_to_var(tlist));
401  }
402  bool operator==(const Expr& rhs) const override;
403  std::string toString() const override;
404  void find_expr(bool (*f)(const Expr*),
405  std::list<const Expr*>& expr_list) const override;
406  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) override;
407 
408  protected:
409  SQLOps optype; // operator type, e.g., kUMINUS, kISNULL, kEXISTS
410  std::shared_ptr<Analyzer::Expr> operand; // operand expression
411 };
412 
413 /*
414  * @type BinOper
415  * @brief represents binary operator expressions. it includes all
416  * comparison, arithmetic and boolean binary operators. it handles ANY/ALL qualifiers
417  * in case the right_operand is a subquery.
418  */
419 class BinOper : public Expr {
420  public:
421  BinOper(const SQLTypeInfo& ti,
422  bool has_agg,
423  SQLOps o,
424  SQLQualifier q,
425  std::shared_ptr<Analyzer::Expr> l,
426  std::shared_ptr<Analyzer::Expr> r)
427  : Expr(ti, has_agg), optype(o), qualifier(q), left_operand(l), right_operand(r) {}
429  SQLOps o,
430  SQLQualifier q,
431  std::shared_ptr<Analyzer::Expr> l,
432  std::shared_ptr<Analyzer::Expr> r)
433  : Expr(t, l->get_type_info().get_notnull() && r->get_type_info().get_notnull())
434  , optype(o)
435  , qualifier(q)
436  , left_operand(l)
437  , right_operand(r) {}
438  SQLOps get_optype() const { return optype; }
439  bool is_overlaps_oper() const { return optype == kOVERLAPS; }
441  const Expr* get_left_operand() const { return left_operand.get(); }
442  const Expr* get_right_operand() const { return right_operand.get(); }
443  const std::shared_ptr<Analyzer::Expr> get_own_left_operand() const {
444  return left_operand;
445  }
446  const std::shared_ptr<Analyzer::Expr> get_own_right_operand() const {
447  return right_operand;
448  }
450  const SQLTypeInfo& left_type,
451  const SQLTypeInfo& right_type,
452  SQLTypeInfo* new_left_type,
453  SQLTypeInfo* new_right_type);
454  static SQLTypeInfo common_numeric_type(const SQLTypeInfo& type1,
455  const SQLTypeInfo& type2);
456  static SQLTypeInfo common_string_type(const SQLTypeInfo& type1,
457  const SQLTypeInfo& type2);
458  void check_group_by(
459  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
460  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
461  std::shared_ptr<Analyzer::Expr> normalize_simple_predicate(int& rte_idx) const override;
462  void group_predicates(std::list<const Expr*>& scan_predicates,
463  std::list<const Expr*>& join_predicates,
464  std::list<const Expr*>& const_predicates) const override;
465  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
466  left_operand->collect_rte_idx(rte_idx_set);
467  right_operand->collect_rte_idx(rte_idx_set);
468  }
470  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
471  colvar_set,
472  bool include_agg) const override {
473  left_operand->collect_column_var(colvar_set, include_agg);
474  right_operand->collect_column_var(colvar_set, include_agg);
475  }
476  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
477  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
478  return makeExpr<BinOper>(type_info,
479  contains_agg,
480  optype,
481  qualifier,
482  left_operand->rewrite_with_targetlist(tlist),
483  right_operand->rewrite_with_targetlist(tlist));
484  }
485  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
486  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
487  return makeExpr<BinOper>(type_info,
488  contains_agg,
489  optype,
490  qualifier,
491  left_operand->rewrite_with_child_targetlist(tlist),
492  right_operand->rewrite_with_child_targetlist(tlist));
493  }
494  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
495  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
496  return makeExpr<BinOper>(type_info,
497  contains_agg,
498  optype,
499  qualifier,
500  left_operand->rewrite_agg_to_var(tlist),
501  right_operand->rewrite_agg_to_var(tlist));
502  }
503  bool operator==(const Expr& rhs) const override;
504  std::string toString() const override;
505  void find_expr(bool (*f)(const Expr*),
506  std::list<const Expr*>& expr_list) const override;
508  const std::shared_ptr<Analyzer::Expr> cast_operand,
509  const std::shared_ptr<Analyzer::Expr> const_operand);
510 
511  private:
512  SQLOps optype; // operator type, e.g., kLT, kAND, kPLUS, etc.
513  SQLQualifier qualifier; // qualifier kANY, kALL or kONE. Only relevant with
514  // right_operand is Subquery
515  std::shared_ptr<Analyzer::Expr> left_operand; // the left operand expression
516  std::shared_ptr<Analyzer::Expr> right_operand; // the right operand expression
517 };
518 
523 class RangeOper : public Expr {
524  public:
525  RangeOper(const bool l_inclusive,
526  const bool r_inclusive,
527  std::shared_ptr<Analyzer::Expr> l,
528  std::shared_ptr<Analyzer::Expr> r)
529  : Expr(SQLTypeInfo(kNULLT), /*not_null=*/false)
530  , left_inclusive_(l_inclusive)
531  , right_inclusive_(r_inclusive)
532  , left_operand_(l)
533  , right_operand_(r) {
536  }
537 
538  const Expr* get_left_operand() const { return left_operand_.get(); }
539  const Expr* get_right_operand() const { return right_operand_.get(); }
540 
541  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
542  bool operator==(const Expr& rhs) const override;
543  std::string toString() const override;
544 
545  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
546  left_operand_->collect_rte_idx(rte_idx_set);
547  right_operand_->collect_rte_idx(rte_idx_set);
548  }
549 
551  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
552  colvar_set,
553  bool include_agg) const override {
554  left_operand_->collect_column_var(colvar_set, include_agg);
555  right_operand_->collect_column_var(colvar_set, include_agg);
556  }
557 
558  private:
559  // build a range between these two operands
562  std::shared_ptr<Analyzer::Expr> left_operand_;
563  std::shared_ptr<Analyzer::Expr> right_operand_;
564 };
565 
566 class Query;
567 
568 /*
569  * @type Subquery
570  * @brief subquery expression. Note that the type of the expression is the type of the
571  * TargetEntry in the subquery instead of the set.
572  */
573 class Subquery : public Expr {
574  public:
575  Subquery(const SQLTypeInfo& ti, Query* q)
576  : Expr(ti), parsetree(q) /*, plan(nullptr)*/ {}
577  ~Subquery() override;
578  const Query* get_parsetree() const { return parsetree; }
579  // const Plan *get_plan() const { return plan; }
580  // void set_plan(Plan *p) { plan = p; } // subquery plan is set by the optimizer
581  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) override;
582  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
583  void group_predicates(std::list<const Expr*>& scan_predicates,
584  std::list<const Expr*>& join_predicates,
585  std::list<const Expr*>& const_predicates) const override {
586  CHECK(false);
587  }
588  void collect_rte_idx(std::set<int>& rte_idx_set) const override { CHECK(false); }
590  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
591  colvar_set,
592  bool include_agg) const override {
593  CHECK(false);
594  }
595  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
596  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
597  abort();
598  }
599  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
600  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
601  abort();
602  }
603  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
604  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
605  abort();
606  }
607  bool operator==(const Expr& rhs) const override {
608  CHECK(false);
609  return false;
610  }
611  std::string toString() const override;
612  void find_expr(bool (*f)(const Expr*),
613  std::list<const Expr*>& expr_list) const override {
614  CHECK(false);
615  }
616 
617  private:
618  Query* parsetree; // parse tree of the subquery
619 };
620 
621 /*
622  * @type InValues
623  * @brief represents predicate expr IN (v1, v2, ...)
624  * v1, v2, ... are can be either Constant or Parameter.
625  */
626 class InValues : public Expr {
627  public:
628  InValues(std::shared_ptr<Analyzer::Expr> a,
629  const std::list<std::shared_ptr<Analyzer::Expr>>& l);
630  const Expr* get_arg() const { return arg.get(); }
631  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
632  const std::list<std::shared_ptr<Analyzer::Expr>>& get_value_list() const {
633  return value_list;
634  }
635  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
636  void group_predicates(std::list<const Expr*>& scan_predicates,
637  std::list<const Expr*>& join_predicates,
638  std::list<const Expr*>& const_predicates) const override;
639  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
640  arg->collect_rte_idx(rte_idx_set);
641  }
643  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
644  colvar_set,
645  bool include_agg) const override {
646  arg->collect_column_var(colvar_set, include_agg);
647  }
648  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
649  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
650  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
651  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
652  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
653  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
654  bool operator==(const Expr& rhs) const override;
655  std::string toString() const override;
656  void find_expr(bool (*f)(const Expr*),
657  std::list<const Expr*>& expr_list) const override;
658 
659  private:
660  std::shared_ptr<Analyzer::Expr> arg; // the argument left of IN
661  const std::list<std::shared_ptr<Analyzer::Expr>>
662  value_list; // the list of values right of IN
663 };
664 
665 /*
666  * @type InIntegerSet
667  * @brief represents predicate expr IN (v1, v2, ...) for the case where the right
668  * hand side is a list of integers or dictionary-encoded strings generated
669  * by a IN subquery. Avoids the overhead of storing a list of shared pointers
670  * to Constant objects, making it more suitable for IN sub-queries usage.
671  * v1, v2, ... are integers
672  */
673 class InIntegerSet : public Expr {
674  public:
675  InIntegerSet(const std::shared_ptr<const Analyzer::Expr> a,
676  const std::vector<int64_t>& values,
677  const bool not_null);
678 
679  const Expr* get_arg() const { return arg.get(); }
680 
681  const std::vector<int64_t>& get_value_list() const { return value_list; }
682 
683  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
684 
685  bool operator==(const Expr& rhs) const override;
686  std::string toString() const override;
687 
688  private:
689  const std::shared_ptr<const Analyzer::Expr> arg; // the argument left of IN
690  const std::vector<int64_t> value_list; // the list of values right of IN
691 };
692 
693 /*
694  * @type CharLengthExpr
695  * @brief expression for the CHAR_LENGTH expression.
696  * arg must evaluate to char, varchar or text.
697  */
698 class CharLengthExpr : public Expr {
699  public:
700  CharLengthExpr(std::shared_ptr<Analyzer::Expr> a, bool e)
701  : Expr(kINT, a->get_type_info().get_notnull()), arg(a), calc_encoded_length(e) {}
702  const Expr* get_arg() const { return arg.get(); }
703  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
705  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
706  void group_predicates(std::list<const Expr*>& scan_predicates,
707  std::list<const Expr*>& join_predicates,
708  std::list<const Expr*>& const_predicates) const override;
709  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
710  arg->collect_rte_idx(rte_idx_set);
711  }
713  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
714  colvar_set,
715  bool include_agg) const override {
716  arg->collect_column_var(colvar_set, include_agg);
717  }
718  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
719  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
720  return makeExpr<CharLengthExpr>(arg->rewrite_with_targetlist(tlist),
722  }
723  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
724  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
725  return makeExpr<CharLengthExpr>(arg->rewrite_with_child_targetlist(tlist),
727  }
728  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
729  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
730  return makeExpr<CharLengthExpr>(arg->rewrite_agg_to_var(tlist), calc_encoded_length);
731  }
732  bool operator==(const Expr& rhs) const override;
733  std::string toString() const override;
734  void find_expr(bool (*f)(const Expr*),
735  std::list<const Expr*>& expr_list) const override;
736 
737  private:
738  std::shared_ptr<Analyzer::Expr> arg;
740 };
741 
742 /*
743  * @type KeyForStringExpr
744  * @brief expression for the KEY_FOR_STRING expression.
745  * arg must be a dict encoded column, not str literal.
746  */
747 class KeyForStringExpr : public Expr {
748  public:
749  KeyForStringExpr(std::shared_ptr<Analyzer::Expr> a)
750  : Expr(kINT, a->get_type_info().get_notnull()), arg(a) {}
751  const Expr* get_arg() const { return arg.get(); }
752  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
753  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
754  void group_predicates(std::list<const Expr*>& scan_predicates,
755  std::list<const Expr*>& join_predicates,
756  std::list<const Expr*>& const_predicates) const override;
757  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
758  arg->collect_rte_idx(rte_idx_set);
759  }
761  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
762  colvar_set,
763  bool include_agg) const override {
764  arg->collect_column_var(colvar_set, include_agg);
765  }
766  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
767  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
768  return makeExpr<KeyForStringExpr>(arg->rewrite_with_targetlist(tlist));
769  }
770  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
771  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
772  return makeExpr<KeyForStringExpr>(arg->rewrite_with_child_targetlist(tlist));
773  }
774  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
775  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
776  return makeExpr<KeyForStringExpr>(arg->rewrite_agg_to_var(tlist));
777  }
778  bool operator==(const Expr& rhs) const override;
779  std::string toString() const override;
780  void find_expr(bool (*f)(const Expr*),
781  std::list<const Expr*>& expr_list) const override;
782 
783  private:
784  std::shared_ptr<Analyzer::Expr> arg;
785 };
786 
787 /*
788  * @type SampleRatioExpr
789  * @brief expression for the SAMPLE_RATIO expression. Argument range is expected to be
790  * between 0 and 1.
791  */
792 class SampleRatioExpr : public Expr {
793  public:
794  SampleRatioExpr(std::shared_ptr<Analyzer::Expr> a)
795  : Expr(kBOOLEAN, a->get_type_info().get_notnull()), arg(a) {}
796  const Expr* get_arg() const { return arg.get(); }
797  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
798  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
799  void group_predicates(std::list<const Expr*>& scan_predicates,
800  std::list<const Expr*>& join_predicates,
801  std::list<const Expr*>& const_predicates) const override;
802  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
803  arg->collect_rte_idx(rte_idx_set);
804  }
806  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
807  colvar_set,
808  bool include_agg) const override {
809  arg->collect_column_var(colvar_set, include_agg);
810  }
811  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
812  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
813  return makeExpr<SampleRatioExpr>(arg->rewrite_with_targetlist(tlist));
814  }
815  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
816  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
817  return makeExpr<SampleRatioExpr>(arg->rewrite_with_child_targetlist(tlist));
818  }
819  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
820  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
821  return makeExpr<SampleRatioExpr>(arg->rewrite_agg_to_var(tlist));
822  }
823  bool operator==(const Expr& rhs) const override;
824  std::string toString() const override;
825  void find_expr(bool (*f)(const Expr*),
826  std::list<const Expr*>& expr_list) const override;
827 
828  private:
829  std::shared_ptr<Analyzer::Expr> arg;
830 };
831 
837 class LowerExpr : public Expr {
838  public:
839  LowerExpr(std::shared_ptr<Analyzer::Expr> arg) : Expr(arg->get_type_info()), arg(arg) {}
840 
841  const Expr* get_arg() const { return arg.get(); }
842 
843  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
844 
845  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
846  arg->collect_rte_idx(rte_idx_set);
847  }
848 
850  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
851  colvar_set,
852  bool include_agg) const override {
853  arg->collect_column_var(colvar_set, include_agg);
854  }
855 
856  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
857  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
858  return makeExpr<LowerExpr>(arg->rewrite_with_targetlist(tlist));
859  }
860 
861  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
862  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
863  return makeExpr<LowerExpr>(arg->rewrite_with_child_targetlist(tlist));
864  }
865 
866  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
867  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
868  return makeExpr<LowerExpr>(arg->rewrite_agg_to_var(tlist));
869  }
870 
871  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
872 
873  void group_predicates(std::list<const Expr*>& scan_predicates,
874  std::list<const Expr*>& join_predicates,
875  std::list<const Expr*>& const_predicates) const override;
876 
877  bool operator==(const Expr& rhs) const override;
878 
879  std::string toString() const override;
880 
881  void find_expr(bool (*f)(const Expr*),
882  std::list<const Expr*>& expr_list) const override;
883 
884  private:
885  std::shared_ptr<Analyzer::Expr> arg;
886 };
887 
888 /*
889  * @type CardinalityExpr
890  * @brief expression for the CARDINALITY expression.
891  * arg must evaluate to array (or multiset when supported).
892  */
893 class CardinalityExpr : public Expr {
894  public:
895  CardinalityExpr(std::shared_ptr<Analyzer::Expr> a)
896  : Expr(kINT, a->get_type_info().get_notnull()), arg(a) {}
897  const Expr* get_arg() const { return arg.get(); }
898  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
899  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
900  void group_predicates(std::list<const Expr*>& scan_predicates,
901  std::list<const Expr*>& join_predicates,
902  std::list<const Expr*>& const_predicates) const override;
903  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
904  arg->collect_rte_idx(rte_idx_set);
905  }
907  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
908  colvar_set,
909  bool include_agg) const override {
910  arg->collect_column_var(colvar_set, include_agg);
911  }
912  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
913  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
914  return makeExpr<CardinalityExpr>(arg->rewrite_with_targetlist(tlist));
915  }
916  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
917  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
918  return makeExpr<CardinalityExpr>(arg->rewrite_with_child_targetlist(tlist));
919  }
920  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
921  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
922  return makeExpr<CardinalityExpr>(arg->rewrite_agg_to_var(tlist));
923  }
924  bool operator==(const Expr& rhs) const override;
925  std::string toString() const override;
926  void find_expr(bool (*f)(const Expr*),
927  std::list<const Expr*>& expr_list) const override;
928 
929  private:
930  std::shared_ptr<Analyzer::Expr> arg;
931 };
932 
933 /*
934  * @type LikeExpr
935  * @brief expression for the LIKE predicate.
936  * arg must evaluate to char, varchar or text.
937  */
938 class LikeExpr : public Expr {
939  public:
940  LikeExpr(std::shared_ptr<Analyzer::Expr> a,
941  std::shared_ptr<Analyzer::Expr> l,
942  std::shared_ptr<Analyzer::Expr> e,
943  bool i,
944  bool s)
945  : Expr(kBOOLEAN, a->get_type_info().get_notnull())
946  , arg(a)
947  , like_expr(l)
948  , escape_expr(e)
949  , is_ilike(i)
950  , is_simple(s) {}
951  const Expr* get_arg() const { return arg.get(); }
952  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
953  const Expr* get_like_expr() const { return like_expr.get(); }
954  const Expr* get_escape_expr() const { return escape_expr.get(); }
955  bool get_is_ilike() const { return is_ilike; }
956  bool get_is_simple() const { return is_simple; }
957  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
958  void group_predicates(std::list<const Expr*>& scan_predicates,
959  std::list<const Expr*>& join_predicates,
960  std::list<const Expr*>& const_predicates) const override;
961  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
962  arg->collect_rte_idx(rte_idx_set);
963  }
965  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
966  colvar_set,
967  bool include_agg) const override {
968  arg->collect_column_var(colvar_set, include_agg);
969  }
970  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
971  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
972  return makeExpr<LikeExpr>(arg->rewrite_with_targetlist(tlist),
973  like_expr->deep_copy(),
974  escape_expr ? escape_expr->deep_copy() : nullptr,
975  is_ilike,
976  is_simple);
977  }
978  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
979  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
980  return makeExpr<LikeExpr>(arg->rewrite_with_child_targetlist(tlist),
981  like_expr->deep_copy(),
982  escape_expr ? escape_expr->deep_copy() : nullptr,
983  is_ilike,
984  is_simple);
985  }
986  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
987  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
988  return makeExpr<LikeExpr>(arg->rewrite_agg_to_var(tlist),
989  like_expr->deep_copy(),
990  escape_expr ? escape_expr->deep_copy() : nullptr,
991  is_ilike,
992  is_simple);
993  }
994  bool operator==(const Expr& rhs) const override;
995  std::string toString() const override;
996  void find_expr(bool (*f)(const Expr*),
997  std::list<const Expr*>& expr_list) const override;
998 
999  private:
1000  std::shared_ptr<Analyzer::Expr> arg; // the argument to the left of LIKE
1001  std::shared_ptr<Analyzer::Expr> like_expr; // expression that evaluates to like string
1002  std::shared_ptr<Analyzer::Expr>
1003  escape_expr; // expression that evaluates to escape string, can be nullptr
1004  bool is_ilike; // is this ILIKE?
1005  bool is_simple; // is this simple, meaning we can use fast path search (fits '%str%'
1006  // pattern with no inner '%','_','[',']'
1007 };
1008 
1009 /*
1010  * @type RegexpExpr
1011  * @brief expression for REGEXP.
1012  * arg must evaluate to char, varchar or text.
1013  */
1014 class RegexpExpr : public Expr {
1015  public:
1016  RegexpExpr(std::shared_ptr<Analyzer::Expr> a,
1017  std::shared_ptr<Analyzer::Expr> p,
1018  std::shared_ptr<Analyzer::Expr> e)
1019  : Expr(kBOOLEAN, a->get_type_info().get_notnull())
1020  , arg(a)
1021  , pattern_expr(p)
1022  , escape_expr(e) {}
1023  const Expr* get_arg() const { return arg.get(); }
1024  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
1025  const Expr* get_pattern_expr() const { return pattern_expr.get(); }
1026  const Expr* get_escape_expr() const { return escape_expr.get(); }
1027  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1028  void group_predicates(std::list<const Expr*>& scan_predicates,
1029  std::list<const Expr*>& join_predicates,
1030  std::list<const Expr*>& const_predicates) const override;
1031  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
1032  arg->collect_rte_idx(rte_idx_set);
1033  }
1035  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1036  colvar_set,
1037  bool include_agg) const override {
1038  arg->collect_column_var(colvar_set, include_agg);
1039  }
1040  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1041  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1042  return makeExpr<RegexpExpr>(arg->rewrite_with_targetlist(tlist),
1043  pattern_expr->deep_copy(),
1044  escape_expr ? escape_expr->deep_copy() : nullptr);
1045  }
1046  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1047  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1048  return makeExpr<RegexpExpr>(arg->rewrite_with_child_targetlist(tlist),
1049  pattern_expr->deep_copy(),
1050  escape_expr ? escape_expr->deep_copy() : nullptr);
1051  }
1052  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1053  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1054  return makeExpr<RegexpExpr>(arg->rewrite_agg_to_var(tlist),
1055  pattern_expr->deep_copy(),
1056  escape_expr ? escape_expr->deep_copy() : nullptr);
1057  }
1058  bool operator==(const Expr& rhs) const override;
1059  std::string toString() const override;
1060  void find_expr(bool (*f)(const Expr*),
1061  std::list<const Expr*>& expr_list) const override;
1062 
1063  private:
1064  std::shared_ptr<Analyzer::Expr> arg; // the argument to the left of REGEXP
1065  std::shared_ptr<Analyzer::Expr>
1066  pattern_expr; // expression that evaluates to pattern string
1067  std::shared_ptr<Analyzer::Expr>
1068  escape_expr; // expression that evaluates to escape string, can be nullptr
1069 };
1070 
1071 /*
1072  * @type WidthBucketExpr
1073  * @brief expression for width_bucket functions.
1074  */
1075 class WidthBucketExpr : public Expr {
1076  public:
1077  WidthBucketExpr(const std::shared_ptr<Analyzer::Expr> target_value,
1078  const std::shared_ptr<Analyzer::Expr> lower_bound,
1079  const std::shared_ptr<Analyzer::Expr> upper_bound,
1080  const std::shared_ptr<Analyzer::Expr> partition_count)
1081  : Expr(kINT, target_value->get_type_info().get_notnull())
1082  , target_value_(target_value)
1083  , lower_bound_(lower_bound)
1084  , upper_bound_(upper_bound)
1085  , partition_count_(partition_count)
1088  const Expr* get_target_value() const { return target_value_.get(); }
1089  const Expr* get_lower_bound() const { return lower_bound_.get(); }
1090  const Expr* get_upper_bound() const { return upper_bound_.get(); }
1091  const Expr* get_partition_count() const { return partition_count_.get(); }
1092  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1093  void group_predicates(std::list<const Expr*>& scan_predicates,
1094  std::list<const Expr*>& join_predicates,
1095  std::list<const Expr*>& const_predicates) const override;
1096  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
1097  target_value_->collect_rte_idx(rte_idx_set);
1098  }
1100  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1101  colvar_set,
1102  bool include_agg) const override {
1103  target_value_->collect_column_var(colvar_set, include_agg);
1104  }
1105  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1106  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1107  return makeExpr<WidthBucketExpr>(target_value_->rewrite_with_targetlist(tlist),
1108  lower_bound_,
1109  upper_bound_,
1111  }
1112  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1113  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1114  return makeExpr<WidthBucketExpr>(target_value_->rewrite_with_child_targetlist(tlist),
1115  lower_bound_,
1116  upper_bound_,
1118  }
1119  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1120  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1121  return makeExpr<WidthBucketExpr>(target_value_->rewrite_agg_to_var(tlist),
1122  lower_bound_,
1123  upper_bound_,
1125  }
1126  double get_bound_val(const Analyzer::Expr* bound_expr) const;
1127  int32_t get_partition_count_val() const;
1128  template <typename T>
1129  int32_t compute_bucket(T target_const_val, SQLTypeInfo& ti) const {
1130  // this utility function is useful for optimizing expression range decision
1131  // for an expression depending on width_bucket expr
1132  T null_val = ti.is_integer() ? inline_int_null_val(ti) : inline_fp_null_val(ti);
1133  double lower_bound_val = get_bound_val(lower_bound_.get());
1134  double upper_bound_val = get_bound_val(upper_bound_.get());
1135  auto partition_count_val = get_partition_count_val();
1136  if (target_const_val == null_val) {
1137  return INT32_MIN;
1138  }
1139  float res;
1140  if (lower_bound_val < upper_bound_val) {
1141  if (target_const_val < lower_bound_val) {
1142  return 0;
1143  } else if (target_const_val >= upper_bound_val) {
1144  return partition_count_val + 1;
1145  }
1146  double dividend = upper_bound_val - lower_bound_val;
1147  res = ((partition_count_val * (target_const_val - lower_bound_val)) / dividend) + 1;
1148  } else {
1149  if (target_const_val > lower_bound_val) {
1150  return 0;
1151  } else if (target_const_val <= upper_bound_val) {
1152  return partition_count_val + 1;
1153  }
1154  double dividend = lower_bound_val - upper_bound_val;
1155  res = ((partition_count_val * (lower_bound_val - target_const_val)) / dividend) + 1;
1156  }
1157  return res;
1158  }
1159  bool operator==(const Expr& rhs) const override;
1160  std::string toString() const override;
1161  void find_expr(bool (*f)(const Expr*),
1162  std::list<const Expr*>& expr_list) const override;
1165  void set_constant_expr() const { constant_expr_ = true; }
1166  bool is_constant_expr() const { return constant_expr_; }
1167 
1168  private:
1169  std::shared_ptr<Analyzer::Expr> target_value_; // target value expression
1170  std::shared_ptr<Analyzer::Expr> lower_bound_; // lower_bound
1171  std::shared_ptr<Analyzer::Expr> upper_bound_; // upper_bound
1172  std::shared_ptr<Analyzer::Expr> partition_count_; // partition_count
1173  // true if lower, upper and partition count exprs are constant
1174  mutable bool constant_expr_;
1175  // true if we can skip oob check and is determined within compile time
1177 };
1178 
1179 /*
1180  * @type LikelihoodExpr
1181  * @brief expression for LIKELY and UNLIKELY boolean identity functions.
1182  */
1183 class LikelihoodExpr : public Expr {
1184  public:
1185  LikelihoodExpr(std::shared_ptr<Analyzer::Expr> a, float l = 0.5)
1186  : Expr(kBOOLEAN, a->get_type_info().get_notnull()), arg(a), likelihood(l) {}
1187  const Expr* get_arg() const { return arg.get(); }
1188  const std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
1189  float get_likelihood() const { return likelihood; }
1190  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1191  void group_predicates(std::list<const Expr*>& scan_predicates,
1192  std::list<const Expr*>& join_predicates,
1193  std::list<const Expr*>& const_predicates) const override;
1194  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
1195  arg->collect_rte_idx(rte_idx_set);
1196  }
1198  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1199  colvar_set,
1200  bool include_agg) const override {
1201  arg->collect_column_var(colvar_set, include_agg);
1202  }
1203  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1204  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1205  return makeExpr<LikelihoodExpr>(arg->rewrite_with_targetlist(tlist), likelihood);
1206  }
1207  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1208  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1209  return makeExpr<LikelihoodExpr>(arg->rewrite_with_child_targetlist(tlist),
1210  likelihood);
1211  }
1212  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1213  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override {
1214  return makeExpr<LikelihoodExpr>(arg->rewrite_agg_to_var(tlist), likelihood);
1215  }
1216  bool operator==(const Expr& rhs) const override;
1217  std::string toString() const override;
1218  void find_expr(bool (*f)(const Expr*),
1219  std::list<const Expr*>& expr_list) const override;
1220 
1221  private:
1222  std::shared_ptr<Analyzer::Expr> arg; // the argument to LIKELY, UNLIKELY
1223  float likelihood;
1224 };
1225 
1226 /*
1227  * @type AggExpr
1228  * @brief expression for builtin SQL aggregates.
1229  */
1230 class AggExpr : public Expr {
1231  public:
1233  SQLAgg a,
1234  std::shared_ptr<Analyzer::Expr> g,
1235  bool d,
1236  std::shared_ptr<Analyzer::Constant> e)
1237  : Expr(ti, true), aggtype(a), arg(g), is_distinct(d), arg1(e) {}
1239  SQLAgg a,
1240  Expr* g,
1241  bool d,
1242  std::shared_ptr<Analyzer::Constant> e,
1243  int idx)
1244  : Expr(SQLTypeInfo(t, g == nullptr ? true : g->get_type_info().get_notnull()), true)
1245  , aggtype(a)
1246  , arg(g)
1247  , is_distinct(d)
1248  , arg1(e) {}
1249  SQLAgg get_aggtype() const { return aggtype; }
1250  Expr* get_arg() const { return arg.get(); }
1251  std::shared_ptr<Analyzer::Expr> get_own_arg() const { return arg; }
1252  bool get_is_distinct() const { return is_distinct; }
1253  std::shared_ptr<Analyzer::Constant> get_arg1() const { return arg1; }
1254  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1255  void group_predicates(std::list<const Expr*>& scan_predicates,
1256  std::list<const Expr*>& join_predicates,
1257  std::list<const Expr*>& const_predicates) const override;
1258  void collect_rte_idx(std::set<int>& rte_idx_set) const override {
1259  if (arg) {
1260  arg->collect_rte_idx(rte_idx_set);
1261  }
1262  };
1264  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1265  colvar_set,
1266  bool include_agg) const override {
1267  if (include_agg && arg != nullptr) {
1268  arg->collect_column_var(colvar_set, include_agg);
1269  }
1270  }
1271  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1272  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1273  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1274  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1275  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1276  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1277  bool operator==(const Expr& rhs) const override;
1278  std::string toString() const override;
1279  void find_expr(bool (*f)(const Expr*),
1280  std::list<const Expr*>& expr_list) const override;
1281 
1282  private:
1283  SQLAgg aggtype; // aggregate type: kAVG, kMIN, kMAX, kSUM, kCOUNT
1284  std::shared_ptr<Analyzer::Expr> arg; // argument to aggregate
1285  bool is_distinct; // true only if it is for COUNT(DISTINCT x)
1286  // APPROX_COUNT_DISTINCT error_rate, APPROX_QUANTILE quantile
1287  std::shared_ptr<Analyzer::Constant> arg1;
1288 };
1289 
1290 /*
1291  * @type CaseExpr
1292  * @brief the CASE-WHEN-THEN-ELSE expression
1293  */
1294 class CaseExpr : public Expr {
1295  public:
1297  bool has_agg,
1298  const std::list<std::pair<std::shared_ptr<Analyzer::Expr>,
1299  std::shared_ptr<Analyzer::Expr>>>& w,
1300  std::shared_ptr<Analyzer::Expr> e)
1301  : Expr(ti, has_agg), expr_pair_list(w), else_expr(e) {}
1302  const std::list<
1303  std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>&
1305  return expr_pair_list;
1306  }
1307  const Expr* get_else_expr() const { return else_expr.get(); }
1308  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1309  void check_group_by(
1310  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1311  void group_predicates(std::list<const Expr*>& scan_predicates,
1312  std::list<const Expr*>& join_predicates,
1313  std::list<const Expr*>& const_predicates) const override;
1314  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1315  void collect_column_var(
1316  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1317  colvar_set,
1318  bool include_agg) const override;
1319  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1320  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1321  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1322  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1323  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1324  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1325  bool operator==(const Expr& rhs) const override;
1326  std::string toString() const override;
1327  void find_expr(bool (*f)(const Expr*),
1328  std::list<const Expr*>& expr_list) const override;
1329  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) override;
1330  void get_domain(DomainSet& domain_set) const override;
1331 
1332  private:
1333  std::list<std::pair<std::shared_ptr<Analyzer::Expr>, std::shared_ptr<Analyzer::Expr>>>
1334  expr_pair_list; // a pair of expressions for each WHEN expr1 THEN expr2. expr1
1335  // must be of boolean type. all expr2's must be of compatible
1336  // types and will be promoted to the common type.
1337  std::shared_ptr<Analyzer::Expr> else_expr; // expression for ELSE. nullptr if omitted.
1338 };
1339 
1340 /*
1341  * @type ExtractExpr
1342  * @brief the EXTRACT expression
1343  */
1344 class ExtractExpr : public Expr {
1345  public:
1347  bool has_agg,
1348  ExtractField f,
1349  std::shared_ptr<Analyzer::Expr> e)
1350  : Expr(ti, has_agg), field_(f), from_expr_(e) {}
1351  ExtractField get_field() const { return field_; }
1352  const Expr* get_from_expr() const { return from_expr_.get(); }
1353  const std::shared_ptr<Analyzer::Expr> get_own_from_expr() const { return from_expr_; }
1354  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1355  void check_group_by(
1356  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1357  void group_predicates(std::list<const Expr*>& scan_predicates,
1358  std::list<const Expr*>& join_predicates,
1359  std::list<const Expr*>& const_predicates) const override;
1360  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1361  void collect_column_var(
1362  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1363  colvar_set,
1364  bool include_agg) const override;
1365  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1366  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1367  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1368  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1369  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1370  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1371  bool operator==(const Expr& rhs) const override;
1372  std::string toString() const override;
1373  void find_expr(bool (*f)(const Expr*),
1374  std::list<const Expr*>& expr_list) const override;
1375 
1376  private:
1378  std::shared_ptr<Analyzer::Expr> from_expr_;
1379 };
1380 
1381 /*
1382  * @type DateaddExpr
1383  * @brief the DATEADD expression
1384  */
1385 class DateaddExpr : public Expr {
1386  public:
1388  const DateaddField f,
1389  const std::shared_ptr<Analyzer::Expr> number,
1390  const std::shared_ptr<Analyzer::Expr> datetime)
1391  : Expr(ti, false), field_(f), number_(number), datetime_(datetime) {}
1392  DateaddField get_field() const { return field_; }
1393  const Expr* get_number_expr() const { return number_.get(); }
1394  const Expr* get_datetime_expr() const { return datetime_.get(); }
1395  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1396  void check_group_by(
1397  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1398  void group_predicates(std::list<const Expr*>& scan_predicates,
1399  std::list<const Expr*>& join_predicates,
1400  std::list<const Expr*>& const_predicates) const override;
1401  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1402  void collect_column_var(
1403  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1404  colvar_set,
1405  bool include_agg) const override;
1406  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1407  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1408  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1409  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1410  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1411  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1412  bool operator==(const Expr& rhs) const override;
1413  std::string toString() const override;
1414  void find_expr(bool (*f)(const Expr*),
1415  std::list<const Expr*>& expr_list) const override;
1416 
1417  private:
1419  const std::shared_ptr<Analyzer::Expr> number_;
1420  const std::shared_ptr<Analyzer::Expr> datetime_;
1421 };
1422 
1423 /*
1424  * @type DatediffExpr
1425  * @brief the DATEDIFF expression
1426  */
1427 class DatediffExpr : public Expr {
1428  public:
1430  const DatetruncField f,
1431  const std::shared_ptr<Analyzer::Expr> start,
1432  const std::shared_ptr<Analyzer::Expr> end)
1433  : Expr(ti, false), field_(f), start_(start), end_(end) {}
1434  DatetruncField get_field() const { return field_; }
1435  const Expr* get_start_expr() const { return start_.get(); }
1436  const Expr* get_end_expr() const { return end_.get(); }
1437  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1438  void check_group_by(
1439  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1440  void group_predicates(std::list<const Expr*>& scan_predicates,
1441  std::list<const Expr*>& join_predicates,
1442  std::list<const Expr*>& const_predicates) const override;
1443  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1444  void collect_column_var(
1445  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1446  colvar_set,
1447  bool include_agg) const override;
1448  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1449  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1450  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1451  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1452  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1453  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1454  bool operator==(const Expr& rhs) const override;
1455  std::string toString() const override;
1456  void find_expr(bool (*f)(const Expr*),
1457  std::list<const Expr*>& expr_list) const override;
1458 
1459  private:
1461  const std::shared_ptr<Analyzer::Expr> start_;
1462  const std::shared_ptr<Analyzer::Expr> end_;
1463 };
1464 
1465 /*
1466  * @type DatetruncExpr
1467  * @brief the DATE_TRUNC expression
1468  */
1469 class DatetruncExpr : public Expr {
1470  public:
1472  bool has_agg,
1473  DatetruncField f,
1474  std::shared_ptr<Analyzer::Expr> e)
1475  : Expr(ti, has_agg), field_(f), from_expr_(e) {}
1476  DatetruncField get_field() const { return field_; }
1477  const Expr* get_from_expr() const { return from_expr_.get(); }
1478  const std::shared_ptr<Analyzer::Expr> get_own_from_expr() const { return from_expr_; }
1479  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1480  void check_group_by(
1481  const std::list<std::shared_ptr<Analyzer::Expr>>& groupby) const override;
1482  void group_predicates(std::list<const Expr*>& scan_predicates,
1483  std::list<const Expr*>& join_predicates,
1484  std::list<const Expr*>& const_predicates) const override;
1485  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1486  void collect_column_var(
1487  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1488  colvar_set,
1489  bool include_agg) const override;
1490  std::shared_ptr<Analyzer::Expr> rewrite_with_targetlist(
1491  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1492  std::shared_ptr<Analyzer::Expr> rewrite_with_child_targetlist(
1493  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1494  std::shared_ptr<Analyzer::Expr> rewrite_agg_to_var(
1495  const std::vector<std::shared_ptr<TargetEntry>>& tlist) const override;
1496  bool operator==(const Expr& rhs) const override;
1497  std::string toString() const override;
1498  void find_expr(bool (*f)(const Expr*),
1499  std::list<const Expr*>& expr_list) const override;
1500 
1501  private:
1503  std::shared_ptr<Analyzer::Expr> from_expr_;
1504 };
1505 
1506 class FunctionOper : public Expr {
1507  public:
1509  const std::string& name,
1510  const std::vector<std::shared_ptr<Analyzer::Expr>>& args)
1511  : Expr(ti, false), name_(name), args_(args) {}
1512 
1513  std::string getName() const { return name_; }
1514 
1515  size_t getArity() const { return args_.size(); }
1516 
1517  const Analyzer::Expr* getArg(const size_t i) const {
1518  CHECK_LT(i, args_.size());
1519  return args_[i].get();
1520  }
1521 
1522  std::shared_ptr<Analyzer::Expr> getOwnArg(const size_t i) const {
1523  CHECK_LT(i, args_.size());
1524  return args_[i];
1525  }
1526 
1527  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1528  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1529  void collect_column_var(
1530  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1531  colvar_set,
1532  bool include_agg) const override;
1533 
1534  bool operator==(const Expr& rhs) const override;
1535  std::string toString() const override;
1536 
1537  private:
1538  const std::string name_;
1539  const std::vector<std::shared_ptr<Analyzer::Expr>> args_;
1540 };
1541 
1543  public:
1545  const SQLTypeInfo& ti,
1546  const std::string& name,
1547  const std::vector<std::shared_ptr<Analyzer::Expr>>& args)
1548  : FunctionOper(ti, name, args) {}
1549 
1550  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1551 
1552  bool operator==(const Expr& rhs) const override;
1553 };
1554 
1555 /*
1556  * @type OffsetInFragment
1557  * @brief The offset of a row in the current fragment. To be used by updates.
1558  */
1559 class OffsetInFragment : public Expr {
1560  public:
1562 
1563  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1564 
1565  bool operator==(const Expr& rhs) const override;
1566  std::string toString() const override;
1567 };
1568 
1569 /*
1570  * @type OrderEntry
1571  * @brief represents an entry in ORDER BY clause.
1572  */
1573 struct OrderEntry {
1574  OrderEntry(int t, bool d, bool nf) : tle_no(t), is_desc(d), nulls_first(nf){};
1576  std::string toString() const;
1577  void print() const { std::cout << toString(); }
1578  int tle_no; /* targetlist entry number: 1-based */
1579  bool is_desc; /* true if order is DESC */
1580  bool nulls_first; /* true if nulls are ordered first. otherwise last. */
1581 };
1582 
1583 /*
1584  * @type WindowFunction
1585  * @brief A window function.
1586  */
1587 class WindowFunction : public Expr {
1588  public:
1590  const SqlWindowFunctionKind kind,
1591  const std::vector<std::shared_ptr<Analyzer::Expr>>& args,
1592  const std::vector<std::shared_ptr<Analyzer::Expr>>& partition_keys,
1593  const std::vector<std::shared_ptr<Analyzer::Expr>>& order_keys,
1594  const std::vector<OrderEntry>& collation)
1595  : Expr(ti)
1596  , kind_(kind)
1597  , args_(args)
1598  , partition_keys_(partition_keys)
1599  , order_keys_(order_keys)
1600  , collation_(collation){};
1601 
1602  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1603 
1604  bool operator==(const Expr& rhs) const override;
1605  std::string toString() const override;
1606 
1608 
1609  const std::vector<std::shared_ptr<Analyzer::Expr>>& getArgs() const { return args_; }
1610 
1611  const std::vector<std::shared_ptr<Analyzer::Expr>>& getPartitionKeys() const {
1612  return partition_keys_;
1613  }
1614 
1615  const std::vector<std::shared_ptr<Analyzer::Expr>>& getOrderKeys() const {
1616  return order_keys_;
1617  }
1618 
1619  const std::vector<OrderEntry>& getCollation() const { return collation_; }
1620 
1621  private:
1623  const std::vector<std::shared_ptr<Analyzer::Expr>> args_;
1624  const std::vector<std::shared_ptr<Analyzer::Expr>> partition_keys_;
1625  const std::vector<std::shared_ptr<Analyzer::Expr>> order_keys_;
1626  const std::vector<OrderEntry> collation_;
1627 };
1628 
1629 /*
1630  * @type ArrayExpr
1631  * @brief Corresponds to ARRAY[] statements in SQL
1632  */
1633 
1634 class ArrayExpr : public Expr {
1635  public:
1636  ArrayExpr(SQLTypeInfo const& array_ti,
1637  ExpressionPtrVector const& array_exprs,
1638  bool is_null = false,
1639  bool local_alloc = false)
1640  : Expr(array_ti)
1641  , contained_expressions_(array_exprs)
1642  , local_alloc_(local_alloc)
1643  , is_null_(is_null) {}
1644 
1645  Analyzer::ExpressionPtr deep_copy() const override;
1646  std::string toString() const override;
1647  bool operator==(Expr const& rhs) const override;
1648  size_t getElementCount() const { return contained_expressions_.size(); }
1649  bool isLocalAlloc() const { return local_alloc_; }
1650  bool isNull() const { return is_null_; }
1651 
1652  const Analyzer::Expr* getElement(const size_t i) const {
1653  CHECK_LT(i, contained_expressions_.size());
1654  return contained_expressions_[i].get();
1655  }
1656 
1657  void collect_rte_idx(std::set<int>& rte_idx_set) const override;
1658  void collect_column_var(
1659  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1660  colvar_set,
1661  bool include_agg) const override;
1662 
1663  private:
1666  bool is_null_; // constant is NULL
1667 };
1668 
1669 /*
1670  * @type GeoUOper
1671  * @brief Geo unary operation
1672  */
1673 class GeoUOper : public Expr {
1674  public:
1676  const SQLTypeInfo& ti,
1677  const SQLTypeInfo& ti0,
1678  const std::vector<std::shared_ptr<Analyzer::Expr>>& args)
1679  : Expr(ti), op_(op), ti0_(ti0), args0_(args){};
1680 
1681  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1682 
1683  bool operator==(const Expr& rhs) const override;
1684  std::string toString() const override;
1685 
1687  const SQLTypeInfo getTypeInfo0() const { return ti0_; }
1688  const std::vector<std::shared_ptr<Analyzer::Expr>>& getArgs0() const { return args0_; }
1689 
1690  private:
1692  SQLTypeInfo ti0_; // Type of geo input 0 (or geo output)
1693  const std::vector<std::shared_ptr<Analyzer::Expr>> args0_;
1694 };
1695 
1696 /*
1697  * @type GeoBinOper
1698  * @brief Geo binary operation
1699  */
1700 class GeoBinOper : public Expr {
1701  public:
1703  const SQLTypeInfo& ti,
1704  const SQLTypeInfo& ti0,
1705  const SQLTypeInfo& ti1,
1706  const std::vector<std::shared_ptr<Analyzer::Expr>>& args0,
1707  const std::vector<std::shared_ptr<Analyzer::Expr>>& args1)
1708  : Expr(ti), op_(op), ti0_(ti0), ti1_(ti1), args0_(args0), args1_(args1){};
1709 
1710  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1711 
1712  bool operator==(const Expr& rhs) const override;
1713  std::string toString() const override;
1714 
1716  const SQLTypeInfo getTypeInfo0() const { return ti0_; }
1717  const SQLTypeInfo getTypeInfo1() const { return ti1_; }
1718  const std::vector<std::shared_ptr<Analyzer::Expr>>& getArgs0() const { return args0_; }
1719  const std::vector<std::shared_ptr<Analyzer::Expr>>& getArgs1() const { return args1_; }
1720 
1721  private:
1723  SQLTypeInfo ti0_; // Type of geo input 0 (or geo output)
1724  SQLTypeInfo ti1_; // Type of geo input 1
1725  const std::vector<std::shared_ptr<Analyzer::Expr>> args0_;
1726  const std::vector<std::shared_ptr<Analyzer::Expr>> args1_;
1727 };
1728 
1729 /*
1730  * @type TargetEntry
1731  * @brief Target list defines a relational projection. It is a list of TargetEntry's.
1732  */
1734  public:
1735  TargetEntry(const std::string& n, std::shared_ptr<Analyzer::Expr> e, bool u)
1736  : resname(n), expr(e), unnest(u) {}
1737  virtual ~TargetEntry() {}
1738  const std::string& get_resname() const { return resname; }
1739  void set_resname(const std::string& name) { resname = name; }
1740  Expr* get_expr() const { return expr.get(); }
1741  std::shared_ptr<Expr> get_own_expr() const { return expr; }
1742  void set_expr(std::shared_ptr<Analyzer::Expr> e) { expr = e; }
1743  bool get_unnest() const { return unnest; }
1744  std::string toString() const;
1745  void print() const { std::cout << toString(); }
1746 
1747  private:
1748  std::string resname; // alias name, e.g., SELECT salary + bonus AS compensation,
1749  std::shared_ptr<Analyzer::Expr> expr; // expression to evaluate for the value
1750  bool unnest; // unnest a collection type
1751 };
1752 
1753 class RangeTableEntry;
1754 
1755 /*
1756  * @type Query
1757  * @brief parse tree for a query
1758  */
1759 class Query {
1760  public:
1762  : is_distinct(false)
1763  , where_predicate(nullptr)
1764  , having_predicate(nullptr)
1765  , order_by(nullptr)
1766  , next_query(nullptr)
1767  , is_unionall(false)
1768  , stmt_type(kSELECT)
1769  , num_aggs(0)
1770  , result_table_id(0)
1771  , limit(0)
1772  , offset(0) {}
1773  virtual ~Query();
1774  bool get_is_distinct() const { return is_distinct; }
1775  int get_num_aggs() const { return num_aggs; }
1776  const std::vector<std::shared_ptr<TargetEntry>>& get_targetlist() const {
1777  return targetlist;
1778  }
1779  std::vector<std::shared_ptr<TargetEntry>>& get_targetlist_nonconst() {
1780  return targetlist;
1781  }
1782  const std::vector<RangeTableEntry*>& get_rangetable() const { return rangetable; }
1783  const Expr* get_where_predicate() const { return where_predicate.get(); }
1784  const std::list<std::shared_ptr<Analyzer::Expr>>& get_group_by() const {
1785  return group_by;
1786  };
1787  const Expr* get_having_predicate() const { return having_predicate.get(); }
1788  const std::list<OrderEntry>* get_order_by() const { return order_by; }
1789  const Query* get_next_query() const { return next_query; }
1791  bool get_is_unionall() const { return is_unionall; }
1792  int get_result_table_id() const { return result_table_id; }
1793  const std::list<int>& get_result_col_list() const { return result_col_list; }
1794  void set_result_col_list(const std::list<int>& col_list) { result_col_list = col_list; }
1795  void set_result_table_id(int id) { result_table_id = id; }
1796  void set_is_distinct(bool d) { is_distinct = d; }
1797  void set_where_predicate(std::shared_ptr<Analyzer::Expr> p) { where_predicate = p; }
1798  void set_group_by(std::list<std::shared_ptr<Analyzer::Expr>>& g) { group_by = g; }
1799  void set_having_predicate(std::shared_ptr<Analyzer::Expr> p) { having_predicate = p; }
1800  void set_order_by(std::list<OrderEntry>* o) { order_by = o; }
1801  void set_next_query(Query* q) { next_query = q; }
1802  void set_is_unionall(bool u) { is_unionall = u; }
1804  void set_num_aggs(int a) { num_aggs = a; }
1805  int get_rte_idx(const std::string& range_var_name) const;
1806  RangeTableEntry* get_rte(int rte_idx) const { return rangetable[rte_idx]; }
1807  void add_rte(RangeTableEntry* rte);
1808  void add_tle(std::shared_ptr<TargetEntry> tle) { targetlist.push_back(tle); }
1809  int64_t get_limit() const { return limit; }
1810  void set_limit(int64_t l) { limit = l; }
1811  int64_t get_offset() const { return offset; }
1812  void set_offset(int64_t o) { offset = o; }
1813 
1814  private:
1815  bool is_distinct; // true only if SELECT DISTINCT
1816  std::vector<std::shared_ptr<TargetEntry>> targetlist; // represents the SELECT clause
1817  std::vector<RangeTableEntry*> rangetable; // represents the FROM clause for SELECT. For
1818  // INSERT, DELETE, UPDATE the result table is
1819  // always the first entry in rangetable.
1820  std::shared_ptr<Analyzer::Expr> where_predicate; // represents the WHERE clause
1821  std::list<std::shared_ptr<Analyzer::Expr>> group_by; // represents the GROUP BY clause
1822  std::shared_ptr<Analyzer::Expr> having_predicate; // represents the HAVING clause
1823  std::list<OrderEntry>* order_by; // represents the ORDER BY clause
1824  Query* next_query; // the next query to UNION
1825  bool is_unionall; // true only if it is UNION ALL
1827  int num_aggs; // number of aggregate functions in query
1828  int result_table_id; // for INSERT statements only
1829  std::list<int> result_col_list; // for INSERT statement only
1830  int64_t limit; // row count for LIMIT clause. 0 means ALL
1831  int64_t offset; // offset in OFFSET clause. 0 means no offset.
1832 };
1833 
1834 class GeoExpr : public Expr {
1835  public:
1836  GeoExpr(const SQLTypeInfo& ti) : Expr(ti) {}
1837 
1838  // geo expressions might hide child expressions (e.g. constructors). Centralize logic
1839  // for pulling out child expressions for simplicity in visitors.
1840  virtual std::vector<Analyzer::Expr*> getChildExprs() const { return {}; }
1841 };
1842 
1848 class GeoColumnVar : public ColumnVar {
1849  public:
1851  const int table_id,
1852  const int column_id,
1853  const int range_table_index,
1854  const bool with_bounds,
1855  const bool with_render_group)
1856  : ColumnVar(ti, table_id, column_id, range_table_index)
1857  , with_bounds_(with_bounds)
1858  , with_render_group_(with_render_group) {}
1859 
1861  const bool with_bounds,
1862  const bool with_render_group)
1863  : ColumnVar(column_var->get_type_info(),
1864  column_var->get_table_id(),
1865  column_var->get_column_id(),
1866  column_var->get_rte_idx())
1867  , with_bounds_(with_bounds)
1868  , with_render_group_(with_render_group) {}
1869 
1870  protected:
1873 };
1874 
1875 class GeoConstant : public GeoExpr {
1876  public:
1877  GeoConstant(std::unique_ptr<Geospatial::GeoBase>&& geo, const SQLTypeInfo& ti);
1878 
1879  std::shared_ptr<Analyzer::Expr> deep_copy() const final;
1880 
1881  std::string toString() const final;
1882 
1883  bool operator==(const Expr&) const final;
1884 
1885  size_t physicalCols() const;
1886 
1887  std::shared_ptr<Analyzer::Constant> makePhysicalConstant(const size_t index) const;
1888 
1889  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) final;
1890 
1891  std::string getWKTString() const;
1892 
1893  private:
1894  std::unique_ptr<Geospatial::GeoBase> geo_;
1895 };
1896 
1901 class GeoOperator : public GeoExpr {
1902  public:
1903  GeoOperator(const SQLTypeInfo& ti,
1904  const std::string& name,
1905  const std::vector<std::shared_ptr<Analyzer::Expr>>& args,
1906  const std::optional<int>& output_srid_override = std::nullopt);
1907 
1908  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1909 
1910  void collect_rte_idx(std::set<int>& rte_idx_set) const final;
1911 
1912  void collect_column_var(
1913  std::set<const ColumnVar*, bool (*)(const ColumnVar*, const ColumnVar*)>&
1914  colvar_set,
1915  bool include_agg) const final;
1916 
1917  std::string toString() const override;
1918 
1919  bool operator==(const Expr&) const override;
1920 
1921  size_t size() const;
1922 
1923  Analyzer::Expr* getOperand(const size_t index) const;
1924 
1925  const std::string& getName() const { return name_; }
1926 
1927  std::vector<std::shared_ptr<Analyzer::Expr>> getArgs() const { return args_; }
1928 
1929  std::vector<Analyzer::Expr*> getChildExprs() const override {
1930  std::vector<Analyzer::Expr*> ret;
1931  ret.reserve(args_.size());
1932  for (const auto& arg : args_) {
1933  ret.push_back(arg.get());
1934  }
1935  return ret;
1936  }
1937 
1938  std::shared_ptr<Analyzer::Expr> add_cast(const SQLTypeInfo& new_type_info) final;
1939 
1941 
1942  protected:
1943  const std::string name_;
1944  const std::vector<std::shared_ptr<Analyzer::Expr>> args_;
1945 
1946  // for legacy geo code, allow passing in a srid to force a transform in the function
1947  std::optional<int> output_srid_override_;
1948 };
1949 
1951  public:
1953  const std::string& name,
1954  const std::vector<std::shared_ptr<Analyzer::Expr>>& args,
1955  const int32_t input_srid,
1956  const int32_t output_srid)
1957  : GeoOperator(ti, name, args), input_srid_(input_srid), output_srid_(output_srid) {}
1958 
1959  std::shared_ptr<Analyzer::Expr> deep_copy() const override;
1960 
1961  std::string toString() const override;
1962 
1963  bool operator==(const Expr&) const override;
1964 
1965  int32_t getInputSRID() const { return input_srid_; }
1966 
1967  int32_t getOutputSRID() const { return output_srid_; }
1968 
1969  private:
1970  const int32_t input_srid_;
1971  const int32_t output_srid_;
1972 };
1973 
1974 } // namespace Analyzer
1975 
1976 inline std::shared_ptr<Analyzer::Var> var_ref(const Analyzer::Expr* expr,
1977  const Analyzer::Var::WhichRow which_row,
1978  const int varno) {
1979  const auto col_expr = dynamic_cast<const Analyzer::ColumnVar*>(expr);
1980  const int table_id = col_expr ? col_expr->get_table_id() : 0;
1981  const int column_id = col_expr ? col_expr->get_column_id() : 0;
1982  const int rte_idx = col_expr ? col_expr->get_rte_idx() : -1;
1983  return makeExpr<Analyzer::Var>(
1984  expr->get_type_info(), table_id, column_id, rte_idx, which_row, varno);
1985 }
1986 
1987 // Returns true iff the two expression lists are equal (same size and each element are
1988 // equal).
1989 bool expr_list_match(const std::vector<std::shared_ptr<Analyzer::Expr>>& lhs,
1990  const std::vector<std::shared_ptr<Analyzer::Expr>>& rhs);
1991 
1992 // Remove a cast operator if present.
1993 std::shared_ptr<Analyzer::Expr> remove_cast(const std::shared_ptr<Analyzer::Expr>& expr);
1994 
1995 #endif // ANALYZER_H
DEVICE auto upper_bound(ARGS &&...args)
Definition: gpu_enabled.h:123
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3121
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1222
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:3388
std::list< ExpressionPtr > ExpressionPtrList
Definition: Analyzer.h:180
int get_table_id() const
Definition: Analyzer.h:193
GeoBinOper(const Geospatial::GeoBase::GeoOp op, const SQLTypeInfo &ti, const SQLTypeInfo &ti0, const SQLTypeInfo &ti1, const std::vector< std::shared_ptr< Analyzer::Expr >> &args0, const std::vector< std::shared_ptr< Analyzer::Expr >> &args1)
Definition: Analyzer.h:1702
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1064
Query * next_query
Definition: Analyzer.h:1824
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:1296
InIntegerSet(const std::shared_ptr< const Analyzer::Expr > a, const std::vector< int64_t > &values, const bool not_null)
Definition: Analyzer.cpp:1612
virtual void get_domain(DomainSet &domain_set) const
Definition: Analyzer.h:172
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1932
bool operator==(const Expr &rhs) const override
Definition: Analyzer.h:607
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:642
TargetEntry(const std::string &n, std::shared_ptr< Analyzer::Expr > e, bool u)
Definition: Analyzer.h:1735
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:280
std::string toString() const override
Definition: Analyzer.cpp:2770
Query * parsetree
Definition: Analyzer.h:618
const std::list< std::shared_ptr< Analyzer::Expr > > & get_value_list() const
Definition: Analyzer.h:336
SQLAgg
Definition: sqldefs.h:71
float get_likelihood() const
Definition: Analyzer.h:1189
std::vector< Analyzer::Expr * > getChildExprs() const override
Definition: Analyzer.h:1929
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2081
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:283
std::shared_ptr< Analyzer::Expr > expr
Definition: Analyzer.h:1749
virtual bool operator==(const Expr &rhs) const =0
std::string toString() const override
Definition: Analyzer.cpp:2688
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:550
SqlWindowFunctionKind getKind() const
Definition: Analyzer.h:1607
Var(const SQLTypeInfo &ti, int r, int c, int i, WhichRow o, int v)
Definition: Analyzer.h:268
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:204
virtual ~Expr()
Definition: Analyzer.h:75
Expr(SQLTypes t, int d, int s, bool notnull)
Definition: Analyzer.h:71
bool unnest
Definition: Analyzer.h:1750
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:1598
InValues(std::shared_ptr< Analyzer::Expr > a, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
Definition: Analyzer.cpp:1594
const Expr * get_from_expr() const
Definition: Analyzer.h:1352
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:1459
const Expr * get_partition_count() const
Definition: Analyzer.h:1091
Constant(const SQLTypeInfo &ti, bool n, Datum v)
Definition: Analyzer.h:321
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:1024
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2427
std::string toString() const override
Definition: Analyzer.cpp:2517
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3096
Var(const SQLTypeInfo &ti, WhichRow o, int v)
Definition: Analyzer.h:270
GeoConstant(std::unique_ptr< Geospatial::GeoBase > &&geo, const SQLTypeInfo &ti)
Definition: Analyzer.cpp:3482
void get_domain(DomainSet &domain_set) const override
Definition: Analyzer.cpp:3290
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2103
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:845
std::string toString() const final
Definition: Analyzer.cpp:3497
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2205
bool is_constant_expr() const
Definition: Analyzer.h:1166
const Expr * get_else_expr() const
Definition: Analyzer.h:1307
const SQLTypeInfo getTypeInfo0() const
Definition: Analyzer.h:1716
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2315
void set_contains_agg(bool a)
Definition: Analyzer.h:80
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:225
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs0() const
Definition: Analyzer.h:1718
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:68
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:3357
const std::vector< int64_t > & get_value_list() const
Definition: Analyzer.h:681
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2992
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2197
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:843
OrderEntry(int t, bool d, bool nf)
Definition: Analyzer.h:1574
const Expr * get_escape_expr() const
Definition: Analyzer.h:954
virtual std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
Definition: Analyzer.h:124
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:784
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:906
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2010
std::shared_ptr< Analyzer::Expr > decompress()
Definition: Analyzer.cpp:688
size_t getArity() const
Definition: Analyzer.h:1515
std::optional< int > output_srid_override_
Definition: Analyzer.h:1947
Definition: Analyzer.h:1733
DatediffExpr(const SQLTypeInfo &ti, const DatetruncField f, const std::shared_ptr< Analyzer::Expr > start, const std::shared_ptr< Analyzer::Expr > end)
Definition: Analyzer.h:1429
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:111
int32_t getInputSRID() const
Definition: Analyzer.h:1965
std::shared_ptr< Analyzer::Expr > remove_cast(const std::shared_ptr< Analyzer::Expr > &expr)
Definition: Analyzer.cpp:3723
RangeOper(const bool l_inclusive, const bool r_inclusive, std::shared_ptr< Analyzer::Expr > l, std::shared_ptr< Analyzer::Expr > r)
Definition: Analyzer.h:525
static bool colvar_comp(const ColumnVar *l, const ColumnVar *r)
Definition: Analyzer.h:207
SQLTypes
Definition: sqltypes.h:38
void add_rte(RangeTableEntry *rte)
Definition: Analyzer.cpp:1412
const SQLTypeInfo getTypeInfo0() const
Definition: Analyzer.h:1687
std::shared_ptr< Analyzer::Expr > operand
Definition: Analyzer.h:410
AggExpr(SQLTypes t, SQLAgg a, Expr *g, bool d, std::shared_ptr< Analyzer::Constant > e, int idx)
Definition: Analyzer.h:1238
virtual void print() const
Definition: Analyzer.h:149
std::list< int > result_col_list
Definition: Analyzer.h:1829
void set_varno(int n)
Definition: Analyzer.h:275
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:738
std::list< std::pair< std::shared_ptr< Analyzer::Expr >, std::shared_ptr< Analyzer::Expr > > > expr_pair_list
Definition: Analyzer.h:1334
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:797
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:212
GeoUOper(const Geospatial::GeoBase::GeoOp op, const SQLTypeInfo &ti, const SQLTypeInfo &ti0, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
Definition: Analyzer.h:1675
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:1777
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2067
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:392
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2444
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:494
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:1188
void collect_rte_idx(std::set< int > &rte_idx_set) const final
Definition: Analyzer.cpp:3596
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2053
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2267
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:1534
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:1034
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3031
SQLQualifier
Definition: sqldefs.h:69
virtual void add_unique(std::list< const Expr * > &expr_list) const
Definition: Analyzer.cpp:2965
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:802
std::shared_ptr< Analyzer::Expr > right_operand
Definition: Analyzer.h:516
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:1258
SQLStmtType stmt_type
Definition: Analyzer.h:1826
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1068
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:191
const Query * get_parsetree() const
Definition: Analyzer.h:578
bool operator==(Expr const &rhs) const override
Definition: Analyzer.cpp:2463
ExtractField get_field() const
Definition: Analyzer.h:1351
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1900
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:1631
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:142
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:134
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:287
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:96
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3248
const Expr * get_escape_expr() const
Definition: Analyzer.h:1026
const Expr * get_right_operand() const
Definition: Analyzer.h:442
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:1743
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:3173
GeoTransformOperator(const SQLTypeInfo &ti, const std::string &name, const std::vector< std::shared_ptr< Analyzer::Expr >> &args, const int32_t input_srid, const int32_t output_srid)
Definition: Analyzer.h:1952
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1119
std::string toString() const override
Definition: Analyzer.cpp:2913
std::shared_ptr< Analyzer::Expr > get_shared_ptr()
Definition: Analyzer.h:76
virtual void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const
Definition: Analyzer.h:82
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:964
auto getOutputSridOverride() const
Definition: Analyzer.h:1940
std::list< std::shared_ptr< Analyzer::Expr > > group_by
Definition: Analyzer.h:1821
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:660
string name
Definition: setup.in.py:72
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:81
void print() const
Definition: Analyzer.h:1745
const std::vector< std::shared_ptr< Analyzer::Expr > > args0_
Definition: Analyzer.h:1693
SQLTypeInfo ti0_
Definition: Analyzer.h:1723
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:603
std::shared_ptr< Analyzer::Expr > like_expr
Definition: Analyzer.h:1001
bool get_is_null() const
Definition: Analyzer.h:333
const std::vector< std::shared_ptr< Analyzer::Expr > > args0_
Definition: Analyzer.h:1725
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:1194
std::string toString() const override
Definition: Analyzer.cpp:3379
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:916
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3226
int tle_no
Definition: Analyzer.h:1578
~OrderEntry()
Definition: Analyzer.h:1575
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:146
std::shared_ptr< Analyzer::Var > var_ref(const Analyzer::Expr *expr, const Analyzer::Var::WhichRow which_row, const int varno)
Definition: Analyzer.h:1976
const std::shared_ptr< const Analyzer::Expr > arg
Definition: Analyzer.h:689
const std::shared_ptr< Analyzer::Expr > get_own_operand() const
Definition: Analyzer.h:371
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:211
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:215
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1112
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:485
void cast_from_string(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:1125
bool get_contains_agg() const
Definition: Analyzer.h:79
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3285
std::string toString() const override
Definition: Analyzer.cpp:2730
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
Definition: Analyzer.cpp:1369
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1207
const SQLTypeInfo getTypeInfo1() const
Definition: Analyzer.h:1717
std::shared_ptr< Analyzer::Expr > ExpressionPtr
Definition: Analyzer.h:179
const Geospatial::GeoBase::GeoOp op_
Definition: Analyzer.h:1722
const Expr * get_arg() const
Definition: Analyzer.h:1023
const std::vector< std::shared_ptr< Analyzer::Expr > > order_keys_
Definition: Analyzer.h:1625
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2045
void set_order_by(std::list< OrderEntry > *o)
Definition: Analyzer.h:1800
Expr * get_arg() const
Definition: Analyzer.h:1250
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2370
DatetruncField get_field() const
Definition: Analyzer.h:1476
const std::list< OrderEntry > * get_order_by() const
Definition: Analyzer.h:1788
void set_result_col_list(const std::list< int > &col_list)
Definition: Analyzer.h:1794
const Expr * get_arg() const
Definition: Analyzer.h:1187
std::shared_ptr< Analyzer::Expr > upper_bound_
Definition: Analyzer.h:1171
Constants for Builtin SQL Types supported by OmniSci.
void set_which_row(WhichRow r)
Definition: Analyzer.h:273
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
Definition: Analyzer.cpp:1350
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1284
const Expr * get_where_predicate() const
Definition: Analyzer.h:1783
int get_num_aggs() const
Definition: Analyzer.h:1775
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:3397
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:3588
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:970
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:60
const std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1539
const std::vector< std::shared_ptr< Analyzer::Expr > > partition_keys_
Definition: Analyzer.h:1624
void set_constant_expr() const
Definition: Analyzer.h:1165
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:3187
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2349
void set_offset(int64_t o)
Definition: Analyzer.h:1812
UOper(SQLTypes t, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:365
~Constant() override
Definition: Analyzer.cpp:42
std::unique_ptr< Geospatial::GeoBase > geo_
Definition: Analyzer.h:1894
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2259
SQLQualifier qualifier
Definition: Analyzer.h:513
bool isNull() const
Definition: Analyzer.h:1650
std::shared_ptr< Analyzer::Expr > partition_count_
Definition: Analyzer.h:1172
virtual std::vector< Analyzer::Expr * > getChildExprs() const
Definition: Analyzer.h:1840
std::string toString() const override
Definition: Analyzer.cpp:2849
const std::vector< std::shared_ptr< Analyzer::Expr > > & getOrderKeys() const
Definition: Analyzer.h:1615
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:1659
std::string toString() const override
Definition: Analyzer.cpp:2578
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:476
SQLTypeInfo type_info
Definition: Analyzer.h:175
const std::vector< OrderEntry > & getCollation() const
Definition: Analyzer.h:1619
const Expr * get_left_operand() const
Definition: Analyzer.h:538
GeoColumnVar(const SQLTypeInfo &ti, const int table_id, const int column_id, const int range_table_index, const bool with_bounds, const bool with_render_group)
Definition: Analyzer.h:1850
EncodingType get_compression() const
Definition: Analyzer.h:196
std::list< const Expr * > DomainSet
Definition: Analyzer.h:60
double inline_fp_null_val(const SQL_TYPE_INFO &ti)
virtual void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const
Definition: Analyzer.h:115
void set_constval(Datum d)
Definition: Analyzer.h:335
const Expr * get_arg() const
Definition: Analyzer.h:951
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:770
std::enable_if< std::is_base_of< Analyzer::Expr, Tp >::value, std::shared_ptr< Tp > >::type makeExpr(Args &&...args)
Definition: Analyzer.h:51
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3062
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:583
std::string toString() const override
Definition: Analyzer.cpp:2526
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:1444
const std::string & get_resname() const
Definition: Analyzer.h:1738
double get_bound_val(const Analyzer::Expr *bound_expr) const
Definition: Analyzer.cpp:3420
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2039
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1052
~Subquery() override
Definition: Analyzer.cpp:48
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:599
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2387
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:723
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1046
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:589
bool operator==(const Expr &) const override
Definition: Analyzer.cpp:3683
int get_rte_idx(const std::string &range_var_name) const
Definition: Analyzer.cpp:1401
void cast_string(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:1114
void set_type_info(const SQLTypeInfo &ti)
Definition: Analyzer.h:78
const std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1623
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3268
std::string toString() const override
Definition: Analyzer.cpp:2547
const std::shared_ptr< Analyzer::Expr > get_own_from_expr() const
Definition: Analyzer.h:1478
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:70
std::string toString() const override
Definition: Analyzer.cpp:2653
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:861
LikelihoodExpr(std::shared_ptr< Analyzer::Expr > a, float l=0.5)
Definition: Analyzer.h:1185
constexpr double a
Definition: Utm.h:38
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2237
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2975
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:421
std::string toString() const override
Definition: Analyzer.cpp:2748
std::string toString() const override
Definition: Analyzer.cpp:2779
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:920
std::string toString() const override
Definition: Analyzer.cpp:2711
bool get_calc_encoded_length() const
Definition: Analyzer.h:704
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2214
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1923
std::string toString() const override
Definition: Analyzer.cpp:2890
DatetruncField field_
Definition: Analyzer.h:1502
const Geospatial::GeoBase::GeoOp op_
Definition: Analyzer.h:1691
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:1099
std::string toString() const override
Definition: Analyzer.cpp:2867
SQLOps get_optype() const
Definition: Analyzer.h:438
std::shared_ptr< Analyzer::Expr > left_operand
Definition: Analyzer.h:515
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2448
const std::vector< std::shared_ptr< Analyzer::Expr > > args1_
Definition: Analyzer.h:1726
std::shared_ptr< Analyzer::Constant > arg1
Definition: Analyzer.h:1287
std::string toString() const
Definition: Analyzer.cpp:2943
const Query * get_next_query() const
Definition: Analyzer.h:1789
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:109
std::shared_ptr< Analyzer::Expr > normalize_simple_predicate(int &rte_idx) const override
Definition: Analyzer.cpp:1483
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:662
EncodingType
Definition: sqltypes.h:233
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:171
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:164
static SQLTypeInfo common_string_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:411
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:465
DatetruncExpr(const SQLTypeInfo &ti, bool has_agg, DatetruncField f, std::shared_ptr< Analyzer::Expr > e)
Definition: Analyzer.h:1471
std::shared_ptr< Analyzer::Expr > right_operand_
Definition: Analyzer.h:563
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:1526
std::shared_ptr< Analyzer::Constant > get_arg1() const
Definition: Analyzer.h:1253
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:469
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:180
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.h:612
Expr(const SQLTypeInfo &ti, bool has_agg=false)
Definition: Analyzer.h:73
std::shared_ptr< Analyzer::Expr > deep_copy() const final
Definition: Analyzer.cpp:3492
std::string toString() const override
Definition: Analyzer.cpp:2642
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1964
const DatetruncField field_
Definition: Analyzer.h:1460
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:1673
const std::vector< std::shared_ptr< Analyzer::Expr > > & getTuple() const
Definition: Analyzer.h:243
CONSTEXPR DEVICE bool is_null(const T &value)
#define INT32_MIN
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:3178
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2087
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs() const
Definition: Analyzer.h:1609
RangeTableEntry * get_rte(int rte_idx) const
Definition: Analyzer.h:1806
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:3169
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:811
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:3194
const std::shared_ptr< Analyzer::Expr > get_own_from_expr() const
Definition: Analyzer.h:1353
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3049
DateaddField
Definition: DateAdd.h:42
std::shared_ptr< Analyzer::Expr > lower_bound_
Definition: Analyzer.h:1170
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:978
bool is_integer() const
Definition: sqltypes.h:511
std::vector< std::shared_ptr< TargetEntry > > targetlist
Definition: Analyzer.h:1816
std::string toString() const override
Definition: Analyzer.cpp:2723
const DateaddField field_
Definition: Analyzer.h:1418
DatetruncField
Definition: DateTruncate.h:27
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:116
std::shared_ptr< Analyzer::Expr > from_expr_
Definition: Analyzer.h:1503
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:631
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:3710
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:885
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3239
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2680
Subquery(const SQLTypeInfo &ti, Query *q)
Definition: Analyzer.h:575
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs0() const
Definition: Analyzer.h:1688
std::shared_ptr< Analyzer::Expr > getOwnArg(const size_t i) const
Definition: Analyzer.h:1522
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:381
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:378
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:196
Expr * get_expr() const
Definition: Analyzer.h:1740
int64_t get_offset() const
Definition: Analyzer.h:1811
std::string toString() const override
Definition: Analyzer.cpp:2511
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:1432
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1462
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2410
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:912
std::string toString() const override
Definition: Analyzer.cpp:2759
WhichRow get_which_row() const
Definition: Analyzer.h:272
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3273
void set_expr(std::shared_ptr< Analyzer::Expr > e)
Definition: Analyzer.h:1742
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2335
const std::shared_ptr< Analyzer::Expr > number_
Definition: Analyzer.h:1419
ArrayExpr(SQLTypeInfo const &array_ti, ExpressionPtrVector const &array_exprs, bool is_null=false, bool local_alloc=false)
Definition: Analyzer.h:1636
const std::list< std::shared_ptr< Analyzer::Expr > > value_list
Definition: Analyzer.h:347
std::string resname
Definition: Analyzer.h:1748
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:2676
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2418
bool get_is_distinct() const
Definition: Analyzer.h:1774
const std::string & getName() const
Definition: Analyzer.h:1925
std::string toString() const override
Definition: Analyzer.cpp:2859
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:718
static SQLTypeInfo common_numeric_type(const SQLTypeInfo &type1, const SQLTypeInfo &type2)
Definition: Analyzer.cpp:451
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:3183
SQLTypeInfo ti1_
Definition: Analyzer.h:1724
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1941
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:595
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:1687
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2109
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1461
virtual ~TargetEntry()
Definition: Analyzer.h:1737
int get_varno() const
Definition: Analyzer.h:274
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:545
std::string toString() const
Definition: Analyzer.cpp:2953
bool get_is_simple() const
Definition: Analyzer.h:956
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:1645
std::vector< std::shared_ptr< Analyzer::Expr > > getArgs() const
Definition: Analyzer.h:1927
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:903
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:1701
bool nulls_first
Definition: Analyzer.h:1580
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3201
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:703
int64_t get_limit() const
Definition: Analyzer.h:1809
bool get_is_distinct() const
Definition: Analyzer.h:1252
FunctionOperWithCustomTypeHandling(const SQLTypeInfo &ti, const std::string &name, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
Definition: Analyzer.h:1544
bool get_unnest() const
Definition: Analyzer.h:1743
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2225
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:712
const std::vector< OrderEntry > collation_
Definition: Analyzer.h:1626
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:1346
const Expr * get_start_expr() const
Definition: Analyzer.h:1435
void do_cast(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:1194
std::string toString() const override
Definition: Analyzer.cpp:2533
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:1821
Constant(const SQLTypeInfo &ti, bool n, const std::list< std::shared_ptr< Analyzer::Expr >> &l)
Definition: Analyzer.h:328
const Expr * get_right_operand() const
Definition: Analyzer.h:539
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2495
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:819
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3140
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3022
void set_num_aggs(int a)
Definition: Analyzer.h:1804
void set_group_by(std::list< std::shared_ptr< Analyzer::Expr >> &g)
Definition: Analyzer.h:1798
WhichRow which_row
Definition: Analyzer.h:295
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1981
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3233
void add_tle(std::shared_ptr< TargetEntry > tle)
Definition: Analyzer.h:1808
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:1791
void set_next_query(Query *q)
Definition: Analyzer.h:1801
bool get_is_unionall() const
Definition: Analyzer.h:1791
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) final
Definition: Analyzer.cpp:3563
int get_result_table_id() const
Definition: Analyzer.h:1792
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:3349
size_t getElementCount() const
Definition: Analyzer.h:1648
int32_t getOutputSRID() const
Definition: Analyzer.h:1967
SQLStmtType
Definition: sqldefs.h:102
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:1000
const std::vector< std::shared_ptr< Analyzer::Expr > > tuple_
Definition: Analyzer.h:253
void set_having_predicate(std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:1799
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:3663
void set_result_table_id(int id)
Definition: Analyzer.h:1795
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:766
const std::vector< int64_t > value_list
Definition: Analyzer.h:690
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:387
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:728
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:3159
const Expr * get_pattern_expr() const
Definition: Analyzer.h:1025
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:709
#define CHECK_LT(x, y)
Definition: Logger.h:219
int64_t offset
Definition: Analyzer.h:1831
virtual std::string toString() const =0
WidthBucketExpr(const std::shared_ptr< Analyzer::Expr > target_value, const std::shared_ptr< Analyzer::Expr > lower_bound, const std::shared_ptr< Analyzer::Expr > upper_bound, const std::shared_ptr< Analyzer::Expr > partition_count)
Definition: Analyzer.h:1077
ExpressionPtrVector contained_expressions_
Definition: Analyzer.h:1664
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1955
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:805
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:1757
UOper(const SQLTypeInfo &ti, bool has_agg, SQLOps o, std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:363
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:138
const Expr * get_from_expr() const
Definition: Analyzer.h:1477
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3150
virtual ~Query()
Definition: Analyzer.cpp:52
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3040
DEVICE auto lower_bound(ARGS &&...args)
Definition: gpu_enabled.h:78
const Expr * get_datetime_expr() const
Definition: Analyzer.h:1394
void set_is_distinct(bool d)
Definition: Analyzer.h:1796
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:1589
int get_comp_param() const
Definition: Analyzer.h:197
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:337
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:232
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:192
bool isLocalAlloc() const
Definition: Analyzer.h:1649
std::string toString() const override
Definition: Analyzer.cpp:2845
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:866
const Expr * get_like_expr() const
Definition: Analyzer.h:953
std::vector< std::shared_ptr< TargetEntry > > & get_targetlist_nonconst()
Definition: Analyzer.h:1779
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:856
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:2984
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1835
const Analyzer::Expr * getArg(const size_t i) const
Definition: Analyzer.h:1517
RegexpExpr(std::shared_ptr< Analyzer::Expr > a, std::shared_ptr< Analyzer::Expr > p, std::shared_ptr< Analyzer::Expr > e)
Definition: Analyzer.h:1016
std::string toString() const override
Definition: Analyzer.cpp:2863
int get_rte_idx() const
Definition: Analyzer.h:195
const Expr * get_operand() const
Definition: Analyzer.h:370
Analyzer::ExpressionPtr deep_copy() const override
Definition: Analyzer.cpp:220
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:774
Datum get_constval() const
Definition: Analyzer.h:334
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3004
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2130
const Expr * get_arg() const
Definition: Analyzer.h:796
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) final
Definition: Analyzer.cpp:3649
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:1729
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1040
void set_is_unionall(bool u)
Definition: Analyzer.h:1802
SampleRatioExpr(std::shared_ptr< Analyzer::Expr > a)
Definition: Analyzer.h:794
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
Definition: Analyzer.cpp:1324
const Expr * get_arg() const
Definition: Analyzer.h:702
void set_resname(const std::string &name)
Definition: Analyzer.h:1739
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:849
const std::list< std::shared_ptr< Analyzer::Expr > > & get_value_list() const
Definition: Analyzer.h:632
int32_t get_partition_count_val() const
Definition: Analyzer.cpp:3430
std::string toString() const override
Definition: Analyzer.cpp:2854
std::vector< RangeTableEntry * > rangetable
Definition: Analyzer.h:1817
GeoOperator(const SQLTypeInfo &ti, const std::string &name, const std::vector< std::shared_ptr< Analyzer::Expr >> &args, const std::optional< int > &output_srid_override=std::nullopt)
Definition: Analyzer.cpp:3579
std::shared_ptr< Analyzer::Expr > from_expr_
Definition: Analyzer.h:1378
std::string toString() const override
Definition: Analyzer.cpp:2785
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2095
Expression class for the LOWER (lowercase) string function. The &quot;arg&quot; constructor parameter must be a...
Definition: Analyzer.h:837
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:1715
virtual std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:702
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:1439
void cast_number(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:839
ExtractField
virtual void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const
Definition: Analyzer.h:158
virtual std::shared_ptr< Analyzer::Expr > deep_copy() const =0
SqlWindowFunctionKind
Definition: sqldefs.h:83
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:961
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:829
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1105
size_t size() const
Definition: Analyzer.cpp:3640
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.cpp:64
SQLTypeInfo ti0_
Definition: Analyzer.h:1692
void set_where_predicate(std::shared_ptr< Analyzer::Expr > p)
Definition: Analyzer.h:1797
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:338
void set_stmt_type(SQLStmtType t)
Definition: Analyzer.h:1803
const Expr * get_having_predicate() const
Definition: Analyzer.h:1787
DateaddField get_field() const
Definition: Analyzer.h:1392
SQLAgg get_aggtype() const
Definition: Analyzer.h:1249
std::string toString() const override
Definition: Analyzer.cpp:2875
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:898
virtual std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
Definition: Analyzer.h:143
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:158
const Expr * get_target_value() const
Definition: Analyzer.h:1088
const std::shared_ptr< Analyzer::Expr > datetime_
Definition: Analyzer.h:1420
KeyForStringExpr(std::shared_ptr< Analyzer::Expr > a)
Definition: Analyzer.h:749
Constant(SQLTypes t, bool n)
Definition: Analyzer.h:307
const Expr * get_arg() const
Definition: Analyzer.h:751
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3130
std::shared_ptr< Expr > get_own_expr() const
Definition: Analyzer.h:1741
std::shared_ptr< Analyzer::Expr > arg
Definition: Analyzer.h:930
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1914
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3106
virtual std::shared_ptr< Analyzer::Expr > normalize_simple_predicate(int &rte_idx) const
Definition: Analyzer.h:93
bool g_enable_watchdog false
Definition: Execute.cpp:76
void set_notnull(bool n)
Definition: sqltypes.h:426
virtual void group_predicates(std::list< const Expr * > &scan_predicates, std::list< const Expr * > &join_predicates, std::list< const Expr * > &const_predicates) const
Definition: Analyzer.h:101
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:1096
const Expr * get_end_expr() const
Definition: Analyzer.h:1436
#define CHECK(condition)
Definition: Logger.h:209
SQLStmtType get_stmt_type() const
Definition: Analyzer.h:1790
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:940
Geospatial::GeoBase::GeoOp getOp() const
Definition: Analyzer.h:1686
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2278
bool can_skip_out_of_bound_check() const
Definition: Analyzer.h:1163
char * t
ExtractField field_
Definition: Analyzer.h:1377
GeoColumnVar(const Analyzer::ColumnVar *column_var, const bool with_bounds, const bool with_render_group)
Definition: Analyzer.h:1860
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2061
BinOper(SQLTypes t, SQLOps o, SQLQualifier q, std::shared_ptr< Analyzer::Expr > l, std::shared_ptr< Analyzer::Expr > r)
Definition: Analyzer.h:428
bool is_desc
Definition: Analyzer.h:1579
std::string toString() const override
Definition: Analyzer.cpp:2737
std::shared_ptr< Analyzer::Expr > add_cast(const SQLTypeInfo &new_type_info) override
Definition: Analyzer.cpp:1395
std::shared_ptr< Analyzer::Expr > having_predicate
Definition: Analyzer.h:1822
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:752
Expr(SQLTypes t, int d, bool notnull)
Definition: Analyzer.h:69
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2248
void cast_to_string(const SQLTypeInfo &new_type_info)
Definition: Analyzer.cpp:1133
int64_t inline_int_null_val(const SQL_TYPE_INFO &ti)
int32_t compute_bucket(T target_const_val, SQLTypeInfo &ti) const
Definition: Analyzer.h:1129
virtual void collect_rte_idx(std::set< int > &rte_idx_set) const
Definition: Analyzer.h:108
const std::list< std::shared_ptr< Analyzer::Expr > > & get_group_by() const
Definition: Analyzer.h:1784
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:130
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:588
std::vector< ExpressionPtr > ExpressionPtrVector
Definition: Analyzer.h:181
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:1548
std::shared_ptr< Analyzer::Expr > left_operand_
Definition: Analyzer.h:562
std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:1251
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:815
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:122
std::string toString() const override
Definition: Analyzer.cpp:3672
char * f
Analyzer::Expr * getOperand(const size_t index) const
Definition: Analyzer.cpp:3644
bool operator==(const Expr &) const final
Definition: Analyzer.cpp:3510
DateaddExpr(const SQLTypeInfo &ti, const DateaddField f, const std::shared_ptr< Analyzer::Expr > number, const std::shared_ptr< Analyzer::Expr > datetime)
Definition: Analyzer.h:1387
std::shared_ptr< Analyzer::Expr > escape_expr
Definition: Analyzer.h:1003
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:1617
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:986
const Expr * get_left_operand() const
Definition: Analyzer.h:441
bool is_overlaps_oper() const
Definition: Analyzer.h:439
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:206
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:100
CharLengthExpr(std::shared_ptr< Analyzer::Expr > a, bool e)
Definition: Analyzer.h:700
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3213
ExpressionTuple(const std::vector< std::shared_ptr< Analyzer::Expr >> &tuple)
Definition: Analyzer.h:240
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3087
Common Enum definitions for SQL processing.
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:1197
Definition: sqltypes.h:45
void skip_out_of_bound_check() const
Definition: Analyzer.h:1164
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2024
const SqlWindowFunctionKind kind_
Definition: Analyzer.h:1622
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:1416
std::shared_ptr< Analyzer::Constant > makePhysicalConstant(const size_t index) const
Definition: Analyzer.cpp:3532
const std::shared_ptr< Analyzer::Expr > get_own_arg() const
Definition: Analyzer.h:952
const Expr * get_lower_bound() const
Definition: Analyzer.h:1089
int get_column_id() const
Definition: Analyzer.h:194
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:397
std::string toString() const override
Definition: Analyzer.cpp:2649
const std::shared_ptr< Analyzer::Expr > get_own_right_operand() const
Definition: Analyzer.h:446
Constant(SQLTypes t, bool n, Datum v)
Definition: Analyzer.h:314
std::string getName() const
Definition: Analyzer.h:1513
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:1263
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const final
Definition: Analyzer.cpp:3603
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2436
void print() const
Definition: Analyzer.h:1577
const Expr * get_arg() const
Definition: Analyzer.h:679
std::shared_ptr< Analyzer::Expr > where_predicate
Definition: Analyzer.h:1820
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1212
constexpr double n
Definition: Utm.h:46
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.h:760
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.h:1203
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2180
Definition: Analyzer.h:1573
void set_limit(int64_t l)
Definition: Analyzer.h:1810
std::string getWKTString() const
Definition: Analyzer.cpp:3505
std::string toString() const override
Definition: Analyzer.cpp:2741
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:1806
std::string toString() const override
Definition: Analyzer.cpp:3612
const Expr * get_upper_bound() const
Definition: Analyzer.h:1090
const std::list< int > & get_result_col_list() const
Definition: Analyzer.h:1793
const std::vector< std::shared_ptr< Analyzer::Expr > > & getPartitionKeys() const
Definition: Analyzer.h:1611
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:150
int64_t limit
Definition: Analyzer.h:1830
bool operator==(const Expr &) const override
Definition: Analyzer.cpp:3621
bool contains_agg
Definition: Analyzer.h:176
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:639
const Expr * get_arg() const
Definition: Analyzer.h:897
DatetruncField get_field() const
Definition: Analyzer.h:1434
const std::vector< std::shared_ptr< TargetEntry > > & get_targetlist() const
Definition: Analyzer.h:1776
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3013
std::list< OrderEntry > * order_by
Definition: Analyzer.h:1823
size_t physicalCols() const
Definition: Analyzer.cpp:3527
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:85
std::shared_ptr< Analyzer::Expr > pattern_expr
Definition: Analyzer.h:1066
Geospatial::GeoBase::GeoOp getOp() const
Definition: Analyzer.h:1715
const std::vector< std::shared_ptr< Analyzer::Expr > > args_
Definition: Analyzer.h:1944
AggExpr(const SQLTypeInfo &ti, SQLAgg a, std::shared_ptr< Analyzer::Expr > g, bool d, std::shared_ptr< Analyzer::Constant > e)
Definition: Analyzer.h:1232
const std::vector< RangeTableEntry * > & get_rangetable() const
Definition: Analyzer.h:1782
std::string toString() const override
Definition: Analyzer.cpp:2828
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3279
std::shared_ptr< Analyzer::Expr > else_expr
Definition: Analyzer.h:1337
const Expr * get_arg() const
Definition: Analyzer.h:630
const std::shared_ptr< Analyzer::Expr > get_own_left_operand() const
Definition: Analyzer.h:443
virtual std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const
Definition: Analyzer.h:133
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:175
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:236
SQLOps get_optype() const
Definition: Analyzer.h:369
const std::vector< std::shared_ptr< Analyzer::Expr > > & getArgs1() const
Definition: Analyzer.h:1719
const std::list< std::pair< std::shared_ptr< Analyzer::Expr >, std::shared_ptr< Analyzer::Expr > > > & get_expr_pair_list() const
Definition: Analyzer.h:1304
FunctionOper(const SQLTypeInfo &ti, const std::string &name, const std::vector< std::shared_ptr< Analyzer::Expr >> &args)
Definition: Analyzer.h:1508
const Expr * get_arg() const
Definition: Analyzer.h:841
void collect_column_var(std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
Definition: Analyzer.cpp:3219
std::shared_ptr< Analyzer::Expr > target_value_
Definition: Analyzer.h:1169
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:757
void check_group_by(const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
Definition: Analyzer.cpp:3257
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2018
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:201
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2297
bool operator==(const Expr &rhs) const override
Definition: Analyzer.cpp:2483
const std::string name_
Definition: Analyzer.h:1943
std::shared_ptr< Analyzer::Expr > rewrite_agg_to_var(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1873
CardinalityExpr(std::shared_ptr< Analyzer::Expr > a)
Definition: Analyzer.h:895
SQLOps optype
Definition: Analyzer.h:409
const Expr * get_number_expr() const
Definition: Analyzer.h:1393
const std::string name_
Definition: Analyzer.h:1538
bool get_is_ilike() const
Definition: Analyzer.h:955
LowerExpr(std::shared_ptr< Analyzer::Expr > arg)
Definition: Analyzer.h:839
const Analyzer::Expr * getElement(const size_t i) const
Definition: Analyzer.h:1652
SQLQualifier get_qualifier() const
Definition: Analyzer.h:440
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1996
void find_expr(bool(*f)(const Expr *), std::list< const Expr * > &expr_list) const override
Definition: Analyzer.cpp:3075
std::shared_ptr< Analyzer::Expr > rewrite_with_child_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:1849
GeoExpr(const SQLTypeInfo &ti)
Definition: Analyzer.h:1836
void collect_rte_idx(std::set< int > &rte_idx_set) const override
Definition: Analyzer.h:1031
std::shared_ptr< Analyzer::Expr > rewrite_with_targetlist(const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
Definition: Analyzer.cpp:2002