bcgov / bcdata

An R package for searching & retrieving data from the B.C. Data Catalogue
https://bcgov.github.io/bcdata
Apache License 2.0
81 stars 12 forks source link

Enable autocomplete of column names in select.bcdc_promise and filter.bcdc_promise #113

Open ateucher opened 4 years ago

boshek commented 4 years ago

I don't think is possible yet. If we take dbplyr as a comparable I think you have to have some part the table in memory first. Take this dbplyr example:

library(dplyr)
library(dbplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), dbname = ":memory:")

copy_to(con, nycflights13::flights, "flights",
        temporary = FALSE, 
        indexes = list(
          c("year", "month", "day"), 
          "carrier", 
          "tailnum",
          "dest"
        )
)

## Auto-completes
flights_db %>% 
  select()

## Doesn't auto-complete
tbl(con, "flights") %>% 
  select()

Similarly with BC data:

library(bcdata)

air <- bcdc_get_data('bc-airports', resource = '4d0377d9-e8a1-429b-824f-0ce8f363512c')

## Auto-completes
air %>% 
  select()

## Doesn't auto-complete
bcdc_get_data('bc-airports', resource = '4d0377d9-e8a1-429b-824f-0ce8f363512c') %>% 
  select()

I would suggest that we make some modification to a vignette explicitly telling users how to take advantage of autocomplete then close the issue? Based on this the path allows for auto-completion should be our suggested workflow.

ateucher commented 4 years ago

for bcdc_query_geodata I think it might be possible if the object passed along is a zero-row df so the column names are available to the next function. I think we talked about that?

boshek commented 4 years ago

🤦‍♂ Of course this needs to be bcdc_query_geodata. I do remember that now although I'm not totally sure how to implement it.