Copilot commented on code in PR #50445:
URL: https://github.com/apache/arrow/pull/50445#discussion_r3550493428


##########
ruby/red-arrow-format/lib/arrow-format/type.rb:
##########
@@ -548,6 +548,23 @@ def build_array(...)
   end
 
   class TimestampType < TemporalType
+    class << self
+      def try_convert(value)
+        case value
+        when Symbol
+          unit = value
+          TimestampType.new(unit, nil)
+        when Array
+          unit, time_zone = value
+          TimestampType.new(unit, time_zone)

Review Comment:
   `TimestampType.try_convert` uses `TimestampType.new(...)` inside a class 
method, which will always instantiate the base class even if `try_convert` is 
inherited and called from a subclass. Other `try_convert` implementations in 
this file use `new(...)`, which preserves subclassing and is more consistent.



##########
ruby/red-arrow-format/test/test-timestamp-array.rb:
##########
@@ -0,0 +1,79 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestTimestampArray < Test::Unit::TestCase
+  def setup
+    @timestamp_2019_11_17_15_09_11 = 1574003351
+    @timestamp_2025_12_16_05_33_58 = 1765863238
+  end
+
+  sub_test_case("#initialize") do
+    def test_no_null
+      values = [
+        @timestamp_2019_11_17_15_09_11,
+        @timestamp_2025_12_16_05_33_58,
+      ]
+      assert_equal(values,
+                   ArrowFormat::TimestampArray.new(:second, values).to_a)
+    end

Review Comment:
   The PR title/description refer to adding `ArrowFormat::Timestamp.new(unit, 
values)`, but this change set appears to add/support 
`ArrowFormat::TimestampArray.new(unit, values)` (and 
`TimestampType.try_convert`). Consider updating the PR metadata to match the 
actual API being introduced and the linked issue (#50436).



##########
ruby/red-arrow-format/test/test-timestamp-array.rb:
##########
@@ -0,0 +1,79 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+class TestTimestampArray < Test::Unit::TestCase
+  def setup
+    @timestamp_2019_11_17_15_09_11 = 1574003351
+    @timestamp_2025_12_16_05_33_58 = 1765863238
+  end
+
+  sub_test_case("#initialize") do
+    def test_no_null
+      values = [
+        @timestamp_2019_11_17_15_09_11,
+        @timestamp_2025_12_16_05_33_58,
+      ]
+      assert_equal(values,
+                   ArrowFormat::TimestampArray.new(:second, values).to_a)
+    end
+
+    def test_mixed
+      values = [
+        @timestamp_2019_11_17_15_09_11,
+        nil,
+        @timestamp_2025_12_16_05_33_58,
+      ]
+      assert_equal(values,
+                   ArrowFormat::TimestampArray.new(:second, values).to_a)
+    end
+  end

Review Comment:
   `TimestampType.try_convert` supports passing `[unit, time_zone]` as the 
first argument to `TimestampArray.new`, but there isn't a test covering this 
new initialization form. Adding a test helps ensure the time zone is preserved 
and the conversion path stays supported.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to