OmniSciDB  95562058bd
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DateTruncate.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 MapD Technologies, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef QUERYENGINE_DATETRUNCATE_H
18 #define QUERYENGINE_DATETRUNCATE_H
19 
20 #include <array>
21 #include <cstdint>
22 
23 #include "../Shared/funcannotations.h"
24 #include "ExtractFromTime.h"
25 
26 // DatetruncField must be synced with datetrunc_fname
28  dtYEAR = 0,
44 };
45 
46 constexpr std::array<char const*, dtINVALID> datetrunc_fname_lookup{
47  {"datetrunc_year",
48  "datetrunc_quarter",
49  "datetrunc_month",
50  "datetrunc_day",
51  "datetrunc_hour",
52  "datetrunc_minute",
53  "datetrunc_second", // not used
54  "datetrunc_millisecond", // not used
55  "datetrunc_microsecond", // not used
56  "datetrunc_nanosecond", // not used
57  "datetrunc_millennium",
58  "datetrunc_century",
59  "datetrunc_decade",
60  "datetrunc_week",
61  "datetrunc_quarterday"}};
62 
63 // Arithmetic which relies on these enums being consecutive is used elsewhere.
64 static_assert(dtSECOND + 1 == dtMILLISECOND, "Please keep these consecutive.");
65 static_assert(dtMILLISECOND + 1 == dtMICROSECOND, "Please keep these consecutive.");
66 static_assert(dtMICROSECOND + 1 == dtNANOSECOND, "Please keep these consecutive.");
67 
68 int64_t DateTruncate(DatetruncField field, const int64_t timeval);
69 
70 extern "C" DEVICE int64_t DateTruncateHighPrecisionToDate(const int64_t timeval,
71  const int64_t scale);
72 
73 #endif // QUERYENGINE_DATETRUNCATE_H
int64_t DateTruncate(DatetruncField field, const int64_t timeval)
#define DEVICE
const rapidjson::Value & field(const rapidjson::Value &obj, const char field[]) noexcept
Definition: JsonAccessors.h:31
DatetruncField
Definition: DateTruncate.h:27
constexpr std::array< char const *, dtINVALID > datetrunc_fname_lookup
Definition: DateTruncate.h:47
ALWAYS_INLINE DEVICE int64_t DateTruncateHighPrecisionToDate(const int64_t timeval, const int64_t scale)