OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DateTimePlusRewrite.cpp File Reference
+ Include dependency graph for DateTimePlusRewrite.cpp:

Go to the source code of this file.

Namespaces

 anonymous_namespace{DateTimePlusRewrite.cpp}
 

Functions

const Analyzer::Expranonymous_namespace{DateTimePlusRewrite.cpp}::remove_truncate_int (const Analyzer::Expr *expr)
 
bool anonymous_namespace{DateTimePlusRewrite.cpp}::match_const_integer (const Analyzer::Expr *expr, const int64_t v)
 
DatetruncField anonymous_namespace{DateTimePlusRewrite.cpp}::get_dt_field (const Analyzer::Expr *ts, const Analyzer::Expr *interval_multiplier, const bool dt_hour)
 
DatetruncField anonymous_namespace{DateTimePlusRewrite.cpp}::get_dt_field (const Analyzer::Expr *ts, const Analyzer::Expr *off_arg)
 
std::shared_ptr< Analyzer::Expranonymous_namespace{DateTimePlusRewrite.cpp}::remove_cast_to_date (const Analyzer::Expr *expr)
 
std::shared_ptr< Analyzer::Exprrewrite_to_date_trunc (const Analyzer::FunctionOper *dt_plus)
 

Function Documentation

std::shared_ptr<Analyzer::Expr> rewrite_to_date_trunc ( const Analyzer::FunctionOper dt_plus)

Definition at line 161 of file DateTimePlusRewrite.cpp.

References CHECK_EQ, dtINVALID, DateTruncExpr::generate(), anonymous_namespace{DateTimePlusRewrite.cpp}::get_dt_field(), Analyzer::FunctionOper::getArg(), Analyzer::FunctionOper::getArity(), Analyzer::FunctionOper::getName(), and anonymous_namespace{DateTimePlusRewrite.cpp}::remove_cast_to_date().

Referenced by RelAlgTranslator::translateDatePlusMinus(), and RelAlgTranslator::translateFunction().

162  {
163  CHECK_EQ("DATETIME_PLUS", dt_plus->getName());
164  CHECK_EQ(size_t(2), dt_plus->getArity());
165  const auto ts = remove_cast_to_date(dt_plus->getArg(0));
166  if (!ts) {
167  return nullptr;
168  }
169  const auto off_arg = dt_plus->getArg(1);
170  const auto dt_field = get_dt_field(ts.get(), off_arg);
171  if (dt_field == dtINVALID) {
172  return nullptr;
173  }
174  return DateTruncExpr::generate(ts, dt_field);
175 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
size_t getArity() const
Definition: Analyzer.h:2615
DatetruncField get_dt_field(const Analyzer::Expr *ts, const Analyzer::Expr *interval_multiplier, const bool dt_hour)
const Analyzer::Expr * getArg(const size_t i) const
Definition: Analyzer.h:2617
std::shared_ptr< Analyzer::Expr > remove_cast_to_date(const Analyzer::Expr *expr)
std::string getName() const
Definition: Analyzer.h:2613
const std::shared_ptr< Analyzer::Expr > generate() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function: