You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ra...@apache.org on 2019/07/31 10:13:27 UTC

[arrow] branch master updated: ARROW-5975: [C++][Gandiva] support castTIMESTAMP(date)

This is an automated email from the ASF dual-hosted git repository.

ravindra pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 8bdade4  ARROW-5975: [C++][Gandiva] support castTIMESTAMP(date)
8bdade4 is described below

commit 8bdade454460f7c5a55388045f8520161aa6f982
Author: Prudhvi Porandla <pr...@icloud.com>
AuthorDate: Wed Jul 31 15:43:05 2019 +0530

    ARROW-5975: [C++][Gandiva] support castTIMESTAMP(date)
    
    Closes #4902 from pprudhvi/casttimestamp-date and squashes the following commits:
    
    49de5528f <Prudhvi Porandla> add castTIMESTAMP_date64 method and its unittest
    
    Authored-by: Prudhvi Porandla <pr...@icloud.com>
    Signed-off-by: Pindikura Ravindra <ra...@dremio.com>
---
 cpp/src/gandiva/function_registry_datetime.cc | 4 +++-
 cpp/src/gandiva/precompiled/time.cc           | 3 +++
 cpp/src/gandiva/precompiled/time_test.cc      | 3 +++
 cpp/src/gandiva/precompiled/types.h           | 1 +
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/cpp/src/gandiva/function_registry_datetime.cc b/cpp/src/gandiva/function_registry_datetime.cc
index 2f52b74..b9c61e5 100644
--- a/cpp/src/gandiva/function_registry_datetime.cc
+++ b/cpp/src/gandiva/function_registry_datetime.cc
@@ -61,7 +61,9 @@ std::vector<NativeFunction> GetDateTimeFunctionRegistry() {
                      kResultNullInternal, "gdv_fn_to_date_utf8_utf8_int32",
                      NativeFunction::kNeedsContext |
                          NativeFunction::kNeedsFunctionHolder |
-                         NativeFunction::kCanReturnErrors)};
+                         NativeFunction::kCanReturnErrors),
+      NativeFunction("castTIMESTAMP", {}, DataTypeVector{date64()}, timestamp(),
+                     kResultNullIfNull, "castTIMESTAMP_date64")};
 
   return date_time_fn_registry_;
 }
diff --git a/cpp/src/gandiva/precompiled/time.cc b/cpp/src/gandiva/precompiled/time.cc
index bb53275..b24e015 100644
--- a/cpp/src/gandiva/precompiled/time.cc
+++ b/cpp/src/gandiva/precompiled/time.cc
@@ -686,4 +686,7 @@ timestamp castTIMESTAMP_utf8(int64_t context, const char* input, int32 length) {
   }
   return std::chrono::time_point_cast<milliseconds>(date_time).time_since_epoch().count();
 }
+
+timestamp castTIMESTAMP_date64(date64 date_in_millis) { return date_in_millis; }
+
 }  // extern "C"
diff --git a/cpp/src/gandiva/precompiled/time_test.cc b/cpp/src/gandiva/precompiled/time_test.cc
index 66c48e3..c9f0f68 100644
--- a/cpp/src/gandiva/precompiled/time_test.cc
+++ b/cpp/src/gandiva/precompiled/time_test.cc
@@ -89,6 +89,9 @@ TEST(TestTime, TestCastTimestamp) {
             -1187308799080);
   EXPECT_EQ(castTIMESTAMP_utf8(context_ptr, "1857-02-11 20:31:40.920 -05:30", 30),
             -3562264699080);
+  EXPECT_EQ(castTIMESTAMP_date64(
+                castDATE_utf8(context_ptr, "2000-09-23 9:45:30.920 +08:00", 29)),
+            castTIMESTAMP_utf8(context_ptr, "2000-09-23 0:00:00.000 +00:00", 29));
 }
 
 #ifndef _WIN32
diff --git a/cpp/src/gandiva/precompiled/types.h b/cpp/src/gandiva/precompiled/types.h
index 397cf99..7d6a9c4 100644
--- a/cpp/src/gandiva/precompiled/types.h
+++ b/cpp/src/gandiva/precompiled/types.h
@@ -163,6 +163,7 @@ int32 utf8_length(int64 context, const char* data, int32 data_len);
 date64 castDATE_utf8(int64_t execution_context, const char* input, int32 length);
 
 timestamp castTIMESTAMP_utf8(int64_t execution_context, const char* input, int32 length);
+timestamp castTIMESTAMP_date64(date64);
 
 }  // extern "C"