You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "thisisnic (via GitHub)" <gi...@apache.org> on 2023/03/31 08:17:46 UTC

[GitHub] [arrow] thisisnic commented on a diff in pull request #34798: GH-15247: [R] Error when trying to save a data.frame with NULL column names

thisisnic commented on code in PR #34798:
URL: https://github.com/apache/arrow/pull/34798#discussion_r1154168985


##########
r/R/csv.R:
##########
@@ -782,12 +782,16 @@ write_csv_arrow <- function(x,
     tryCatch(
       x <- as_record_batch_reader(x),
       error = function(e) {
-        abort(
-          paste0(
-            "x must be an object of class 'data.frame', 'RecordBatch', ",
-            "'Dataset', 'Table', or 'RecordBatchReader' not '", class(x)[1], "'."
+        if (grepl("Input data frame columns must be named", conditionMessage(e))) {
+          abort(conditionMessage(e), parent = NA)

Review Comment:
   I'm not sure `parent = e` does exactly what you think; here's the error with `parent = NA`:
   ```
   Error in write_csv_arrow(x, tempfile()) : 
     Input data frame columns must be named
   ℹ Column names are NULL
   ```
   
   and here's the error with `parent = e`:
   
   ```
   Error in write_csv_arrow(x, tempfile()) : 
     Input data frame columns must be named
   ℹ Column names are NULL
   Caused by error:
   ! Input data frame columns must be named
   ℹ Column names are NULL
   ```
   
   I think `parent = NA` is a better fit in all cases.  Current error in the other condition with no parent specified:
   
   ```
   Error in value[[3L]](cond) : 
     x must be an object of class 'data.frame', 'RecordBatch', 'Dataset', 'Table', or 'RecordBatchReader' not 'function'.
   ```
   
   With `parent = NA`:
   ```
   Error in write_csv_arrow(c, tempfile()) : 
     x must be an object of class 'data.frame', 'RecordBatch', 'Dataset', 'Table', or 'RecordBatchReader' not 'function'.
   ```
   
   With `parent = e`:
   ```
   Error in write_csv_arrow(c, tempfile()) : 
     x must be an object of class 'data.frame', 'RecordBatch', 'Dataset', 'Table', or 'RecordBatchReader' not 'function'.
   Caused by error in `inherits()`:
   ! argument "schema" is missing, with no default
   ```
   
   I've updated it both so they have `parent = NA`.



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org