Skip to content

Commit

Permalink
add support to int32 type
Browse files Browse the repository at this point in the history
  • Loading branch information
rui-mo committed Jul 5, 2021
1 parent 8908635 commit 5d80831
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cpp/src/gandiva/function_registry_datetime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,21 @@ std::vector<NativeFunction> GetDateTimeFunctionRegistry() {
NativeFunction("seconds_to_timestamp", {}, DataTypeVector{int64()}, timestampusutc(),
kResultNullIfNull, "seconds_to_timestamp_int64"),

NativeFunction("seconds_to_timestamp", {}, DataTypeVector{int32()}, timestampusutc(),
kResultNullIfNull, "seconds_to_timestamp_int32"),

NativeFunction("millis_to_timestamp", {}, DataTypeVector{int64()}, timestampusutc(),
kResultNullIfNull, "millis_to_timestamp_int64"),

NativeFunction("millis_to_timestamp", {}, DataTypeVector{int32()}, timestampusutc(),
kResultNullIfNull, "millis_to_timestamp_int32"),

NativeFunction("micros_to_timestamp", {}, DataTypeVector{int64()}, timestampusutc(),
kResultNullIfNull, "micros_to_timestamp_int64"),

NativeFunction("micros_to_timestamp", {}, DataTypeVector{int32()}, timestampusutc(),
kResultNullIfNull, "micros_to_timestamp_int32"),

NativeFunction("date_diff", {}, DataTypeVector{date32(), date32()}, int32(),
kResultNullIfNull, "micros_to_timestamp_date32_date32"),

Expand Down
15 changes: 15 additions & 0 deletions cpp/src/gandiva/precompiled/time.cc
Original file line number Diff line number Diff line change
Expand Up @@ -921,16 +921,31 @@ gdv_timestamp seconds_to_timestamp_int64(gdv_int64 in) {
return in * 1000000;
}

FORCE_INLINE
gdv_timestamp seconds_to_timestamp_int32(gdv_int32 in) {
return (int64_t)in * 1000000;
}

FORCE_INLINE
gdv_timestamp millis_to_timestamp_int64(gdv_int64 in) {
return in * 1000;
}

FORCE_INLINE
gdv_timestamp millis_to_timestamp_int32(gdv_int32 in) {
return (int64_t)in * 1000;
}

FORCE_INLINE
gdv_timestamp micros_to_timestamp_int64(gdv_int64 in) {
return in;
}

FORCE_INLINE
gdv_timestamp micros_to_timestamp_int32(gdv_int32 in) {
return (int64_t)in;
}

FORCE_INLINE
gdv_int32 micros_to_timestamp_date32_date32(gdv_date32 left, gdv_date32 right) {
return left - right;
Expand Down

0 comments on commit 5d80831

Please sign in to comment.