Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upload test datasets #61

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/testthat/test-aaa-connect.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test_that("can connect to Impala using RJDBC", {
unzip(jdbc_zip, exdir = jdbc_jars)
impala_classpath <- list.files(path = jdbc_jars, pattern = "\\.jar$", full.names = TRUE)
rJava::.jinit(classpath = impala_classpath)
drv <- RJDBC::JDBC("com.cloudera.impala.jdbc41.Driver", impala_classpath, "`")
drv <- RJDBC::JDBC("com.cloudera.impala.jdbc.Driver", impala_classpath, "`")
jdbc_conn_str <- paste0("jdbc:impala://", jdbc_host, ":", jdbc_port)
impala <<- implyr::src_impala(drv, jdbc_conn_str, jdbc_user, jdbc_pass)
TRUE
Expand Down
59 changes: 59 additions & 0 deletions tests/upload-datasets.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
## This script uploads some of datasets required to pass package tests.
## Also required for tests are Lahman::batting and nycflights13::flights,
## however they are too large to consistently upload with copy_to.

library(nycflights13)
library(implyr)

## Script expects object `impala` (created by `src_impala`)

## If using Cloudera Impala JDBC drivers, turn off OptimizedInsert
## (example connection string):
## "jdbc:impala://127.0.0.1:21050;OptimizedInsert=0"
## This parameter pads strings to uniform size and will make some of the tests fail.

options(implyr.copy_to_size_limit = 10000000)


upload_datasets <- function(impala) {
copy_to(
impala,
airlines,
types=c("STRING", "STRING"),
temporary = FALSE
)

copy_to(
impala,
mtcars,
temporary = FALSE
)

copy_to(
impala,
data.frame(col1=c(1), col2=c("a")),
"one_row",
temporary = FALSE
)

copy_to(
impala,
iris %>% select(
species=Species,
sepal_length=Sepal.Length
),
"iris",
temporary = FALSE
)

copy_to(
impala,
data.frame(
language="Spanish",
test="El pingüino Wenceslao hizo kilómetros bajo exhaustiva lluvia y frío, añoraba a su querido cachorro"
),
"unicode_test",
temporary = FALSE,
types=c("STRING", "STRING")
)
}