kou commented on code in PR #50226:
URL: https://github.com/apache/arrow/pull/50226#discussion_r3441760975
##########
ruby/red-arrow/lib/arrow/column-containable.rb:
##########
@@ -152,5 +152,68 @@ def [](selector)
def column_names
@column_names ||= columns.collect(&:name)
end
+
+ # Merges columns from the given container or Hash and creates
+ # a new container.
+ #
+ # @param other [Hash, self]
+ # The columns to be merged.
+ #
+ # @return [self]
+ def merge(other)
+ added_columns = {}
+ removed_columns = {}
+
+ case other
+ when Hash
+ other.each do |name, value|
+ name = name.to_s
+ if value
+ added_columns[name] = ensure_raw_column(name, value)
+ else
+ removed_columns[name] = true
+ end
+ end
+ when merge_target_class
Review Comment:
Can we use `self.class` here?
```suggestion
when self.class
```
##########
ruby/red-arrow/lib/arrow/record-batch.rb:
##########
@@ -135,6 +78,20 @@ def method_missing(name, *args, &block)
private
+ def merge_target_class
+ RecordBatch
+ end
+
+ def create_merged_container(fields, arrays)
+ record_batch = self.class.new(
+ Schema.new(fields),
+ n_rows,
+ arrays,
+ )
Review Comment:
If we can use `RecordBatch.new(fields, arrays)`, can we unify this code?
If so, let's accept `RecordBatch.new(fields, arrays)`.
--
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]