heronshoes commented on code in PR #33654:
URL: https://github.com/apache/arrow/pull/33654#discussion_r1070531574


##########
ruby/red-arrow/lib/arrow/table.rb:
##########
@@ -620,5 +657,24 @@ def ensure_raw_column(name, data)
         raise ArgumentError, message
       end
     end
+
+    def merge_columns_in_table(table, keys)
+      fields = table.schema.fields
+      arrays = table.columns.map(&:data)
+      keys.each_with_index do |k, i|
+        l = table.column_names.index(k)
+        r = table.column_names.rindex(k)
+        arrays[l] = merge_arrays(table.columns[l].data, table.columns[r].data)
+        fields[l] = Arrow::Field.new(k, fields[l].data_type)
+        arrays.delete_at(r - i)
+        fields.delete_at(r - i)
+      end
+      Arrow::Table.new(Arrow::Schema.new(fields), arrays)
+    end
+
+    def merge_arrays(array1, array2)
+      booleans = Arrow::Function.find(:is_null).execute([array1])
+      Arrow::Function.find(:if_else).execute([booleans, array2, array1]).value

Review Comment:
   Thanks! It will be the best solution!



-- 
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