4 ms·
Does the R code, for eg., SQLite, actually build an SQL query? This just looks like a tidyverse library comparison. I'd expect a benchmark using their own libs
by mjburgess 5y ago
Does the R code, for eg., SQLite, actually build an SQL query?
This just looks like a tidyverse library comparison. I'd expect a benchmark using their own libs, rather than assuming tidyverse will have an optimal way of querying them.
- wodenokoto 5y agoYes, it does. The ´collect()´ function at the end, is responsible for executing the previous chain in the database. The fact that ´tbl´ in the beginning is called with a connection, ensures that all the following functions don't execute on a dataframe, but instead builds up a query. R, kinda like Julia, executes different versions of a function, depending on the type of the first parameter. From an API point of view, I think it is absolutely ingenious!
- chrisjc 5y agoIn other words, it creates a "push-down" to SQLite? So that we can appreciate your point about the elegance of the API, how would you do the opposite to allow execution to take place on the data-frame?
- phillc73 5y agoThere's an R package for that! Well, multiple really. The `sqldf`[1] package has been around for a while, there's `tidyquery`[2] and also one I wrote called `duckdf`[3]. All three support writing SQL queries to directly access dataframes. [1] https://github.com/ggrothendieck/sqldf https://github.com/ggrothendieck/sqldf [2] https://github.com/ianmcook/tidyquery https://github.com/ianmcook/tidyquery [3] https://github.com/phillc73/duckdf https://github.com/phillc73/duckdf
- chrisjc 5y agoNot exactly what I was asking, but still some pretty awesome links/projects. Thanks for the links. I'm pretty sure that I'll be getting my hands dirty with R eventually.