OmniSciDB  baf940c279
Analyzer::DatediffExpr Class Reference

#include <Analyzer.h>

+ Inheritance diagram for Analyzer::DatediffExpr:
+ Collaboration diagram for Analyzer::DatediffExpr:

Public Member Functions

 DatediffExpr (const SQLTypeInfo &ti, const DatetruncField f, const std::shared_ptr< Analyzer::Expr > start, const std::shared_ptr< Analyzer::Expr > end)
 
DatetruncField get_field () const
 
const Exprget_start_expr () const
 
const Exprget_end_expr () const
 
std::shared_ptr< Analyzer::Exprdeep_copy () const override
 
void check_group_by (const std::list< std::shared_ptr< Analyzer::Expr >> &groupby) 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
 
void find_expr (bool(*f)(const Expr *), std::list< const Expr *> &expr_list) 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::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
 
std::shared_ptr< Analyzer::Exprdecompress ()
 
virtual void get_domain (DomainSet &domain_set) const
 

Private Attributes

const DatetruncField field_
 
const std::shared_ptr< Analyzer::Exprstart_
 
const std::shared_ptr< Analyzer::Exprend_
 

Additional Inherited Members

- Protected Attributes inherited from Analyzer::Expr
SQLTypeInfo type_info
 
bool contains_agg
 

Detailed Description

Definition at line 1272 of file Analyzer.h.

Constructor & Destructor Documentation

◆ DatediffExpr()

Analyzer::DatediffExpr::DatediffExpr ( const SQLTypeInfo ti,
const DatetruncField  f,
const std::shared_ptr< Analyzer::Expr start,
const std::shared_ptr< Analyzer::Expr end 
)
inline

Definition at line 1274 of file Analyzer.h.

1278  : Expr(ti, false), field_(f), start_(start), end_(end) {}
Expr(SQLTypes t, bool notnull)
Definition: Analyzer.h:69
const DatetruncField field_
Definition: Analyzer.h:1305
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

Member Function Documentation

◆ check_group_by()

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

Reimplemented from Analyzer::Expr.

Definition at line 3085 of file Analyzer.cpp.

3086  {
3087  start_->check_group_by(groupby);
3088  end_->check_group_by(groupby);
3089 }
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

◆ collect_column_var()

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

Reimplemented from Analyzer::Expr.

Definition at line 3050 of file Analyzer.cpp.

3052  {
3053  start_->collect_column_var(colvar_set, include_agg);
3054  end_->collect_column_var(colvar_set, include_agg);
3055 }
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

◆ collect_rte_idx()

void Analyzer::DatediffExpr::collect_rte_idx ( std::set< int > &  rte_idx_set) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 3016 of file Analyzer.cpp.

3016  {
3017  start_->collect_rte_idx(rte_idx_set);
3018  end_->collect_rte_idx(rte_idx_set);
3019 }
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

◆ deep_copy()

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

Implements Analyzer::Expr.

Definition at line 188 of file Analyzer.cpp.

References Analyzer::Expr::type_info.

188  {
189  return makeExpr<DatediffExpr>(
190  type_info, field_, start_->deep_copy(), end_->deep_copy());
191 }
SQLTypeInfo type_info
Definition: Analyzer.h:176
const DatetruncField field_
Definition: Analyzer.h:1305
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

◆ find_expr()

void Analyzer::DatediffExpr::find_expr ( bool(*)(const Expr *)  f,
std::list< const Expr *> &  expr_list 
) const
overridevirtual

Reimplemented from Analyzer::Expr.

Definition at line 2978 of file Analyzer.cpp.

References Analyzer::Expr::add_unique().

2979  {
2980  if (f(this)) {
2981  add_unique(expr_list);
2982  return;
2983  }
2984  start_->find_expr(f, expr_list);
2985  end_->find_expr(f, expr_list);
2986 }
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306
virtual void add_unique(std::list< const Expr *> &expr_list) const
Definition: Analyzer.cpp:2815
+ Here is the call graph for this function:

◆ get_end_expr()

const Expr* Analyzer::DatediffExpr::get_end_expr ( ) const
inline

Definition at line 1281 of file Analyzer.h.

References operator==(), and toString().

Referenced by CodeGenerator::codegen(), operator==(), DeepCopyVisitor::visitDatediffExpr(), and ScalarExprVisitor< std::unordered_set< InputColDescriptor > >::visitDatediffExpr().

1281 { return end_.get(); }
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_field()

DatetruncField Analyzer::DatediffExpr::get_field ( ) const
inline

Definition at line 1279 of file Analyzer.h.

Referenced by CodeGenerator::codegen(), operator==(), and DeepCopyVisitor::visitDatediffExpr().

