OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DateTimePlusRewrite.h File Reference
#include <memory>
+ Include dependency graph for DateTimePlusRewrite.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.




std::shared_ptr< Analyzer::Exprrewrite_to_date_trunc (const Analyzer::FunctionOper *)

Function Documentation

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

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
DatetruncField get_dt_field(const Analyzer::Expr *ts, const Analyzer::Expr *interval_multiplier, const bool dt_hour)
std::shared_ptr< Analyzer::Expr > remove_cast_to_date(const Analyzer::Expr *expr)
const std::shared_ptr< Analyzer::Expr > generate() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function: