Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
edalfon committed Jan 3, 2022
0 parents commit 12d11e4
Show file tree
Hide file tree
Showing 15 changed files with 1,112 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
^_targets\.R$
^\.Rprofile$
^report$
^report/_bookdown\.yml$
^report/_output\.yml$
^report/index\.Rmd$
^report/chapter1\.Rmd$
^report/chapter2\.Rmd$
^.*\.Rproj$
^\.Rproj\.user$
36 changes: 36 additions & 0 deletions .Rprofile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
if (file.exists("~/.Rprofile")) source("~/.Rprofile")

if(!requireNamespace("pacman", quietly = TRUE)) {
utils::install.packages("pacman")
}

pacman::p_load(
magrittr,
dplyr,
tidyr,
ggplot2,

duckdb,
arrow,
DBI,
odbc,

targets,
tarchetypes
)

library(conflicted)
conflicted::conflict_prefer("filter", "dplyr", quiet = TRUE)
conflicted::conflict_prefer("select", "dplyr", quiet = TRUE)
conflicted::conflict_prefer("expand", "tidyr", quiet = TRUE)

# make all fns available to {targets} (and interactively, via load_all)
if (rlang::is_interactive()) {
devtools::load_all()
# delayedAssign("duckdb_con", connect_duckdb(), assign.env = globalenv())
# delayedAssign("pg_con", connect_pg(), assign.env = globalenv())
} else {
invisible(
lapply(list.files("./R", full.names = TRUE), source, encoding = "UTF-8")
)
}
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
_targets
playground*
.Rdata
.httr-oauth
.DS_Store
37 changes: 37 additions & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Package: backend_compare
Title: A {targets} pipeline to play around with {arrow} and {duckdb}
Version: 0.0.0.9000
Authors@R:
person("Eduardo", "Alfonso-Sierra", , "[email protected]",
role = c("aut", "cre", "cph"),
comment = c(ORCID = "0000-0001-6430-5135"))
Description: Not really a package. Just a bunch of simple data wrangling steps
to play around with {arrow} and {duckdb}, and compare it with
the same thing in PostgreSQL
License: MIT + file LICENSE
Encoding: UTF-8
Language: en
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.2
Imports:
targets,
tarchetypes,
visNetwork,
duckdb,
arrow,
conflicted,
dplyr,
ggplot2,
magrittr,
pacman,
rlang,
tidyr,
utils,
DBI,
odbc,
fs,
bench,
efun,
glue,
here,
purrr
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by roxygen2: do not edit by hand

3 changes: 3 additions & 0 deletions R/aggregate.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#backend
#interface

44 changes: 44 additions & 0 deletions R/connect.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@

connect_duckdb <- function(read_only = FALSE) {

print("CONNECTING DuckDB ...")

fs::dir_create(fs::path_dir("/backend/duckdb/backend.duckdb"))
DBI::dbConnect(
drv = duckdb::duckdb(),
dbdir = "/backend/duckdb/backend.duckdb",
read_only = read_only
)
}

connect_pg <- function() {

DBI::dbConnect(
odbc::odbc(),
driver = "PostgreSQL Unicode(x64)",
database = "backend",
uid = "postgres",
pwd = "postgres",
host = NULL, #,"localhost",
port = 5432,
encoding = "WINDOWS-1252",
bigint = "numeric"
)
}

connect_arrow <- function(arrow_tbl) {

arrow::open_dataset(
sources = arrow_tbl,
format = "arrow"
)
}

connect_parquet <- function(parquet_tbl) {

arrow::open_dataset(
sources = parquet_tbl,
format = "parquet"
)
}

Loading

0 comments on commit 12d11e4

Please sign in to comment.