1279 { return field_; }
const DatetruncField field_
Definition: Analyzer.h:1305
+ Here is the caller graph for this function:

◆ get_start_expr()

const Expr* Analyzer::DatediffExpr::get_start_expr ( ) const
inline

Definition at line 1280 of file Analyzer.h.

Referenced by CodeGenerator::codegen(), operator==(), DeepCopyVisitor::visitDatediffExpr(), and ScalarExprVisitor< std::unordered_set< InputColDescriptor > >::visitDatediffExpr().

1280 { return start_.get(); }
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306
+ Here is the caller graph for this function:

◆ group_predicates()

void Analyzer::DatediffExpr::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 1729 of file Analyzer.cpp.

1731  {
1732  std::set<int> rte_idx_set;
1733  start_->collect_rte_idx(rte_idx_set);
1734  end_->collect_rte_idx(rte_idx_set);
1735  if (rte_idx_set.size() > 1) {
1736  join_predicates.push_back(this);
1737  } else if (rte_idx_set.size() == 1) {
1738  scan_predicates.push_back(this);
1739  } else {
1740  const_predicates.push_back(this);
1741  }
1742 }
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

◆ operator==()

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

Implements Analyzer::Expr.

Definition at line 2319 of file Analyzer.cpp.

References get_end_expr(), get_field(), and get_start_expr().

2319  {
2320  if (typeid(rhs) != typeid(DatediffExpr)) {
2321  return false;
2322  }
2323  const DatediffExpr& rhs_ee = dynamic_cast<const DatediffExpr&>(rhs);
2324  return field_ == rhs_ee.get_field() && *start_ == *rhs_ee.get_start_expr() &&
2325  *end_ == *rhs_ee.get_end_expr();
2326 }
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
const DatetruncField field_
Definition: Analyzer.h:1305
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306
+ Here is the call graph for this function:

◆ rewrite_agg_to_var()

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

Reimplemented from Analyzer::Expr.

Definition at line 2018 of file Analyzer.cpp.

References Analyzer::Expr::type_info.

2019  {
2020  return makeExpr<DatediffExpr>(type_info,
2021  field_,
2022  start_->rewrite_agg_to_var(tlist),
2023  end_->rewrite_agg_to_var(tlist));
2024 }
SQLTypeInfo type_info
Definition: Analyzer.h:176
const DatetruncField field_
Definition: Analyzer.h:1305
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

◆ rewrite_with_child_targetlist()

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

Reimplemented from Analyzer::Expr.

Definition at line 1976 of file Analyzer.cpp.

References Analyzer::Expr::type_info.

1977  {
1978  return makeExpr<DatediffExpr>(type_info,
1979  field_,
1980  start_->rewrite_with_child_targetlist(tlist),
1981  end_->rewrite_with_child_targetlist(tlist));
1982 }
SQLTypeInfo type_info
Definition: Analyzer.h:176
const DatetruncField field_
Definition: Analyzer.h:1305
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

◆ rewrite_with_targetlist()

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

Reimplemented from Analyzer::Expr.

Definition at line 1933 of file Analyzer.cpp.

References Analyzer::Expr::type_info.

1934  {
1935  return makeExpr<DatediffExpr>(type_info,
1936  field_,
1937  start_->rewrite_with_targetlist(tlist),
1938  end_->rewrite_with_targetlist(tlist));
1939 }
SQLTypeInfo type_info
Definition: Analyzer.h:176
const DatetruncField field_
Definition: Analyzer.h:1305
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306

◆ toString()

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

Implements Analyzer::Expr.

Definition at line 2704 of file Analyzer.cpp.

References to_string().

2704  {
2705  return "DATEDIFF(" + std::to_string(field_) + " START " + start_->toString() + " END " +
2706  end_->toString() + ") ";
2707 }
std::string to_string(char const *&&v)
const DatetruncField field_
Definition: Analyzer.h:1305
const std::shared_ptr< Analyzer::Expr > end_
Definition: Analyzer.h:1307
const std::shared_ptr< Analyzer::Expr > start_
Definition: Analyzer.h:1306
+ Here is the call graph for this function:

Member Data Documentation

◆ end_

const std::shared_ptr<Analyzer::Expr> Analyzer::DatediffExpr::end_
private

Definition at line 1307 of file Analyzer.h.

◆ field_

const DatetruncField Analyzer::DatediffExpr::field_
private

Definition at line 1305 of file Analyzer.h.

◆ start_

const std::shared_ptr<Analyzer::Expr> Analyzer::DatediffExpr::start_
private

Definition at line 1306 of file Analyzer.h.


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