OmniSciDB  c07336695a
Analyzer::ColumnVar Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::ColumnVar:
+ Collaboration diagram for Analyzer::ColumnVar:

Public Member Functions

 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 check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) const override
 
std::shared_ptr< Analyzer::Exprdeep_copy () const override
 
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_rte_idx (std::set< int > &rte_idx_set) const override
 
void collect_column_var (std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &colvar_set, bool include_agg) 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
 
bool operator== (const Expr &rhs) const override
 
std::string toString () 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
 

Static Public Member Functions

static bool colvar_comp (const ColumnVar *l, const ColumnVar *r)
 

Protected Attributes

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 189 of file Analyzer.h.

Constructor & Destructor Documentation

◆ ColumnVar()

Analyzer::ColumnVar::ColumnVar ( const SQLTypeInfo ti,
int  r,
int  c,
int  i 
)
inline

Definition at line 191 of file Analyzer.h.

192  : Expr(ti), table_id(r), column_id(c), rte_idx(i) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
void c(const std::string &query_string, const ExecutorDeviceType device_type)

Member Function Documentation

◆ check_group_by()

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

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 1270 of file Analyzer.cpp.

References anonymous_namespace{ExecuteTest.cpp}::c().

1271  {
1272  if (!groupby.empty()) {
1273  for (auto e : groupby) {
1274  auto c = std::dynamic_pointer_cast<ColumnVar>(e);
1275  if (c && table_id == c->get_table_id() && column_id == c->get_column_id()) {
1276  return;
1277  }
1278  }
1279  }
1280  throw std::runtime_error(
1281  "expressions in the SELECT or HAVING clause must be an aggregate function or an "
1282  "expression "
1283  "over GROUP BY columns.");
1284 }
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)
+ Here is the call graph for this function:

◆ collect_column_var()

void Analyzer::ColumnVar::collect_column_var ( std::set< const ColumnVar *, bool(*)(const ColumnVar *, const ColumnVar *)> &  colvar_set,
bool  include_agg 
) const
inlineoverridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 212 of file Analyzer.h.

References operator==().

Referenced by Planner::Optimizer::optimize_scans().

