Skip to content

Commit b41c3c2

Browse files
committed
Add function registry for to_timestamp method
1 parent b5a80ed commit b41c3c2

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

cpp/src/gandiva/function_registry_common.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,15 @@ typedef std::unordered_map<const FunctionSignature*, const NativeFunction*, KeyH
174174
NativeFunction(#NAME, std::vector<std::string> ALIASES, DataTypeVector{TYPE()}, \
175175
date64(), kResultNullIfNull, ARROW_STRINGIFY(NAME##_from_##TYPE))
176176

177+
// To timestamp functions (used with data/time types) that :
178+
// - NULL handling is of type NULL_IF_NULL
179+
//
180+
// The pre-compiled fn name includes the base name & input type name. eg:
181+
// - to_timestamp_date64
182+
#define TO_TIMESTAMP_SAFE_NULL_IF_NULL(NAME, ALIASES, TYPE) \
183+
NativeFunction(#NAME, std::vector<std::string> ALIASES, DataTypeVector{TYPE()}, \
184+
timestamp(), kResultNullIfNull, ARROW_STRINGIFY(NAME##_##TYPE))
185+
177186
// Hash32 functions that :
178187
// - NULL handling is of type NULL_NEVER
179188
//

cpp/src/gandiva/function_registry_datetime.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ std::vector<NativeFunction> GetDateTimeFunctionRegistry() {
8686
NativeFunction("extractDay", {}, DataTypeVector{day_time_interval()}, int64(),
8787
kResultNullIfNull, "extractDay_daytimeinterval"),
8888

89-
DATE_TYPES(LAST_DAY_SAFE_NULL_IF_NULL, last_day, {})};
89+
DATE_TYPES(LAST_DAY_SAFE_NULL_IF_NULL, last_day, {}),
90+
91+
DATE_TYPES(TO_TIMESTAMP_SAFE_NULL_IF_NULL, to_timestamp, {})};
9092

9193
return date_time_fn_registry_;
9294
}

0 commit comments

Comments
 (0)