OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Analyzer::ColumnVar Class Reference

#include <Analyzer.h>

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

Public Member Functions

 ColumnVar (const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
 
const shared::ColumnKeygetColumnKey () const
 
shared::TableKey getTableKey () const
 
int32_t get_rte_idx () const
 
void set_rte_idx (int32_t new_rte_idx)
 
EncodingType get_compression () 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< int32_t > &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 ()
 
std::shared_ptr< Analyzer::Exprget_shared_ptr ()
 
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::Expr
add_cast (const SQLTypeInfo &new_type_info)
 
virtual std::shared_ptr
< Analyzer::Expr
normalize_simple_predicate (int &rte_idx) const
 
virtual void collect_rte_idx (std::set< int > &rte_idx_set) const
 
virtual size_t get_num_column_vars (const bool include_agg) const
 
virtual void print () const
 
virtual void add_unique (std::list< const Expr * > &expr_list) const
 
virtual void find_expr (std::function< bool(const Expr *)> f, 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

shared::ColumnKey column_key_
 
int32_t rte_idx_
 
- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 194 of file Analyzer.h.

Constructor & Destructor Documentation

Analyzer::ColumnVar::ColumnVar ( const SQLTypeInfo ti,
const shared::ColumnKey column_key,
int32_t  rte_idx 
)
inline

Definition at line 196 of file Analyzer.h.

197  : Expr(ti), column_key_(column_key), rte_idx_(rte_idx) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
shared::ColumnKey column_key_
Definition: Analyzer.h:239

Member Function Documentation

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 1510 of file Analyzer.cpp.

References column_key_.

1511  {
1512  if (!groupby.empty()) {
1513  for (auto e : groupby) {
1514  auto c = std::dynamic_pointer_cast<ColumnVar>(e);
1515  if (c && column_key_ == c->getColumnKey()) {
1516  return;
1517  }
1518  }
1519  }
1520  throw std::runtime_error(
1521  "expressions in the SELECT or HAVING clause must be an aggregate function or an "
1522  "expression "
1523  "over GROUP BY columns.");
1524 }
shared::ColumnKey column_key_
Definition: Analyzer.h:239
ColumnVar(const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
Definition: Analyzer.h:196
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 222 of file Analyzer.h.

Referenced by anonymous_namespace{GroupByAndAggregate.cpp}::init_count_distinct_descriptors(), and RelAlgTranslator::translateWindowFunction().

225  {
226  colvar_set.insert(this);
227  }

+ Here is the caller graph for this function:

void Analyzer::ColumnVar::collect_rte_idx ( std::set< int32_t > &  rte_idx_set) const
inlineoverride

Definition at line 212 of file Analyzer.h.

References rte_idx_.

212  {
213  rte_idx_set.insert(rte_idx_);
214  }
static bool Analyzer::ColumnVar::colvar_comp ( const ColumnVar l,
const ColumnVar r 
)
inlinestatic

Definition at line 215 of file Analyzer.h.

References CHECK, and column_key_.

Referenced by Analyzer::Expr::get_num_column_vars(), Analyzer::StringOper::hasSingleDictEncodedColInput(), anonymous_namespace{GroupByAndAggregate.cpp}::init_count_distinct_descriptors(), anonymous_namespace{GeoIR.cpp}::mark_logical_column_to_fetch(), RelAlgTranslator::translateWindowFunction(), and anonymous_namespace{FromTableReordering.cpp}::traverse_join_cost_graph().

215  {
216  CHECK(l);
217  const auto& l_column_key = l->column_key_;
218  CHECK(r);
219  const auto& r_column_key = r->column_key_;
220  return l_column_key < r_column_key;
221  }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

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

Implements Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 66 of file Analyzer.cpp.

References column_key_, rte_idx_, and Analyzer::Expr::type_info.

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

66  {
67  return makeExpr<ColumnVar>(type_info, column_key_, rte_idx_);
68 }
shared::ColumnKey column_key_
Definition: Analyzer.h:239
SQLTypeInfo type_info
Definition: Analyzer.h:180

+ Here is the caller graph for this function:

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

Definition at line 204 of file Analyzer.h.

References SQLTypeInfo::get_compression(), and Analyzer::Expr::type_info.

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

204 { return type_info.get_compression(); }
SQLTypeInfo type_info
Definition: Analyzer.h:180
HOST DEVICE EncodingType get_compression() const
Definition: sqltypes.h:399

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const shared::ColumnKey& Analyzer::ColumnVar::getColumnKey ( ) const
inline

Definition at line 198 of file Analyzer.h.

References column_key_.

Referenced by Parser::QuerySpec::analyze_select_clause(), apply_simple_quals(), Executor::canSkipFragmentForFpQual(), CodeGenerator::codegenColVar(), CodeGenerator::codegenGeoColumnVar(), PerfectJoinHashTable::genChunkKey(), Executor::getColumnDescriptor(), getExpressionRange(), getLeafColumnRange(), PlanState::getLocalColumnId(), ColumnFetcher::getOneColumnFragment(), Executor::getPhysicalColumnDescriptor(), anonymous_namespace{ArithmeticIR.cpp}::is_temporary_column(), PlanState::isLazyFetchColumn(), anonymous_namespace{ExecutionKernel.cpp}::need_to_hold_chunk(), operator==(), CodeGenerator::resolveGroupedColumnReference(), rewrite_agg_to_var(), rewrite_with_child_targetlist(), rewrite_with_targetlist(), GroupByAndAggregate::shard_count_for_top_groups(), translate_bounding_box_intersect_with_reordering(), QueryPlanDagCache::translateColVarsToInfoHash(), anonymous_namespace{JoinFilterPushDown.cpp}::BindFilterToOutermostVisitor::visitColumnVar(), anonymous_namespace{ScalarCodeGenerator.cpp}::UsedColumnExpressions::visitColumnVar(), UsedColumnsVisitor::visitColumnVar(), ScalarExprToSql::visitColumnVar(), and anonymous_namespace{JoinFilterPushDown.cpp}::CollectInputColumnsVisitor::visitColumnVar().

198 { return column_key_; }
shared::ColumnKey column_key_
Definition: Analyzer.h:239

+ Here is the caller graph for this function:

shared::TableKey Analyzer::ColumnVar::getTableKey ( ) const
inline

Definition at line 199 of file Analyzer.h.

References column_key_, shared::ColumnKey::db_id, and shared::ColumnKey::table_id.

Referenced by CodeGenerator::codegenRowId(), PerfectJoinHashTable::getInnerQueryInfo(), getLeafColumnRange(), and self_join_not_covered_by_left_deep_tree().

199  {
201  }
shared::ColumnKey column_key_
Definition: Analyzer.h:239

+ Here is the caller graph for this function:

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 1620 of file Analyzer.cpp.

References SQLTypeInfo::get_type(), kBOOLEAN, and Analyzer::Expr::type_info.

1622  {
1623  if (type_info.get_type() == kBOOLEAN) {
1624  scan_predicates.push_back(this);
1625  }
1626 }
HOST DEVICE SQLTypes get_type() const
Definition: sqltypes.h:391
SQLTypeInfo type_info
Definition: Analyzer.h:180

+ Here is the call graph for this function:

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

Implements Analyzer::Expr.

Definition at line 2262 of file Analyzer.cpp.

References column_key_, get_rte_idx(), Analyzer::Var::get_varno(), Analyzer::Var::get_which_row(), getColumnKey(), and rte_idx_.

2262  {
2263  if (typeid(rhs) != typeid(ColumnVar) && typeid(rhs) != typeid(Var)) {
2264  return false;
2265  }
2266  const ColumnVar& rhs_cv = dynamic_cast<const ColumnVar&>(rhs);
2267  if (rte_idx_ != -1) {
2268  return (column_key_ == rhs_cv.getColumnKey()) && (rte_idx_ == rhs_cv.get_rte_idx());
2269  }
2270  const Var* v = dynamic_cast<const Var*>(this);
2271  if (v == nullptr) {
2272  return false;
2273  }
2274  const Var* rv = dynamic_cast<const Var*>(&rhs);
2275  if (rv == nullptr) {
2276  return false;
2277  }
2278  return (v->get_which_row() == rv->get_which_row()) &&
2279  (v->get_varno() == rv->get_varno());
2280 }
shared::ColumnKey column_key_
Definition: Analyzer.h:239
ColumnVar(const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
Definition: Analyzer.h:196

+ Here is the call graph for this function:

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 2000 of file Analyzer.cpp.

References column_key_, get_rte_idx(), Analyzer::Expr::get_type_info(), getColumnKey(), and Analyzer::Var::kINPUT_OUTER.

2001  {
2002  int varno = 1;
2003  for (auto tle : tlist) {
2004  const Expr* e = tle->get_expr();
2005  if (typeid(*e) != typeid(AggExpr)) {
2006  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
2007  if (colvar == nullptr) {
2008  throw std::runtime_error(
2009  "Internal Error: targetlist in rewrite_agg_to_var is not all columns and "
2010  "aggregates.");
2011  }
2012  if (column_key_ == colvar->getColumnKey()) {
2013  return makeExpr<Var>(colvar->get_type_info(),
2014  colvar->getColumnKey(),
2015  colvar->get_rte_idx(),
2017  varno);
2018  }
2019  }
2020  varno++;
2021  }
2022  throw std::runtime_error(
2023  "Internal error: cannot find ColumnVar from having clause in targetlist.");
2024 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
shared::ColumnKey column_key_
Definition: Analyzer.h:239
ColumnVar(const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
Definition: Analyzer.h:196

+ Here is the call graph for this function:

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 1977 of file Analyzer.cpp.

References column_key_, get_rte_idx(), Analyzer::Expr::get_type_info(), getColumnKey(), and Analyzer::Var::kINPUT_OUTER.

1978  {
1979  int varno = 1;
1980  for (auto tle : tlist) {
1981  const Expr* e = tle->get_expr();
1982  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1983  if (colvar == nullptr) {
1984  throw std::runtime_error(
1985  "Internal Error: targetlist in rewrite_with_child_targetlist is not all "
1986  "columns.");
1987  }
1988  if (column_key_ == colvar->getColumnKey()) {
1989  return makeExpr<Var>(colvar->get_type_info(),
1990  colvar->getColumnKey(),
1991  colvar->get_rte_idx(),
1993  varno);
1994  }
1995  varno++;
1996  }
1997  throw std::runtime_error("Internal error: cannot find ColumnVar in child targetlist.");
1998 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
shared::ColumnKey column_key_
Definition: Analyzer.h:239
ColumnVar(const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
Definition: Analyzer.h:196

+ Here is the call graph for this function:

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 1963 of file Analyzer.cpp.

References column_key_, deep_copy(), and getColumnKey().

1964  {
1965  for (auto tle : tlist) {
1966  const Expr* e = tle->get_expr();
1967  const ColumnVar* colvar = dynamic_cast<const ColumnVar*>(e);
1968  if (colvar != nullptr) {
1969  if (column_key_ == colvar->getColumnKey()) {
1970  return colvar->deep_copy();
1971  }
1972  }
1973  }
1974  throw std::runtime_error("Internal error: cannot find ColumnVar in targetlist.");
1975 }
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:70
shared::ColumnKey column_key_
Definition: Analyzer.h:239
ColumnVar(const SQLTypeInfo &ti, const shared::ColumnKey &column_key, int32_t rte_idx)
Definition: Analyzer.h:196

+ Here is the call graph for this function:

void Analyzer::ColumnVar::set_rte_idx ( int32_t  new_rte_idx)
inline

Definition at line 203 of file Analyzer.h.

References rte_idx_.

203 { rte_idx_ = new_rte_idx; }
std::string Analyzer::ColumnVar::toString ( ) const
overridevirtual

Implements Analyzer::Expr.

Reimplemented in Analyzer::Var.

Definition at line 2717 of file Analyzer.cpp.

References column_key_, Analyzer::Expr::get_type_info(), SQLTypeInfo::get_type_name(), rte_idx_, to_string(), SQLTypeInfo::toString(), and Analyzer::Expr::type_info.

Referenced by CodeGenerator::codegenColVar(), CodeGenerator::codegenGeoColumnVar(), and PerfectJoinHashTable::getAlternativeCacheKey().

2717  {
2718  std::stringstream ss;
2719  ss << "(ColumnVar " << column_key_ << ", rte: " << std::to_string(rte_idx_) << " "
2720  << get_type_info().get_type_name() << ", type: " << type_info.toString() << ") ";
2721  return ss.str();
2722 }
shared::ColumnKey column_key_
Definition: Analyzer.h:239
SQLTypeInfo type_info
Definition: Analyzer.h:180
std::string to_string(char const *&&v)
std::string toString() const
Definition: sqltypes.h:523
const SQLTypeInfo & get_type_info() const
Definition: Analyzer.h:79
std::string get_type_name() const
Definition: sqltypes.h:482

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

int32_t Analyzer::ColumnVar::rte_idx_
protected

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