Permalink
Browse files

Add placeholder for the interpreted engine.

  • Loading branch information...
malin1993ml authored and hzxa21 committed Nov 12, 2017
1 parent 4f939d8 commit edce0b5edc255a66e0ed67f3c42c12feb3aa1899
Showing with 17 additions and 3 deletions.
  1. +1 −1 src/catalog/catalog.cpp
  2. +15 −2 src/function/timestamp_functions.cpp
  3. +1 −0 src/include/function/timestamp_functions.h
View
@@ -1030,7 +1030,7 @@ void Catalog::InitializeFunctions() {
"date_trunc", {type::TypeId::INTEGER, type::TypeId::TIMESTAMP},
type::TypeId::TIMESTAMP, internal_lang, "DateTrunc",
function::BuiltInFuncType{OperatorId::DateTrunc,
function::DateFunctions::Extract},
function::TimestampFunctions::_DateTrunc},
txn);
} catch (CatalogException &e) {
txn_manager.AbortTransaction(txn);
@@ -28,7 +28,7 @@ namespace function {
uint64_t TimestampFunctions::DateTrunc(uint32_t date_part_type,
uint64_t value) {
DatePartType date_part =
*reinterpret_cast<const DatePartType*>(&date_part_type);
*reinterpret_cast<const DatePartType *>(&date_part_type);
uint64_t timestamp = value;
uint64_t result = 0;
@@ -131,5 +131,18 @@ uint64_t TimestampFunctions::DateTrunc(uint32_t date_part_type,
return (result);
}
} // namespace expression
type::Value TimestampFunctions::_DateTrunc(
const std::vector<type::Value> &args) {
uint32_t date_part = args[0].GetAs<uint32_t>();
uint64_t timestamp = args[1].GetAs<uint64_t>();
type::Value result;
if (timestamp == type::PELOTON_TIMESTAMP_NULL) {
return type::ValueFactory::GetNullValueByType(type::TypeId::TIMESTAMP);
}
uint64_t ret = DateTrunc(date_part, timestamp);
return type::ValueFactory::GetTimestampValue(ret);
}
} // namespace function
} // namespace peloton
@@ -41,6 +41,7 @@ class TimestampFunctions {
// support explicit type casts. For example:
// SELECT date_trunc('hour', TIMESTAMP '2001-02-16 20:38:40');
static uint64_t DateTrunc(uint32_t date_part_type, uint64_t value);
static type::Value _DateTrunc(const std::vector<type::Value> &args);
};
} // namespace function

0 comments on commit edce0b5

Please sign in to comment.