Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
apacheGH-15247: [R] Error when trying to save a data.frame with NULL …
…column names (apache#34798) Before: ``` df <- data.frame(a=1:3,b=4:6) names(df) <- NULL arrow::write_feather(x=df, sink="~/tmp/df") #> Error: Invalid input type, expected 'character' actual 'NULL' arrow::write_csv_arrow(df, "tst.csv") #> Error in `value[[3L]]()`: #> ! x must be an object of class 'data.frame', 'RecordBatch', 'Dataset', 'Table', or 'RecordBatchReader' not 'data.frame'. #> Backtrace: #> ▆ #> 1. └─arrow::write_csv_arrow(df, "tst.csv") #> 2. └─base::tryCatch(...) #> 3. └─base (local) tryCatchList(expr, classes, parentenv, handlers) #> 4. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 5. └─value[[3L]](cond) #> 6. └─rlang::abort(...) arrow::write_parquet(df, "tst.csv") #> Error: Invalid input type, expected 'character' actual 'NULL' ``` After: ``` r df <- data.frame(a=1:3,b=4:6) names(df) <- NULL arrow::write_feather(x=df, sink="~/tmp/df") #> Error in `arrow::write_feather()`: #> ! Input data frame columns must be named #> ℹ Column names are NULL #> Backtrace: #> ▆ #> 1. └─arrow::write_feather(x = df, sink = "~/tmp/df") #> 2. └─arrow:::as_writable_table(x) at r/R/feather.R:124:2 #> 3. ├─base::tryCatch(...) at r/R/util.R:150:2 #> 4. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers) #> 5. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 6. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler) #> 7. ├─arrow::as_arrow_table(x) at r/R/util.R:150:2 #> 8. └─arrow:::as_arrow_table.data.frame(x) at r/R/table.R:284:2 #> 9. └─arrow:::check_named_cols(x) at r/R/table.R:324:2 #> 10. └─rlang::abort(...) at r/R/util.R:255:4 arrow::write_csv_arrow(df, "tst.csv") #> Error in `arrow::write_csv_arrow()`: #> ! Input data frame columns must be named #> ℹ Column names are NULL #> Backtrace: #> ▆ #> 1. └─arrow::write_csv_arrow(df, "tst.csv") #> 2. └─base::tryCatch(...) at r/R/csv.R:782:4 #> 3. └─base (local) tryCatchList(expr, classes, parentenv, handlers) #> 4. └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 5. └─value[[3L]](cond) #> 6. └─rlang::abort(conditionMessage(e), parent = NA) at r/R/csv.R:786:10 arrow::write_parquet(df, "tst.csv") #> Error in `arrow::write_parquet()`: #> ! Input data frame columns must be named #> ℹ Column names are NULL #> Backtrace: #> ▆ #> 1. └─arrow::write_parquet(df, "tst.csv") #> 2. └─arrow:::as_writable_table(x) at r/R/parquet.R:164:2 #> 3. ├─base::tryCatch(...) at r/R/util.R:150:2 #> 4. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers) #> 5. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]]) #> 6. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler) #> 7. ├─arrow::as_arrow_table(x) at r/R/util.R:150:2 #> 8. └─arrow:::as_arrow_table.data.frame(x) at r/R/table.R:284:2 #> 9. └─arrow:::check_named_cols(x) at r/R/table.R:324:2 #> 10. └─rlang::abort(...) at r/R/util.R:255:4 ``` * Closes: apache#15247 Authored-by: Nic Crane <[email protected]> Signed-off-by: Nic Crane <[email protected]>
- Loading branch information