Copilot commented on code in PR #50391:
URL: https://github.com/apache/arrow/pull/50391#discussion_r3529220222
##########
ruby/red-arrow-format/lib/arrow-format/array.rb:
##########
@@ -160,8 +160,19 @@ def to_a
end
class PrimitiveArray < Array
- def initialize(type, size, validity_buffer, values_buffer)
- super(type, size, validity_buffer)
+ include BufferAlignable
+
+ def initialize(*args)
+ if args.size == 1
+ args = build_data(args[0])
+ end
+ n_args = args.size
+ if args.size != 3
+ message = "wrong number of arguments (given #{n_args}, expected 1 or
3)"
+ raise ArgumentError, message
+ end
+ size, validity_buffer, values_buffer = args
+ super(self.class.type, size, validity_buffer)
@values_buffer = values_buffer
end
Review Comment:
PrimitiveArray#initialize now only accepts 1 or 3 args and always uses
self.class.type. But several existing array types (e.g.,
Time32Array/Time64Array/TimestampArray) are still constructed with a runtime
type instance as the first arg (see Type#build_array using
`Time32Array.new(self, ...)`), and Time32Array doesn’t define a class-level
`type`. This will raise ArgumentError/NoMethodError and breaks temporal arrays.
Consider supporting the legacy 4-arg constructor (type, size, validity_buffer,
values_buffer) and using the passed type when provided, while keeping the 1-arg
builder path for numeric primitives.
--
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]