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


##########
r/R/table.R:
##########
@@ -339,7 +339,10 @@ as_arrow_table.Dataset <- function(x, ...) {
 #' @rdname as_arrow_table
 #' @export
 as_arrow_table.arrow_dplyr_query <- function(x, ...) {
-  out <- as_arrow_table(as_record_batch_reader(x))
+  reader <- as_record_batch_reader(x)
+  on.exit(reader$.unsafe_delete())

Review Comment:
   Similarly, should we do this everywhere a record batch reader is created an 
consumed within a function? For example:
   
   
https://github.com/apache/arrow/blob/37a79659f82a7dbe0a55858e59fa5eaa380a266f/r/R/dplyr.R#L297
   
   
https://github.com/apache/arrow/blob/37a79659f82a7dbe0a55858e59fa5eaa380a266f/r/R/python.R#L111



##########
r/R/record-batch-reader.R:
##########
@@ -255,6 +259,8 @@ as_record_batch_reader.arrow_dplyr_query <- function(x, 
...) {
   # See query-engine.R for ExecPlan/Nodes
   plan <- ExecPlan$create()
   final_node <- plan$Build(x)
+  on.exit(plan$.unsafe_delete())

Review Comment:
   Should we do the same everywhere else a plan is created? For example:
   
   
https://github.com/apache/arrow/blob/37a79659f82a7dbe0a55858e59fa5eaa380a266f/r/R/dataset-write.R#L153
   
   
https://github.com/apache/arrow/blob/37a79659f82a7dbe0a55858e59fa5eaa380a266f/r/R/query-engine.R#L381



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