[ 
https://issues.apache.org/jira/browse/ARROW-1926?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16296145#comment-16296145
 ] 

ASF GitHub Bot commented on ARROW-1926:
---------------------------------------

wesm closed pull request #1424: ARROW-1926: [GLib] Add 
garrow_timestamp_data_type_get_unit()
URL: https://github.com/apache/arrow/pull/1424
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/c_glib/arrow-glib/basic-data-type.cpp 
b/c_glib/arrow-glib/basic-data-type.cpp
index dcafe06d6..a5f7aed1b 100644
--- a/c_glib/arrow-glib/basic-data-type.cpp
+++ b/c_glib/arrow-glib/basic-data-type.cpp
@@ -805,6 +805,24 @@ garrow_timestamp_data_type_new(GArrowTimeUnit unit)
   return data_type;
 }
 
+/**
+ * garrow_timestamp_data_type_get_unit:
+ * @timestamp_data_type: The #GArrowTimestampDataType.
+ *
+ * Returns: The unit of the timestamp data type.
+ *
+ * Since: 0.8.0
+ */
+GArrowTimeUnit
+garrow_timestamp_data_type_get_unit(GArrowTimestampDataType 
*timestamp_data_type)
+{
+  const auto arrow_data_type =
+    garrow_data_type_get_raw(GARROW_DATA_TYPE(timestamp_data_type));
+  const auto arrow_timestamp_data_type =
+    std::static_pointer_cast<arrow::TimestampType>(arrow_data_type);
+  return garrow_time_unit_from_raw(arrow_timestamp_data_type->unit());
+}
+
 
 G_DEFINE_TYPE(GArrowTimeDataType,               \
               garrow_time_data_type,            \
diff --git a/c_glib/arrow-glib/basic-data-type.h 
b/c_glib/arrow-glib/basic-data-type.h
index bc0192f1b..469590191 100644
--- a/c_glib/arrow-glib/basic-data-type.h
+++ b/c_glib/arrow-glib/basic-data-type.h
@@ -774,6 +774,8 @@ struct _GArrowTimestampDataTypeClass
 
 GType                 garrow_timestamp_data_type_get_type (void) G_GNUC_CONST;
 GArrowTimestampDataType *garrow_timestamp_data_type_new   (GArrowTimeUnit 
unit);
+GArrowTimeUnit
+garrow_timestamp_data_type_get_unit (GArrowTimestampDataType 
*timestamp_data_type);
 
 
 #define GARROW_TYPE_TIME_DATA_TYPE              \
diff --git a/c_glib/test/test-timestamp-data-type.rb 
b/c_glib/test/test-timestamp-data-type.rb
index 830388769..bbc597c16 100644
--- a/c_glib/test/test-timestamp-data-type.rb
+++ b/c_glib/test/test-timestamp-data-type.rb
@@ -29,6 +29,10 @@ def setup
     def test_to_s
       assert_equal("timestamp[s]", @data_type.to_s)
     end
+
+    def test_unit
+      assert_equal(Arrow::TimeUnit::SECOND, @data_type.unit)
+    end
   end
 
   sub_test_case("millisecond") do
@@ -39,6 +43,10 @@ def setup
     def test_to_s
       assert_equal("timestamp[ms]", @data_type.to_s)
     end
+
+    def test_unit
+      assert_equal(Arrow::TimeUnit::MILLI, @data_type.unit)
+    end
   end
 
   sub_test_case("micro") do
@@ -49,6 +57,10 @@ def setup
     def test_to_s
       assert_equal("timestamp[us]", @data_type.to_s)
     end
+
+    def test_unit
+      assert_equal(Arrow::TimeUnit::MICRO, @data_type.unit)
+    end
   end
 
   sub_test_case("nano") do
@@ -59,5 +71,9 @@ def setup
     def test_to_s
       assert_equal("timestamp[ns]", @data_type.to_s)
     end
+
+    def test_unit
+      assert_equal(Arrow::TimeUnit::NANO, @data_type.unit)
+    end
   end
 end


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> [GLib] Add garrow_timestamp_data_type_get_unit()
> ------------------------------------------------
>
>                 Key: ARROW-1926
>                 URL: https://issues.apache.org/jira/browse/ARROW-1926
>             Project: Apache Arrow
>          Issue Type: New Feature
>          Components: GLib
>            Reporter: Kouhei Sutou
>            Assignee: Kouhei Sutou
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> If 0.8.0 RC2 is dropped, I hope that 0.8.0 includes this.
> If RC2 has no problem, I hope that 0.9.0 includes this. 



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to