paleolimbot removed a comment on pull request #12564:
URL: https://github.com/apache/arrow/pull/12564#issuecomment-1059487075


   Whee...this works! (Although until ARROW-15849 is merged it's necessary to 
copy the arrow/engine/substrait/ headers manually...). It currently just prints 
the output...before this is merged I think it would be nice to return a `Table` 
to help us test output.
   
   ``` r
   # remotes::install_github("apache/arrow/r#12564")
   # remotes::install_github("voltrondata/substrait-r")
   library(arrow, warn.conflicts = FALSE)
   library(substrait)
   
   # currently works via the ReadRel object (not an Arrow source node),
   # so we need a parquet file to work with
   temp_parquet_file <- tempfile()
   write_parquet(mtcars, temp_parquet_file)
   
   plan <- substrait$Plan$create(
     relations = list(
       substrait$PlanRel$create(
         rel = substrait$Rel$create(
           read = substrait$ReadRel$create(
             base_schema = as_substrait(mtcars, "substrait.NamedStruct"),
             local_files = substrait$ReadRel$LocalFiles$create(
               items = list(
                 substrait$ReadRel$LocalFiles$FileOrFiles$create(
                   uri_file = sprintf("file://%s", temp_parquet_file),
                   format = 
substrait$ReadRel$LocalFiles$FileOrFiles$FileFormat$FILE_FORMAT_PARQUET
                 )
               )
             )
           )
         )
       )
     )
   )
   
   arrow:::do_exec_plan_substrait(as.raw(plan))
   #> <tag: 0 rows: 32>
   #> ExecBatch
   #>     # Rows: 32
   #>     0: 
Array[21,21,22.8,21.4,18.7,18.1,14.3,24.4,22.8,19.2,...,15.2,13.3,19.2,27.3,26,30.4,15.8,19.7,15,21.4]
   #>     1: Array[6,6,4,6,8,6,8,4,4,6,...,8,8,8,4,4,4,8,6,8,4]
   #>     2: 
Array[160,160,108,258,360,225,360,146.7,140.8,167.6,...,304,350,400,79,120.3,95.1,351,145,301,121]
   #>     3: 
Array[110,110,93,110,175,105,245,62,95,123,...,150,245,175,66,91,113,264,175,335,109]
   #>     4: 
Array[3.9,3.9,3.85,3.08,3.15,2.76,3.21,3.69,3.92,3.92,...,3.15,3.73,3.08,4.08,4.43,3.77,4.22,3.62,3.54,4.11]
   #>     5: 
Array[2.62,2.875,2.32,3.215,3.44,3.46,3.57,3.19,3.15,3.44,...,3.435,3.84,3.845,1.935,2.14,1.513,3.17,2.77,3.57,2.78]
   #>     6: 
Array[16.46,17.02,18.61,19.44,17.02,20.22,15.84,20,22.9,18.3,...,17.3,15.41,17.05,18.9,16.7,16.9,14.5,15.5,14.6,18.6]
   #>     7: Array[0,0,1,1,0,1,0,1,1,1,...,0,0,0,1,0,1,0,0,0,1]
   #>     8: Array[1,1,1,0,0,0,0,0,0,0,...,0,0,0,1,1,1,1,1,1,1]
   #>     9: Array[4,4,4,3,3,3,3,4,4,4,...,3,3,3,4,5,5,5,5,5,4]
   #>     10: Array[4,4,1,1,2,1,4,2,2,4,...,2,4,2,1,2,2,4,6,8,2]
   #>     11: Scalar[0]
   #>     12: Scalar[0]
   #>     13: Scalar[true]
   #> 
   #> <tag: 0 finished>
   ```
   
   <sup>Created on 2022-03-04 by the [reprex 
package](https://reprex.tidyverse.org) (v2.0.1)</sup>


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