OmniSciDB  c07336695a
Analyzer::Var Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::Var:
+ Collaboration diagram for Analyzer::Var:

Public Types

enum  WhichRow { kINPUT_OUTER, kINPUT_INNER, kOUTPUT, kGROUPBY }
 

Public Member Functions

 Var (const SQLTypeInfo &ti, int r, int c, int i, WhichRow o, int v)
 
 Var (const SQLTypeInfo &ti, WhichRow o, int v)
 
WhichRow get_which_row () const
 
void set_which_row (WhichRow r)
 
int get_varno () const
 
void set_varno (int n)
 
std::shared_ptr< Analyzer::Exprdeep_copy () const override
 
std::string toString () const override
 
void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
 
void collect_rte_idx (std::set< int > &rte_idx_set) const override
 
std::shared_ptr< Analyzer::Exprrewrite_with_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprrewrite_with_child_targetlist (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
std::shared_ptr< Analyzer::Exprrewrite_agg_to_var (const std::vector< std::shared_ptr< TargetEntry >> &tlist) const override
 
- Public Member Functions inherited from Analyzer::ColumnVar
 ColumnVar (const SQLTypeInfo &ti, int r, int c, int i)
 
int get_table_id () const
 
int get_column_id () const
 
int get_rte_idx () const
 
EncodingType get_compression () const
 
int get_comp_param () const
 
void group_predicates (std::list< const Expr *> &scan_predicates, std::list< const Expr *> &join_predicates, std::list< const Expr *> &const_predicates) const override
 
void collect_column_var (std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) const override
 
bool operator== (const Expr &rhs) const override
 
- Public Member Functions inherited from Analyzer::Expr
 Expr (SQLTypes t, bool notnull)
 
 Expr (SQLTypes t, int d, bool notnull)
 
 Expr (SQLTypes t, int d, int s, bool notnull)
 
 Expr (const SQLTypeInfo &ti, bool has_agg=false)
 
virtual ~Expr ()
 
const SQLTypeInfoget_type_info () const
 
void set_type_info (const SQLTypeInfo &ti)
 
bool get_contains_agg () const
 
void set_contains_agg (bool a)
 
virtual std::shared_ptr< Analyzer::Expradd_cast (const SQLTypeInfo &new_type_info)
 
virtual std::shared_ptr< Analyzer::Exprnormalize_simple_predicate (int &rte_idx) const
 
virtual void print () const
 
virtual void add_unique (std::list< const Expr *> &expr_list) const
 
virtual void find_expr (bool(*f)(const Expr *), std::list< const Expr *> &expr_list) const
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Private Attributes

WhichRow which_row
 
int varno
 

Additional Inherited Members

- Static Public Member Functions inherited from Analyzer::ColumnVar
static bool colvar_comp (const ColumnVar *l, const ColumnVar *r)
 
- Protected Attributes inherited from Analyzer::ColumnVar
int table_id
 
int column_id
 
int rte_idx
 
- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 265 of file Analyzer.h.

Member Enumeration Documentation

◆ WhichRow

Enumerator
kINPUT_OUTER 
kINPUT_INNER 
kOUTPUT 
kGROUPBY 

Definition at line 267 of file Analyzer.h.

Constructor & Destructor Documentation

◆ Var() [1/2]

Analyzer::Var::Var ( const SQLTypeInfo ti,
int  r,
int  c,
int  i,
WhichRow  o,
int  v 
)
inline

Definition at line 268 of file Analyzer.h.

269  : ColumnVar(ti, r, c, i), which_row(o), varno(v) {}
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:191
void c(const std::string &query_string, const ExecutorDeviceType device_type)
T v(const TargetValue &r)
WhichRow which_row
Definition: Analyzer.h:295

◆ Var() [2/2]

Analyzer::Var::Var ( const SQLTypeInfo ti,
WhichRow  o,
int  v 
)
inline

Definition at line 270 of file Analyzer.h.

271  : ColumnVar(ti, 0, 0, -1), which_row(o), varno(v) {}
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:191
T v(const TargetValue &r)
WhichRow which_row
Definition: Analyzer.h:295

Member Function Documentation

◆ check_group_by()

void Analyzer::Var::check_group_by ( const std::list< std::shared_ptr< Analyzer::Expr >> &  groupby) const
overridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 1286 of file Analyzer.cpp.

1287  {
1288  if (which_row != kGROUPBY) {
1289  throw std::runtime_error("Internal error: invalid VAR in GROUP BY or HAVING.");
1290  }
1291 }
WhichRow which_row
Definition: Analyzer.h:295

◆ collect_rte_idx()

void Analyzer::Var::collect_rte_idx ( std::set< int > &  rte_idx_set) const
inlineoverridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 280 of file Analyzer.h.

280  {
281  rte_idx_set.insert(-1);
282  }

◆ deep_copy()

std::shared_ptr< Analyzer::Expr > Analyzer::Var::deep_copy ( ) const
overridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 80 of file Analyzer.cpp.

References Analyzer::Expr::type_info.

Referenced by Parser::ColumnRef::analyze(), and DeepCopyVisitor::visitVar().

80  {
81  return makeExpr<Var>(type_info, table_id, column_id, rte_idx, which_row, varno);
82 }
SQLTypeInfo type_info
Definition: Analyzer.h:175
WhichRow which_row
Definition: Analyzer.h:295
+ Here is the caller graph for this function:

◆ get_varno()

int Analyzer::Var::get_varno ( ) const
inline

Definition at line 274 of file Analyzer.h.

Referenced by Parser::QuerySpec::analyze_group_by(), Analyzer::ColumnVar::operator==(), and anonymous_namespace{QueryMemoryDescriptor.cpp}::target_expr_group_by_indices().

274 { return varno; }
+ Here is the caller graph for this function:

◆ get_which_row()

WhichRow Analyzer::Var::get_which_row ( ) const
inline

Definition at line 272 of file Analyzer.h.

Referenced by Parser::ColumnRef::analyze(), and Analyzer::ColumnVar::operator==().

272 { return which_row; }
WhichRow which_row
Definition: Analyzer.h:295
+ Here is the caller graph for this function:

◆ rewrite_agg_to_var()

std::shared_ptr< Analyzer::Expr > Analyzer::Var::rewrite_agg_to_var ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 1712 of file Analyzer.cpp.

References Analyzer::Expr::get_type_info(), and kINPUT_OUTER.

1713  {
1714  int varno = 1;
1715  for (auto tle : tlist) {
1716  const Expr* e = tle->get_expr();
1717  if (*e == *this) {
1718  return makeExpr<Var>(e->get_type_info(), Var::kINPUT_OUTER, varno);
1719  }
1720  varno++;
1721  }
1722  throw std::runtime_error(
1723  "Internal error: cannot find Var from having clause in targetlist.");
1724 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
+ Here is the call graph for this function:

◆ rewrite_with_child_targetlist()

std::shared_ptr<Analyzer::Expr> Analyzer::Var::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 287 of file Analyzer.h.

288  {
289  return deep_copy();
290  }
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:80

◆ rewrite_with_targetlist()

std::shared_ptr<Analyzer::Expr> Analyzer::Var::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
inlineoverridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 283 of file Analyzer.h.

284  {
285  return deep_copy();
286  }
std::shared_ptr< Analyzer::Expr > deep_copy() const override
Definition: Analyzer.cpp:80

◆ set_varno()

void Analyzer::Var::set_varno ( int  n)
inline

Definition at line 275 of file Analyzer.h.

275 { varno = n; }

◆ set_which_row()

void Analyzer::Var::set_which_row ( WhichRow  r)
inline

Definition at line 273 of file Analyzer.h.

273 { which_row = r; }
WhichRow which_row
Definition: Analyzer.h:295

◆ toString()

std::string Analyzer::Var::toString ( ) const
overridevirtual

Reimplemented from Analyzer::ColumnVar.

Definition at line 2255 of file Analyzer.cpp.

References to_string().

2255  {
2256  return "(Var table: " + std::to_string(table_id) +
2257  " column: " + std::to_string(column_id) + " rte: " + std::to_string(rte_idx) +
2258  " which_row: " + std::to_string(which_row) + " varno: " + std::to_string(varno) +
2259  ") ";
2260 }
std::string to_string(char const *&&v)
WhichRow which_row
Definition: Analyzer.h:295
+ Here is the call graph for this function:

Member Data Documentation

◆ varno

int Analyzer::Var::varno
private

Definition at line 298 of file Analyzer.h.

◆ which_row

WhichRow Analyzer::Var::which_row
private

Definition at line 295 of file Analyzer.h.


The documentation for this class was generated from the following files: