This is an automated email from the ASF dual-hosted git repository.

lidavidm pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-adbc.git


The following commit(s) were added to refs/heads/main by this push:
     new aa1990bb1 docs(r): Update READMEs for R packages (#1707)
aa1990bb1 is described below

commit aa1990bb155f053b8ed4e20b49b04421a0c8a205
Author: Dewey Dunnington <[email protected]>
AuthorDate: Wed Apr 3 17:26:53 2024 -0300

    docs(r): Update READMEs for R packages (#1707)
    
    Just a pass through all the READMEs to generally align them with how
    people are most likely to interact with them at first glance!
---
 r/adbcdrivermanager/README.Rmd | 29 +++++++++--------------------
 r/adbcdrivermanager/README.md  | 38 ++++++++++++++------------------------
 r/adbcpostgresql/README.Rmd    | 10 +++-------
 r/adbcpostgresql/README.md     | 18 +++++++-----------
 r/adbcsqlite/README.Rmd        | 22 +++++++++-------------
 r/adbcsqlite/README.md         | 28 ++++++++++++----------------
 6 files changed, 54 insertions(+), 91 deletions(-)

diff --git a/r/adbcdrivermanager/README.Rmd b/r/adbcdrivermanager/README.Rmd
index 439268cb8..4384c8b4a 100644
--- a/r/adbcdrivermanager/README.Rmd
+++ b/r/adbcdrivermanager/README.Rmd
@@ -70,33 +70,22 @@ library(adbcdrivermanager)
 
 # Get a reference to a database using a driver. The adbcdrivermanager package
 # contains a few drivers useful for illustration and testing.
-db <- adbc_database_init(adbc_driver_monkey())
+db <- adbc_database_init(adbcsqlite::adbcsqlite())
 
 # Open a new connection to a database
 con <- adbc_connection_init(db)
 
-# Initialize a new statement from a connection
-stmt <- adbc_statement_init(con)
+# Write a table
+nycflights13::flights |> write_adbc(con, "flights")
 
-# The monkey driver allows you to specify the data for a query
-# in advance for testing purposes
-adbc_statement_bind_stream(stmt, nycflights13::flights)
-
-# Set the query
-adbc_statement_set_sql_query(stmt, "SELECT * FROM flights")
-
-# Start executing the query. Results in ADBC are ArrowArrayStream objects,
-# which can be materialized using as.data.frame(), as_tibble(),
-# or converted to an arrow::RecordBatchReader using
-# arrow::as_record_batch_reader()
-stream <- nanoarrow::nanoarrow_allocate_array_stream()
-adbc_statement_execute_query(stmt, stream)
-
-# Materialize the whole query as a tibble
-tibble::as_tibble(stream)
+# Issue a query
+con |>
+  read_adbc("SELECT * from flights") |>
+  tibble::as_tibble()
 
 # Clean up!
-adbc_statement_release(stmt)
 adbc_connection_release(con)
 adbc_database_release(db)
 ```
+
+One can also interact with the driver manager at a lower level using 
`adbc_connection_*()` and `adbc_statement_*()` functions (see reference 
documentation for details).
diff --git a/r/adbcdrivermanager/README.md b/r/adbcdrivermanager/README.md
index 231fc8a48..387f64c2f 100644
--- a/r/adbcdrivermanager/README.md
+++ b/r/adbcdrivermanager/README.md
@@ -62,34 +62,21 @@ library(adbcdrivermanager)
 
 # Get a reference to a database using a driver. The adbcdrivermanager package
 # contains a few drivers useful for illustration and testing.
-db <- adbc_database_init(adbc_driver_monkey())
+db <- adbc_database_init(adbcsqlite::adbcsqlite())
 
 # Open a new connection to a database
 con <- adbc_connection_init(db)
 
-# Initialize a new statement from a connection
-stmt <- adbc_statement_init(con)
+# Write a table
+nycflights13::flights |> write_adbc(con, "flights")
 
-# The monkey driver allows you to specify the data for a query
-# in advance for testing purposes
-adbc_statement_bind_stream(stmt, nycflights13::flights)
-
-# Set the query
-adbc_statement_set_sql_query(stmt, "SELECT * FROM flights")
-
-# Start executing the query. Results in ADBC are ArrowArrayStream objects,
-# which can be materialized using as.data.frame(), as_tibble(),
-# or converted to an arrow::RecordBatchReader using
-# arrow::as_record_batch_reader()
-stream <- nanoarrow::nanoarrow_allocate_array_stream()
-adbc_statement_execute_query(stmt, stream)
-#> [1] -1
-
-# Materialize the whole query as a tibble
-tibble::as_tibble(stream)
+# Issue a query
+con |>
+  read_adbc("SELECT * from flights") |>
+  tibble::as_tibble()
 #> # A tibble: 336,776 × 19
 #>     year month   day dep_time sched_dep_time dep_delay arr_time 
sched_arr_time
-#>    <int> <int> <int>    <int>          <int>     <dbl>    <int>          
<int>
+#>    <dbl> <dbl> <dbl>    <dbl>          <dbl>     <dbl>    <dbl>          
<dbl>
 #>  1  2013     1     1      517            515         2      830            
819
 #>  2  2013     1     1      533            529         4      850            
830
 #>  3  2013     1     1      542            540         2      923            
850
@@ -101,12 +88,15 @@ tibble::as_tibble(stream)
 #>  9  2013     1     1      557            600        -3      838            
846
 #> 10  2013     1     1      558            600        -2      753            
745
 #> # ℹ 336,766 more rows
-#> # ℹ 11 more variables: arr_delay <dbl>, carrier <chr>, flight <int>,
+#> # ℹ 11 more variables: arr_delay <dbl>, carrier <chr>, flight <dbl>,
 #> #   tailnum <chr>, origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>,
-#> #   hour <dbl>, minute <dbl>, time_hour <dttm>
+#> #   hour <dbl>, minute <dbl>, time_hour <chr>
 
 # Clean up!
-adbc_statement_release(stmt)
 adbc_connection_release(con)
 adbc_database_release(db)
 ```
+
+One can also interact with the driver manager at a lower level using
+`adbc_connection_*()` and `adbc_statement_*()` functions (see reference
+documentation for details).
diff --git a/r/adbcpostgresql/README.Rmd b/r/adbcpostgresql/README.Rmd
index cc68887b2..b94915c16 100644
--- a/r/adbcpostgresql/README.Rmd
+++ b/r/adbcpostgresql/README.Rmd
@@ -73,20 +73,16 @@ db <- adbc_database_init(adbcpostgresql::adbcpostgresql(), 
uri = uri)
 con <- adbc_connection_init(db)
 
 # Write a table
-flights <- head(nycflights13::flights, 100)
-# (timestamp not supported yet)
-flights$time_hour <- NULL
-flights |>
-  write_adbc(con, "flights")
+nycflights13::flights |> write_adbc(con, "flights")
 
-# Query it
+# Issue a query
 con |>
   read_adbc("SELECT * from flights") |>
   tibble::as_tibble()
 ```
 
 ```{r example-clean-up}
-# Clean up
+# Clean up!
 con |>
   execute_adbc("DROP TABLE flights")
 adbc_connection_release(con)
diff --git a/r/adbcpostgresql/README.md b/r/adbcpostgresql/README.md
index b902cc8c1..96112aada 100644
--- a/r/adbcpostgresql/README.md
+++ b/r/adbcpostgresql/README.md
@@ -64,17 +64,13 @@ db <- adbc_database_init(adbcpostgresql::adbcpostgresql(), 
uri = uri)
 con <- adbc_connection_init(db)
 
 # Write a table
-flights <- head(nycflights13::flights, 100)
-# (timestamp not supported yet)
-flights$time_hour <- NULL
-flights |>
-  write_adbc(con, "flights")
+nycflights13::flights |> write_adbc(con, "flights")
 
-# Query it
+# Issue a query
 con |>
   read_adbc("SELECT * from flights") |>
   tibble::as_tibble()
-#> # A tibble: 100 × 18
+#> # A tibble: 336,776 × 19
 #>     year month   day dep_time sched_dep_time dep_delay arr_time 
sched_arr_time
 #>    <int> <int> <int>    <int>          <int>     <dbl>    <int>          
<int>
 #>  1  2013     1     1      517            515         2      830            
819
@@ -87,14 +83,14 @@ con |>
 #>  8  2013     1     1      557            600        -3      709            
723
 #>  9  2013     1     1      557            600        -3      838            
846
 #> 10  2013     1     1      558            600        -2      753            
745
-#> # ℹ 90 more rows
-#> # ℹ 10 more variables: arr_delay <dbl>, carrier <chr>, flight <int>,
+#> # ℹ 336,766 more rows
+#> # ℹ 11 more variables: arr_delay <dbl>, carrier <chr>, flight <int>,
 #> #   tailnum <chr>, origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>,
-#> #   hour <dbl>, minute <dbl>
+#> #   hour <dbl>, minute <dbl>, time_hour <dttm>
 ```
 
 ``` r
-# Clean up
+# Clean up!
 con |>
   execute_adbc("DROP TABLE flights")
 adbc_connection_release(con)
diff --git a/r/adbcsqlite/README.Rmd b/r/adbcsqlite/README.Rmd
index ffcaee358..950e97e46 100644
--- a/r/adbcsqlite/README.Rmd
+++ b/r/adbcsqlite/README.Rmd
@@ -67,27 +67,23 @@ This is a basic example which shows you how to solve a 
common problem:
 ```{r example}
 library(adbcdrivermanager)
 
-# Use the driver manager to connect to a database
-db <- adbc_database_init(adbcsqlite::adbcsqlite(), uri = ":memory:")
+# Open a new connection to a database
+db <- adbc_database_init(
+  adbcsqlite::adbcsqlite(),
+  uri = ":memory:"
+)
+
 con <- adbc_connection_init(db)
 
 # Write a table
-flights <- nycflights13::flights
-# (timestamp not supported yet)
-flights$time_hour <- NULL
-flights |>
-  write_adbc(con, "flights")
+nycflights13::flights |> write_adbc(con, "flights")
 
-# Query it
+# Issue a query
 con |>
   read_adbc("SELECT * from flights") |>
   tibble::as_tibble()
-```
 
-```{r}
-# Clean up
-con |>
-  execute_adbc("DROP TABLE flights")
+# Clean up!
 adbc_connection_release(con)
 adbc_database_release(db)
 ```
diff --git a/r/adbcsqlite/README.md b/r/adbcsqlite/README.md
index f04f07cbe..9fc8e5d24 100644
--- a/r/adbcsqlite/README.md
+++ b/r/adbcsqlite/README.md
@@ -58,22 +58,22 @@ This is a basic example which shows you how to solve a 
common problem:
 ``` r
 library(adbcdrivermanager)
 
-# Use the driver manager to connect to a database
-db <- adbc_database_init(adbcsqlite::adbcsqlite(), uri = ":memory:")
+# Open a new connection to a database
+db <- adbc_database_init(
+  adbcsqlite::adbcsqlite(),
+  uri = ":memory:"
+)
+
 con <- adbc_connection_init(db)
 
 # Write a table
-flights <- nycflights13::flights
-# (timestamp not supported yet)
-flights$time_hour <- NULL
-flights |>
-  write_adbc(con, "flights")
+nycflights13::flights |> write_adbc(con, "flights")
 
-# Query it
+# Issue a query
 con |>
   read_adbc("SELECT * from flights") |>
   tibble::as_tibble()
-#> # A tibble: 336,776 × 18
+#> # A tibble: 336,776 × 19
 #>     year month   day dep_time sched_dep_time dep_delay arr_time 
sched_arr_time
 #>    <dbl> <dbl> <dbl>    <dbl>          <dbl>     <dbl>    <dbl>          
<dbl>
 #>  1  2013     1     1      517            515         2      830            
819
@@ -87,15 +87,11 @@ con |>
 #>  9  2013     1     1      557            600        -3      838            
846
 #> 10  2013     1     1      558            600        -2      753            
745
 #> # ℹ 336,766 more rows
-#> # ℹ 10 more variables: arr_delay <dbl>, carrier <chr>, flight <dbl>,
+#> # ℹ 11 more variables: arr_delay <dbl>, carrier <chr>, flight <dbl>,
 #> #   tailnum <chr>, origin <chr>, dest <chr>, air_time <dbl>, distance <dbl>,
-#> #   hour <dbl>, minute <dbl>
-```
+#> #   hour <dbl>, minute <dbl>, time_hour <chr>
 
-``` r
-# Clean up
-con |>
-  execute_adbc("DROP TABLE flights")
+# Clean up!
 adbc_connection_release(con)
 adbc_database_release(db)
 ```

Reply via email to