wjones127 commented on code in PR #12751:
URL: https://github.com/apache/arrow/pull/12751#discussion_r846496712


##########
r/R/record-batch.R:
##########
@@ -189,3 +189,52 @@ record_batch <- RecordBatch$create
 
 #' @export
 names.RecordBatch <- function(x) x$names()
+
+#' @export
+rbind.RecordBatch <- function(...) {
+  abort("Use Table$create to combine record batches")
+}
+
+cbind_check_length <- function(target_length, length, idx) {
+  if (length != target_length) {
+    abort(
+      sprintf(
+        "Non-scalar inputs must have an equal number of rows. ..1 has %i, ..%i 
has %i",
+        target_length,
+        idx,
+        length
+      )
+    )
+  }
+}
+
+#' @export
+cbind.RecordBatch <- function(...) {
+  inputs <- list(...)
+  num_rows <- inputs[[1]]$num_rows
+
+  batches <- imap(inputs, function(input, idx) {

Review Comment:
   Thanks. I'm not a fan of how base R handles the case of no names:
   
   ```r
   > cbind(data.frame(x = 1:2), b = 3:4, 5:6, c("a", "b"))
     x b 5:6 c("a", "b")
   1 1 3   5           a
   2 2 4   6           b
   ```
   
   So I opted for using `X{i}` instead:
   
   ```r
   > as.data.frame(cbind(record_batch(x = 1:2), b = 3:4, 5:6, c("a", "b")))
     x b X3 X4
   1 1 3  5  a
   2 2 4  6  b
   ```
   
   LMK what you think



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