215  {
216  colvar_set.insert(this);
217  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ collect_rte_idx()

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

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 204 of file Analyzer.h.

204  {
205  rte_idx_set.insert(rte_idx);
206  }

◆ colvar_comp()

static bool Analyzer::ColumnVar::colvar_comp ( const ColumnVar l,
const ColumnVar r 
)
inlinestatic

Definition at line 207 of file Analyzer.h.

References get_column_id(), and get_table_id().

Referenced by Planner::Optimizer::optimize_aggs(), and Planner::Optimizer::optimize_scans().

207  {
208  return l->get_table_id() < r->get_table_id() ||
209  (l->get_table_id() == r->get_table_id() &&
210  l->get_column_id() < r->get_column_id());
211  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deep_copy()

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

Implements Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 59 of file Analyzer.cpp.

References Analyzer::Expr::type_info.

Referenced by rewrite_with_targetlist(), DeepCopyVisitor::visitColumnVar(), and anonymous_namespace{ScalarCodeGenerator.cpp}::UsedColumnExpressions::visitColumnVar().

59  {
60  return makeExpr<ColumnVar>(type_info, table_id, column_id, rte_idx);
61 }
SQLTypeInfo type_info
Definition: Analyzer.h:175
+ Here is the caller graph for this function:

◆ get_column_id()

◆ get_comp_param()

int Analyzer::ColumnVar::get_comp_param ( ) const
inline

Definition at line 197 of file Analyzer.h.

Referenced by anonymous_namespace{ColumnIR.cpp}::get_col_decoder().

197 { return type_info.get_comp_param(); }
SQLTypeInfo type_info
Definition: Analyzer.h:175
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:328
+ Here is the caller graph for this function:

◆ get_compression()

EncodingType Analyzer::ColumnVar::get_compression ( ) const
inline

Definition at line 196 of file Analyzer.h.

Referenced by anonymous_namespace{ColumnIR.cpp}::get_col_decoder().

196 { return type_info.get_compression(); }
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:327
SQLTypeInfo type_info
Definition: Analyzer.h:175
+ Here is the caller graph for this function:

◆ get_rte_idx()

◆ get_table_id()

◆ group_predicates()

void Analyzer::ColumnVar::group_predicates ( std::list< const Expr *> &  scan_predicates,
std::list< const Expr *> &  join_predicates,
std::list< const Expr *> &  const_predicates 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 1380 of file Analyzer.cpp.

References SQLTypeInfoCore< TYPE_FACET_PACK >::get_type(), kBOOLEAN, and Analyzer::Expr::type_info.

1382  {
1383  if (type_info.get_type() == kBOOLEAN) {
1384  scan_predicates.push_back(this);
1385  }
1386 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:319
SQLTypeInfo type_info
Definition: Analyzer.h:175
+ Here is the call graph for this function:

◆ operator==()

bool Analyzer::ColumnVar::operator== ( const Expr rhs) const
overridevirtual

Implements Analyzer::Expr.

Definition at line 1921 of file Analyzer.cpp.

References get_column_id(), get_rte_idx(), get_table_id(), Analyzer::Var::get_varno(), Analyzer::Var::get_which_row(), and v().

1921  {
1922  if (typeid(rhs) != typeid(ColumnVar) && typeid(rhs) != typeid(Var)) {
1923  return false;
1924  }
1925  const ColumnVar& rhs_cv = dynamic_cast<const ColumnVar&>(rhs);
1926  if (rte_idx != -1) {
1927  return (table_id == rhs_cv.get_table_id()) && (column_id == rhs_cv.get_column_id()) &&
1928  (rte_idx == rhs_cv.get_rte_idx());
1929  }
1930  const Var* v = dynamic_cast<const Var*>(this);
1931  if (v == nullptr) {
1932  return false;
1933  }
1934  const Var* rv = dynamic_cast<const Var*>(&rhs);
1935  if (rv == nullptr) {
1936  return false;
1937  }
1938  return (v->get_which_row() == rv->get_which_row()) &&
1939  (v->get_varno() == rv->get_varno());
1940 }
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:191
T v(const TargetValue &r)
+ Here is the call graph for this function:

◆ rewrite_agg_to_var()

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

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 1685 of file Analyzer.cpp.

References get_column_id(), get_rte_idx(), get_table_id(), Analyzer::Expr::get_type_info(), and Analyzer::Var::kINPUT_OUTER.

1686  {
1687  int varno = 1;
1688  for (auto tle : tlist) {
1689  const Expr* e = tle->get_expr();
1690  if (typeid(*e) != typeid(AggExpr)) {
1691  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1692  if (colvar == nullptr) {
1693  throw std::runtime_error(
1694  "Internal Error: targetlist in rewrite_agg_to_var is not all columns and "
1695  "aggregates.");
1696  }
1697  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1698  return makeExpr<Var>(colvar->get_type_info(),
1699  colvar->get_table_id(),
1700  colvar->get_column_id(),
1701  colvar->get_rte_idx(),
1703  varno);
1704  }
1705  }
1706  varno++;
1707  }
1708  throw std::runtime_error(
1709  "Internal error: cannot find ColumnVar from having clause in targetlist.");
1710 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:191
+ Here is the call graph for this function:

◆ rewrite_with_child_targetlist()

std::shared_ptr< Analyzer::Expr > Analyzer::ColumnVar::rewrite_with_child_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 1661 of file Analyzer.cpp.

References get_column_id(), get_rte_idx(), get_table_id(), Analyzer::Expr::get_type_info(), and Analyzer::Var::kINPUT_OUTER.

1662  {
1663  int varno = 1;
1664  for (auto tle : tlist) {
1665  const Expr* e = tle->get_expr();
1666  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1667  if (colvar == nullptr) {
1668  throw std::runtime_error(
1669  "Internal Error: targetlist in rewrite_with_child_targetlist is not all "
1670  "columns.");
1671  }
1672  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1673  return makeExpr<Var>(colvar->get_type_info(),
1674  colvar->get_table_id(),
1675  colvar->get_column_id(),
1676  colvar->get_rte_idx(),
1678  varno);
1679  }
1680  varno++;
1681  }
1682  throw std::runtime_error("Internal error: cannot find ColumnVar in child targetlist.");
1683 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:191
+ Here is the call graph for this function:

◆ rewrite_with_targetlist()

std::shared_ptr< Analyzer::Expr > Analyzer::ColumnVar::rewrite_with_targetlist ( const std::vector< std::shared_ptr< TargetEntry >> &  tlist) const
overridevirtual

Reimplemented from Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 1647 of file Analyzer.cpp.

References deep_copy(), get_column_id(), and get_table_id().

1648  {
1649  for (auto tle : tlist) {
1650  const Expr* e = tle->get_expr();
1651  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1652  if (colvar != nullptr) {
1653  if (table_id == colvar->get_table_id() && column_id == colvar->get_column_id()) {
1654  return colvar->deep_copy();
1655  }
1656  }
1657  }
1658  throw std::runtime_error("Internal error: cannot find ColumnVar in targetlist.");
1659 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
ColumnVar(const SQLTypeInfo &ti, int r, int c, int i)
Definition: Analyzer.h:191
+ Here is the call graph for this function:

◆ toString()

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

Implements Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 2240 of file Analyzer.cpp.

References Analyzer::Expr::get_type_info(), SQLTypeInfoCore< TYPE_FACET_PACK >::get_type_name(), and to_string().

2240  {
2241  return "(ColumnVar table: " + std::to_string(table_id) +
2242  " column: " + std::to_string(column_id) + " rte: " + std::to_string(rte_idx) +
2243  " " + get_type_info().get_type_name() + ") ";
2244 }
std::string to_string(char const *&&v)
std::string get_type_name() const
Definition: sqltypes.h:422
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:77
+ Here is the call graph for this function:

Member Data Documentation

◆ column_id

int Analyzer::ColumnVar::column_id
protected

Definition at line 229 of file Analyzer.h.

◆ rte_idx

int Analyzer::ColumnVar::rte_idx
protected

Definition at line 230 of file Analyzer.h.

◆ table_id

int Analyzer::ColumnVar::table_id
protected

Definition at line 228 of file Analyzer.h.


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