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