diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 1b799ad0c..42a8209a9 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -203,7 +203,7 @@ jobs: - {os: ubuntu-20.04, r: 'release', test-src: 'test-mssql', covr: false, desc: 'SQL Server without covr' } - {os: ubuntu-22.04, r: 'release', test-src: 'test-postgres', covr: true, desc: 'Postgres with covr' } - {os: ubuntu-22.04, r: 'release', test-src: 'test-maria', covr: true, desc: 'MariaDB with covr' } - - {os: ubuntu-22.04, r: 'release', test-src: 'test-mysql-maria', covr: true, desc: 'MySQL with covr' } + - {os: ubuntu-22.04, r: 'release', test-src: 'test-mysql', covr: true, desc: 'MySQL with covr' } - {os: ubuntu-22.04, r: 'release', test-src: 'test-duckdb', covr: true, desc: 'DuckDB with covr' } - {os: ubuntu-22.04, r: 'release', test-src: 'test-sqlite', covr: true, desc: 'SQLite with covr' } # End custom: matrix elements diff --git a/Makefile b/Makefile index 07adf2d81..08529cbcb 100644 --- a/Makefile +++ b/Makefile @@ -3,19 +3,19 @@ all: qtest # Quiet tests # Run with make -j $(nproc) -O # or with pmake -qtest: qtest-df qtest-sqlite qtest-postgres qtest-mssql qtest-duckdb qtest-maria +qtest: qtest-df qtest-sqlite qtest-postgres qtest-mssql qtest-duckdb qtest-maria qtest-mysql # Progress tests -test: test-df test-sqlite test-postgres test-mssql test-duckdb test-maria +test: test-df test-sqlite test-postgres test-mssql test-duckdb test-maria test-mysql # Testing with lazytest -ltest: ltest-df ltest-sqlite ltest-postgres ltest-mssql ltest-duckdb ltest-maria +ltest: ltest-df ltest-sqlite ltest-postgres ltest-mssql ltest-duckdb ltest-maria ltest-mysql # Silent testing -stest: stest-df stest-sqlite stest-postgres stest-mssql stest-duckdb stest-maria +stest: stest-df stest-sqlite stest-postgres stest-mssql stest-duckdb stest-maria stest-mysql # Connectivity tests -connect: connect-sqlite connect-postgres connect-mssql connect-duckdb connect-maria +connect: connect-sqlite connect-postgres connect-mssql connect-duckdb connect-maria connect-mysql qtest-%: DM_TEST_SRC=$@ time R -q -e 'options("crayon.enabled" = TRUE); Sys.setenv(TESTTHAT_PARALLEL = FALSE); testthat::test_local(filter = "${DM_TEST_FILTER}")' @@ -32,10 +32,20 @@ ltest-%: connect-%: DM_TEST_SRC=$@ R -q -e 'suppressMessages(pkgload::load_all()); my_test_con()' +db-init-maria: + while ! R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_maria(root = TRUE)$$con, "GRANT ALL ON *.* TO '"'"'compose'"'"'@'"'"'%'"'"';"); DBI::dbExecute(test_src_maria()$$con, "FLUSH PRIVILEGES")'; do sleep 1; done + +db-init-mysql: + while ! R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_mysql(root = TRUE)$$con, "GRANT ALL ON *.* TO '"'"'compose'"'"'@'"'"'%'"'"';"); DBI::dbExecute(test_src_mysql()$$con, "FLUSH PRIVILEGES")'; do sleep 1; done + +db-init-mssql: + while ! R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_mssql(FALSE)$$con, "CREATE DATABASE test")'; do sleep 1; done + +db-init: db-init-maria db-init-mysql db-init-mssql + db-start: - docker-compose up -d --force-recreate - R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_maria(root = TRUE)$$con, "GRANT ALL ON *.* TO '"'"'compose'"'"'@'"'"'%'"'"';"); DBI::dbExecute(test_src_maria()$$con, "FLUSH PRIVILEGES")' - R -q -e 'suppressMessages(pkgload::load_all()); DBI::dbExecute(test_src_mssql(FALSE)$$con, "CREATE DATABASE test")' + docker-compose up -d --force-recreate --wait + $(MAKE) db-init db-restart: docker-compose up -d diff --git a/docker-compose.yml b/docker-compose.yml index 30b039d1b..5b4443533 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,10 +6,11 @@ volumes: driver: local maria-db: driver: local + mysql-db: + driver: local services: # https://www.beekeeperstudio.io/blog/how-to-use-mariadb-with-docker mysql: - # FIXME: Still need to add Makefile rules to provision MySQL database container_name: mysql image: mysql environment: @@ -17,6 +18,8 @@ services: MYSQL_DATABASE: test MYSQL_USER: compose MYSQL_PASSWORD: "YourStrong!Passw0rd" + volumes: + - mysql-db:/var/lib/mysql ports: - "3307:3306" maria: diff --git a/tests/testthat/_snaps/add-tbl.md b/tests/testthat/_snaps/add-tbl.md index 8c7f30499..d88e0978b 100644 --- a/tests/testthat/_snaps/add-tbl.md +++ b/tests/testthat/_snaps/add-tbl.md @@ -7,87 +7,12 @@ `dm_add_tbl()` was deprecated in dm 1.0.0. i Please use `dm()` instead. i Use `.name_repair = "unique"` if necessary. - Error in `abort_need_unique_names()`: - ! Each new table needs to have a unique name. Duplicate new name(s): `tf_1`. - ---- - - Code - dm_add_tbl(dm_for_flatten(), res_flat = result_from_flatten()) %>% dm_paste( - options = c("select", "keys")) - Condition - Warning: - `dm_add_tbl()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - i Use `.name_repair = "unique"` if necessary. - Message - dm::dm( - fact, - dim_1, - dim_2, - dim_3, - dim_4, - res_flat, - ) %>% - dm::dm_select(fact, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2, dim_2_pk, something) %>% - dm::dm_select(dim_3, dim_3_pk, something) %>% - dm::dm_select(dim_4, dim_4_pk, something) %>% - dm::dm_select(res_flat, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, fact.something, dim_1.something, dim_2.something, dim_3.something, dim_4.something) %>% - dm::dm_add_pk(dim_1, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2, dim_2_pk) %>% - dm::dm_add_pk(dim_3, dim_3_pk) %>% - dm::dm_add_pk(dim_4, dim_4_pk) %>% - dm::dm_add_fk(fact, c(dim_1_key_1, dim_1_key_2), dim_1) %>% - dm::dm_add_fk(fact, dim_2_key, dim_2) %>% - dm::dm_add_fk(fact, dim_3_key, dim_3) %>% - dm::dm_add_fk(fact, dim_4_key, dim_4) - -# dm_rm_tbl() snapshot - - Code - dm_rm_tbl(dm_for_flatten(), dim_1) %>% dm_paste(options = c("select", "keys")) - Condition - Warning: - `dm_rm_tbl()` was deprecated in dm 1.0.0. - i Please use `dm_select_tbl()` instead. - Message - dm::dm( - fact, - dim_2, - dim_3, - dim_4, - ) %>% - dm::dm_select(fact, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_2, dim_2_pk, something) %>% - dm::dm_select(dim_3, dim_3_pk, something) %>% - dm::dm_select(dim_4, dim_4_pk, something) %>% - dm::dm_add_pk(dim_2, dim_2_pk) %>% - dm::dm_add_pk(dim_3, dim_3_pk) %>% - dm::dm_add_pk(dim_4, dim_4_pk) %>% - dm::dm_add_fk(fact, dim_2_key, dim_2) %>% - dm::dm_add_fk(fact, dim_3_key, dim_3) %>% - dm::dm_add_fk(fact, dim_4_key, dim_4) - Code - dm_rm_tbl(dm_for_flatten(), fact) %>% dm_paste(options = c("select", "keys")) - Condition - Warning: - `dm_rm_tbl()` was deprecated in dm 1.0.0. - i Please use `dm_select_tbl()` instead. - Message - dm::dm( - dim_1, - dim_2, - dim_3, - dim_4, - ) %>% - dm::dm_select(dim_1, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2, dim_2_pk, something) %>% - dm::dm_select(dim_3, dim_3_pk, something) %>% - dm::dm_select(dim_4, dim_4_pk, something) %>% - dm::dm_add_pk(dim_1, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2, dim_2_pk) %>% - dm::dm_add_pk(dim_3, dim_3_pk) %>% - dm::dm_add_pk(dim_4, dim_4_pk) + Warning in `dm_for_filter()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) diff --git a/tests/testthat/_snaps/bind.md b/tests/testthat/_snaps/bind.md index 66d3bd84e..54fc73419 100644 --- a/tests/testthat/_snaps/bind.md +++ b/tests/testthat/_snaps/bind.md @@ -6,15 +6,14 @@ Warning: `dm_bind()` was deprecated in dm 1.0.0. i Please use `dm()` instead. - Error in `dm_bind()`: - ! Names must be unique. - x These names are duplicated: - * "tf_1" at locations 1 and 12. - * "tf_2" at locations 2 and 13. - * "tf_3" at locations 3 and 14. - * "tf_4" at locations 4 and 15. - * "tf_5" at locations 5 and 16. - * ... + Warning in `dm_for_filter()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) # test error output for src mismatches @@ -25,263 +24,12 @@ Warning: `dm_bind()` was deprecated in dm 1.0.0. i Please use `dm()` instead. + Warning in `dm_for_flatten()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation Output - All `dm` objects need to share the same `src`. - -# output - - Code - dm_bind() - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Output - dm() - Code - dm_bind(empty_dm()) - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Output - dm() - Code - dm_bind(dm_for_filter()) %>% collect() - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Output - -- Metadata -------------------------------------------------------------------- - Tables: `tf_1`, `tf_2`, `tf_3`, `tf_4`, `tf_5`, `tf_6` - Columns: 20 - Primary keys: 6 - Foreign keys: 5 - Code - dm_bind(dm_for_filter(), dm_for_flatten(), dm_for_filter(), repair = "unique", - quiet = TRUE) %>% collect() - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Output - -- Metadata -------------------------------------------------------------------- - Tables: `tf_1...1`, `tf_2...2`, `tf_3...3`, `tf_4...4`, `tf_5...5`, ... (17 total) - Columns: 56 - Primary keys: 16 - Foreign keys: 14 - Code - writeLines(conditionMessage(expect_error(dm_bind(dm_for_filter(), - dm_for_flatten(), dm_for_filter())))) - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Output - Names must be unique. - x These names are duplicated: - * "tf_1" at locations 1 and 12. - * "tf_2" at locations 2 and 13. - * "tf_3" at locations 3 and 14. - * "tf_4" at locations 4 and 15. - * "tf_5" at locations 5 and 16. - * ... - ---- - - Code - dm_bind(dm_for_filter(), dm_for_flatten(), dm_for_filter(), repair = "unique") %>% - collect() - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Message - New names: - * `tf_1` -> `tf_1...1` - * `tf_2` -> `tf_2...2` - * `tf_3` -> `tf_3...3` - * `tf_4` -> `tf_4...4` - * `tf_5` -> `tf_5...5` - * `tf_6` -> `tf_6...6` - * `tf_1` -> `tf_1...12` - * `tf_2` -> `tf_2...13` - * `tf_3` -> `tf_3...14` - * `tf_4` -> `tf_4...15` - * `tf_5` -> `tf_5...16` - * `tf_6` -> `tf_6...17` - Output - -- Metadata -------------------------------------------------------------------- - Tables: `tf_1...1`, `tf_2...2`, `tf_3...3`, `tf_4...4`, `tf_5...5`, ... (17 total) - Columns: 56 - Primary keys: 16 - Foreign keys: 14 - -# output for compound keys - - Code - dm_bind(dm_for_filter(), dm_for_flatten()) %>% dm_paste(options = c("select", - "keys")) - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Message - dm::dm( - tf_1, - tf_2, - tf_3, - tf_4, - tf_5, - tf_6, - fact, - dim_1, - dim_2, - dim_3, - dim_4, - ) %>% - dm::dm_select(tf_1, a, b) %>% - dm::dm_select(tf_2, c, d, e, e1) %>% - dm::dm_select(tf_3, f, f1, g) %>% - dm::dm_select(tf_4, h, i, j, j1) %>% - dm::dm_select(tf_5, ww, k, l, m) %>% - dm::dm_select(tf_6, zz, n, o) %>% - dm::dm_select(fact, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2, dim_2_pk, something) %>% - dm::dm_select(dim_3, dim_3_pk, something) %>% - dm::dm_select(dim_4, dim_4_pk, something) %>% - dm::dm_add_pk(tf_1, a, autoincrement = TRUE) %>% - dm::dm_add_pk(tf_2, c) %>% - dm::dm_add_pk(tf_3, c(f, f1)) %>% - dm::dm_add_pk(tf_4, h) %>% - dm::dm_add_pk(tf_5, k) %>% - dm::dm_add_pk(tf_6, o) %>% - dm::dm_add_pk(dim_1, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2, dim_2_pk) %>% - dm::dm_add_pk(dim_3, dim_3_pk) %>% - dm::dm_add_pk(dim_4, dim_4_pk) %>% - dm::dm_add_uk(tf_3, g) %>% - dm::dm_add_fk(tf_2, d, tf_1) %>% - dm::dm_add_fk(tf_2, c(e, e1), tf_3) %>% - dm::dm_add_fk(tf_4, c(j, j1), tf_3) %>% - dm::dm_add_fk(tf_5, l, tf_4, on_delete = "cascade") %>% - dm::dm_add_fk(tf_5, m, tf_6, n) %>% - dm::dm_add_fk(fact, c(dim_1_key_1, dim_1_key_2), dim_1) %>% - dm::dm_add_fk(fact, dim_2_key, dim_2) %>% - dm::dm_add_fk(fact, dim_3_key, dim_3) %>% - dm::dm_add_fk(fact, dim_4_key, dim_4) - Code - dm_bind(dm_for_flatten(), dm_for_filter()) %>% dm_paste(options = c("select", - "keys")) - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Message - dm::dm( - fact, - dim_1, - dim_2, - dim_3, - dim_4, - tf_1, - tf_2, - tf_3, - tf_4, - tf_5, - tf_6, - ) %>% - dm::dm_select(fact, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2, dim_2_pk, something) %>% - dm::dm_select(dim_3, dim_3_pk, something) %>% - dm::dm_select(dim_4, dim_4_pk, something) %>% - dm::dm_select(tf_1, a, b) %>% - dm::dm_select(tf_2, c, d, e, e1) %>% - dm::dm_select(tf_3, f, f1, g) %>% - dm::dm_select(tf_4, h, i, j, j1) %>% - dm::dm_select(tf_5, ww, k, l, m) %>% - dm::dm_select(tf_6, zz, n, o) %>% - dm::dm_add_pk(dim_1, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2, dim_2_pk) %>% - dm::dm_add_pk(dim_3, dim_3_pk) %>% - dm::dm_add_pk(dim_4, dim_4_pk) %>% - dm::dm_add_pk(tf_1, a, autoincrement = TRUE) %>% - dm::dm_add_pk(tf_2, c) %>% - dm::dm_add_pk(tf_3, c(f, f1)) %>% - dm::dm_add_pk(tf_4, h) %>% - dm::dm_add_pk(tf_5, k) %>% - dm::dm_add_pk(tf_6, o) %>% - dm::dm_add_uk(tf_3, g) %>% - dm::dm_add_fk(fact, c(dim_1_key_1, dim_1_key_2), dim_1) %>% - dm::dm_add_fk(fact, dim_2_key, dim_2) %>% - dm::dm_add_fk(fact, dim_3_key, dim_3) %>% - dm::dm_add_fk(fact, dim_4_key, dim_4) %>% - dm::dm_add_fk(tf_2, d, tf_1) %>% - dm::dm_add_fk(tf_2, c(e, e1), tf_3) %>% - dm::dm_add_fk(tf_4, c(j, j1), tf_3) %>% - dm::dm_add_fk(tf_5, l, tf_4, on_delete = "cascade") %>% - dm::dm_add_fk(tf_5, m, tf_6, n) - ---- - - Code - dm_bind(dm_for_flatten(), dm_for_flatten(), repair = "unique") %>% dm_paste( - options = c("select", "keys")) - Condition - Warning: - `dm_bind()` was deprecated in dm 1.0.0. - i Please use `dm()` instead. - Message - New names: - * `fact` -> `fact...1` - * `dim_1` -> `dim_1...2` - * `dim_2` -> `dim_2...3` - * `dim_3` -> `dim_3...4` - * `dim_4` -> `dim_4...5` - * `fact` -> `fact...6` - * `dim_1` -> `dim_1...7` - * `dim_2` -> `dim_2...8` - * `dim_3` -> `dim_3...9` - * `dim_4` -> `dim_4...10` - dm::dm( - fact...1, - dim_1...2, - dim_2...3, - dim_3...4, - dim_4...5, - fact...6, - dim_1...7, - dim_2...8, - dim_3...9, - dim_4...10, - ) %>% - dm::dm_select(fact...1, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1...2, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2...3, dim_2_pk, something) %>% - dm::dm_select(dim_3...4, dim_3_pk, something) %>% - dm::dm_select(dim_4...5, dim_4_pk, something) %>% - dm::dm_select(fact...6, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1...7, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2...8, dim_2_pk, something) %>% - dm::dm_select(dim_3...9, dim_3_pk, something) %>% - dm::dm_select(dim_4...10, dim_4_pk, something) %>% - dm::dm_add_pk(dim_1...2, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2...3, dim_2_pk) %>% - dm::dm_add_pk(dim_3...4, dim_3_pk) %>% - dm::dm_add_pk(dim_4...5, dim_4_pk) %>% - dm::dm_add_pk(dim_1...7, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2...8, dim_2_pk) %>% - dm::dm_add_pk(dim_3...9, dim_3_pk) %>% - dm::dm_add_pk(dim_4...10, dim_4_pk) %>% - dm::dm_add_fk(fact...1, c(dim_1_key_1, dim_1_key_2), dim_1...2) %>% - dm::dm_add_fk(fact...1, dim_2_key, dim_2...3) %>% - dm::dm_add_fk(fact...1, dim_3_key, dim_3...4) %>% - dm::dm_add_fk(fact...1, dim_4_key, dim_4...5) %>% - dm::dm_add_fk(fact...6, c(dim_1_key_1, dim_1_key_2), dim_1...7) %>% - dm::dm_add_fk(fact...6, dim_2_key, dim_2...8) %>% - dm::dm_add_fk(fact...6, dim_3_key, dim_3...9) %>% - dm::dm_add_fk(fact...6, dim_4_key, dim_4...10) + Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) diff --git a/tests/testthat/_snaps/dm.md b/tests/testthat/_snaps/dm.md index 6fcb49aa2..7ee6d4894 100644 --- a/tests/testthat/_snaps/dm.md +++ b/tests/testthat/_snaps/dm.md @@ -45,830 +45,63 @@ Code dm(a = tibble(), dm_zoom_to(dm_for_filter(), tf_1)) Condition - Error in `dm()`: - ! All dm objects passed to `dm()` must be unzoomed. - i Argument 2 is a zoomed dm. - -# dm() works for adding tables - - Code - dm(dm_for_filter(), tf_1 = data_card_1(), .name_repair = "check_unique") - Condition - Error in `dm()`: - ! Names must be unique. - x These names are duplicated: - * "tf_1" at locations 1 and 7. - -# dm() for adding tables with compound keys - - Code - dm(dm_for_flatten(), res_flat = result_from_flatten()) %>% dm_paste(options = c( - "select", "keys")) - Message - dm::dm( - fact, - dim_1, - dim_2, - dim_3, - dim_4, - res_flat, - ) %>% - dm::dm_select(fact, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2, dim_2_pk, something) %>% - dm::dm_select(dim_3, dim_3_pk, something) %>% - dm::dm_select(dim_4, dim_4_pk, something) %>% - dm::dm_select(res_flat, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, fact.something, dim_1.something, dim_2.something, dim_3.something, dim_4.something) %>% - dm::dm_add_pk(dim_1, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2, dim_2_pk) %>% - dm::dm_add_pk(dim_3, dim_3_pk) %>% - dm::dm_add_pk(dim_4, dim_4_pk) %>% - dm::dm_add_fk(fact, c(dim_1_key_1, dim_1_key_2), dim_1) %>% - dm::dm_add_fk(fact, dim_2_key, dim_2) %>% - dm::dm_add_fk(fact, dim_3_key, dim_3) %>% - dm::dm_add_fk(fact, dim_4_key, dim_4) + Warning in `dm_for_filter()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `map()`: + i In index: 2. + Caused by error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) # errors: duplicate table names, src mismatches Code dm(dm_for_filter(), dm_for_flatten(), dm_for_filter()) Condition - Error in `dm()`: - ! Names must be unique. - x These names are duplicated: - * "tf_1" at locations 1 and 12. - * "tf_2" at locations 2 and 13. - * "tf_3" at locations 3 and 14. - * "tf_4" at locations 4 and 15. - * "tf_5" at locations 5 and 16. - * ... + Warning in `dm_for_filter()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `map()`: + i In index: 1. + Caused by error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) # test error output for src mismatches Code writeLines(conditionMessage(expect_error(dm(dm_for_flatten(), dm_for_filter_duckdb())))) + Condition + Warning in `dm_for_flatten()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation Output - All `dm` objects need to share the same `src`. - -# output for dm() with dm - - Code - dm() - Output - dm() - Code - dm(empty_dm()) - Output - dm() - Code - dm(dm_for_filter()) %>% collect() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `tf_1`, `tf_2`, `tf_3`, `tf_4`, `tf_5`, `tf_6` - Columns: 20 - Primary keys: 6 - Foreign keys: 5 - Code - dm(dm_for_filter(), dm_for_flatten(), dm_for_filter(), .name_repair = "unique", - .quiet = TRUE) %>% collect() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `tf_1...1`, `tf_2...2`, `tf_3...3`, `tf_4...4`, `tf_5...5`, ... (17 total) - Columns: 56 - Primary keys: 16 - Foreign keys: 14 + i In index: 1. + Caused by error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) # output for dm() with dm (2) Code dm(dm_for_filter(), dm_for_flatten(), dm_for_filter()) Condition - Error in `dm()`: - ! Names must be unique. - x These names are duplicated: - * "tf_1" at locations 1 and 12. - * "tf_2" at locations 2 and 13. - * "tf_3" at locations 3 and 14. - * "tf_4" at locations 4 and 15. - * "tf_5" at locations 5 and 16. - * ... - -# output for dm() with dm (3) - - Code - dm(dm_for_filter(), dm_for_flatten(), dm_for_filter(), .name_repair = "unique") %>% - collect() - Message - New names: - * `tf_1` -> `tf_1...1` - * `tf_2` -> `tf_2...2` - * `tf_3` -> `tf_3...3` - * `tf_4` -> `tf_4...4` - * `tf_5` -> `tf_5...5` - * `tf_6` -> `tf_6...6` - * `tf_1` -> `tf_1...12` - * `tf_2` -> `tf_2...13` - * `tf_3` -> `tf_3...14` - * `tf_4` -> `tf_4...15` - * `tf_5` -> `tf_5...16` - * `tf_6` -> `tf_6...17` - Output - -- Metadata -------------------------------------------------------------------- - Tables: `tf_1...1`, `tf_2...2`, `tf_3...3`, `tf_4...4`, `tf_5...5`, ... (17 total) - Columns: 56 - Primary keys: 16 - Foreign keys: 14 - -# output dm() for dm for compound keys - - Code - dm(dm_for_filter(), dm_for_flatten()) %>% dm_paste(options = c("select", "keys")) - Message - dm::dm( - tf_1, - tf_2, - tf_3, - tf_4, - tf_5, - tf_6, - fact, - dim_1, - dim_2, - dim_3, - dim_4, - ) %>% - dm::dm_select(tf_1, a, b) %>% - dm::dm_select(tf_2, c, d, e, e1) %>% - dm::dm_select(tf_3, f, f1, g) %>% - dm::dm_select(tf_4, h, i, j, j1) %>% - dm::dm_select(tf_5, ww, k, l, m) %>% - dm::dm_select(tf_6, zz, n, o) %>% - dm::dm_select(fact, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2, dim_2_pk, something) %>% - dm::dm_select(dim_3, dim_3_pk, something) %>% - dm::dm_select(dim_4, dim_4_pk, something) %>% - dm::dm_add_pk(tf_1, a, autoincrement = TRUE) %>% - dm::dm_add_pk(tf_2, c) %>% - dm::dm_add_pk(tf_3, c(f, f1)) %>% - dm::dm_add_pk(tf_4, h) %>% - dm::dm_add_pk(tf_5, k) %>% - dm::dm_add_pk(tf_6, o) %>% - dm::dm_add_pk(dim_1, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2, dim_2_pk) %>% - dm::dm_add_pk(dim_3, dim_3_pk) %>% - dm::dm_add_pk(dim_4, dim_4_pk) %>% - dm::dm_add_uk(tf_3, g) %>% - dm::dm_add_fk(tf_2, d, tf_1) %>% - dm::dm_add_fk(tf_2, c(e, e1), tf_3) %>% - dm::dm_add_fk(tf_4, c(j, j1), tf_3) %>% - dm::dm_add_fk(tf_5, l, tf_4, on_delete = "cascade") %>% - dm::dm_add_fk(tf_5, m, tf_6, n) %>% - dm::dm_add_fk(fact, c(dim_1_key_1, dim_1_key_2), dim_1) %>% - dm::dm_add_fk(fact, dim_2_key, dim_2) %>% - dm::dm_add_fk(fact, dim_3_key, dim_3) %>% - dm::dm_add_fk(fact, dim_4_key, dim_4) - Code - dm(dm_for_flatten(), dm_for_filter()) %>% dm_paste(options = c("select", "keys")) - Message - dm::dm( - fact, - dim_1, - dim_2, - dim_3, - dim_4, - tf_1, - tf_2, - tf_3, - tf_4, - tf_5, - tf_6, - ) %>% - dm::dm_select(fact, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2, dim_2_pk, something) %>% - dm::dm_select(dim_3, dim_3_pk, something) %>% - dm::dm_select(dim_4, dim_4_pk, something) %>% - dm::dm_select(tf_1, a, b) %>% - dm::dm_select(tf_2, c, d, e, e1) %>% - dm::dm_select(tf_3, f, f1, g) %>% - dm::dm_select(tf_4, h, i, j, j1) %>% - dm::dm_select(tf_5, ww, k, l, m) %>% - dm::dm_select(tf_6, zz, n, o) %>% - dm::dm_add_pk(dim_1, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2, dim_2_pk) %>% - dm::dm_add_pk(dim_3, dim_3_pk) %>% - dm::dm_add_pk(dim_4, dim_4_pk) %>% - dm::dm_add_pk(tf_1, a, autoincrement = TRUE) %>% - dm::dm_add_pk(tf_2, c) %>% - dm::dm_add_pk(tf_3, c(f, f1)) %>% - dm::dm_add_pk(tf_4, h) %>% - dm::dm_add_pk(tf_5, k) %>% - dm::dm_add_pk(tf_6, o) %>% - dm::dm_add_uk(tf_3, g) %>% - dm::dm_add_fk(fact, c(dim_1_key_1, dim_1_key_2), dim_1) %>% - dm::dm_add_fk(fact, dim_2_key, dim_2) %>% - dm::dm_add_fk(fact, dim_3_key, dim_3) %>% - dm::dm_add_fk(fact, dim_4_key, dim_4) %>% - dm::dm_add_fk(tf_2, d, tf_1) %>% - dm::dm_add_fk(tf_2, c(e, e1), tf_3) %>% - dm::dm_add_fk(tf_4, c(j, j1), tf_3) %>% - dm::dm_add_fk(tf_5, l, tf_4, on_delete = "cascade") %>% - dm::dm_add_fk(tf_5, m, tf_6, n) - ---- - - Code - dm(dm_for_flatten(), dm_for_flatten(), .name_repair = "unique") %>% dm_paste( - options = c("select", "keys")) - Message - New names: - * `fact` -> `fact...1` - * `dim_1` -> `dim_1...2` - * `dim_2` -> `dim_2...3` - * `dim_3` -> `dim_3...4` - * `dim_4` -> `dim_4...5` - * `fact` -> `fact...6` - * `dim_1` -> `dim_1...7` - * `dim_2` -> `dim_2...8` - * `dim_3` -> `dim_3...9` - * `dim_4` -> `dim_4...10` - dm::dm( - fact...1, - dim_1...2, - dim_2...3, - dim_3...4, - dim_4...5, - fact...6, - dim_1...7, - dim_2...8, - dim_3...9, - dim_4...10, - ) %>% - dm::dm_select(fact...1, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1...2, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2...3, dim_2_pk, something) %>% - dm::dm_select(dim_3...4, dim_3_pk, something) %>% - dm::dm_select(dim_4...5, dim_4_pk, something) %>% - dm::dm_select(fact...6, fact, dim_1_key_1, dim_1_key_2, dim_2_key, dim_3_key, dim_4_key, something) %>% - dm::dm_select(dim_1...7, dim_1_pk_1, dim_1_pk_2, something) %>% - dm::dm_select(dim_2...8, dim_2_pk, something) %>% - dm::dm_select(dim_3...9, dim_3_pk, something) %>% - dm::dm_select(dim_4...10, dim_4_pk, something) %>% - dm::dm_add_pk(dim_1...2, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2...3, dim_2_pk) %>% - dm::dm_add_pk(dim_3...4, dim_3_pk) %>% - dm::dm_add_pk(dim_4...5, dim_4_pk) %>% - dm::dm_add_pk(dim_1...7, c(dim_1_pk_1, dim_1_pk_2)) %>% - dm::dm_add_pk(dim_2...8, dim_2_pk) %>% - dm::dm_add_pk(dim_3...9, dim_3_pk) %>% - dm::dm_add_pk(dim_4...10, dim_4_pk) %>% - dm::dm_add_fk(fact...1, c(dim_1_key_1, dim_1_key_2), dim_1...2) %>% - dm::dm_add_fk(fact...1, dim_2_key, dim_2...3) %>% - dm::dm_add_fk(fact...1, dim_3_key, dim_3...4) %>% - dm::dm_add_fk(fact...1, dim_4_key, dim_4...5) %>% - dm::dm_add_fk(fact...6, c(dim_1_key_1, dim_1_key_2), dim_1...7) %>% - dm::dm_add_fk(fact...6, dim_2_key, dim_2...8) %>% - dm::dm_add_fk(fact...6, dim_3_key, dim_3...9) %>% - dm::dm_add_fk(fact...6, dim_4_key, dim_4...10) - -# output - - Code - print(dm()) - Output - dm() - Code - nyc_flights_dm <- dm_nycflights_small() - collect(nyc_flights_dm) - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 53 - Primary keys: 3 - Foreign keys: 3 - Code - nyc_flights_dm %>% format() - Output - dm: 5 tables, 53 columns, 3 primary keys, 3 foreign keys - Code - nyc_flights_dm %>% dm_filter(flights = (origin == "EWR")) %>% collect() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 53 - Primary keys: 3 - Foreign keys: 3 - -# output for compound keys - - Code - copy_to(nyc_comp(), mtcars, "car_table") - Condition - Warning: - `copy_to.dm()` was deprecated in dm 0.2.0. - i Use `copy_to(dm_get_con(dm), ...)` and `dm()`. - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather`, `car_table` - Columns: 64 - Primary keys: 4 - Foreign keys: 4 - Code - dm(nyc_comp(), car_table) - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather`, `car_table` - Columns: 64 - Primary keys: 4 - Foreign keys: 4 - Code - nyc_comp() %>% collect() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 53 - Primary keys: 4 - Foreign keys: 4 - Code - nyc_comp() %>% dm_filter(flights = (day == 10)) %>% collect() %>% dm_get_def() %>% - select(-uuid) - Output - # A tibble: 5 x 10 - table data segment display pks uks fks filters zoom - - 1 airlines [1 x 2] [0 x 1] [1 x 4] [0 x 2] - 2 airports [1 x 2] [0 x 1] [1 x 4] [0 x 2] - 3 flights [0 x 2] [0 x 1] [0 x 4] [0 x 2] - 4 planes [1 x 2] [0 x 1] [1 x 4] [0 x 2] - 5 weather [1 x 2] [0 x 1] [1 x 4] [0 x 2] - # i 1 more variable: col_tracker_zoom - Code - nyc_comp() %>% dm_zoom_to(weather) %>% mutate(origin_new = paste0(origin, - " airport")) %>% compute() %>% dm_update_zoomed() %>% collect() %>% - dm_get_def() %>% select(-uuid) - Output - # A tibble: 5 x 10 - table data segment display pks uks fks filters zoom - - 1 airlines [1 x 2] [0 x 1] [1 x 4] [0 x 2] - 2 airports [1 x 2] [0 x 1] [1 x 4] [0 x 2] - 3 flights [0 x 2] [0 x 1] [0 x 4] [0 x 2] - 4 planes [1 x 2] [0 x 1] [1 x 4] [0 x 2] - 5 weather [1 x 2] [0 x 1] [1 x 4] [0 x 2] - # i 1 more variable: col_tracker_zoom - Code - nyc_comp() %>% dm_zoom_to(weather) %>% collect() - Message - Detaching table from dm. - i Use `. %>% pull_tbl() %>% collect()` instead to silence this message. - Output - # A tibble: 144 x 15 - origin year month day hour temp dewp humid wind_dir wind_speed - - 1 EWR 2013 1 10 0 41 32 70.1 230 8.06 - 2 EWR 2013 1 10 1 39.0 30.0 69.9 210 9.21 - 3 EWR 2013 1 10 2 39.0 28.9 66.8 230 6.90 - 4 EWR 2013 1 10 3 39.9 27.0 59.5 270 5.75 - 5 EWR 2013 1 10 4 41 26.1 55.0 320 6.90 - 6 EWR 2013 1 10 5 41 26.1 55.0 300 12.7 - 7 EWR 2013 1 10 6 39.9 25.0 54.8 280 6.90 - 8 EWR 2013 1 10 7 41 25.0 52.6 330 6.90 - 9 EWR 2013 1 10 8 43.0 25.0 48.7 330 8.06 - 10 EWR 2013 1 10 9 45.0 23 41.6 320 17.3 - # i 134 more rows - # i 5 more variables: wind_gust , precip , pressure , - # visib , time_hour - Code - pull_tbl(nyc_comp(), weather) - Output - # A tibble: 144 x 15 - origin year month day hour temp dewp humid wind_dir wind_speed - - 1 EWR 2013 1 10 0 41 32 70.1 230 8.06 - 2 EWR 2013 1 10 1 39.0 30.0 69.9 210 9.21 - 3 EWR 2013 1 10 2 39.0 28.9 66.8 230 6.90 - 4 EWR 2013 1 10 3 39.9 27.0 59.5 270 5.75 - 5 EWR 2013 1 10 4 41 26.1 55.0 320 6.90 - 6 EWR 2013 1 10 5 41 26.1 55.0 300 12.7 - 7 EWR 2013 1 10 6 39.9 25.0 54.8 280 6.90 - 8 EWR 2013 1 10 7 41 25.0 52.6 330 6.90 - 9 EWR 2013 1 10 8 43.0 25.0 48.7 330 8.06 - 10 EWR 2013 1 10 9 45.0 23 41.6 320 17.3 - # i 134 more rows - # i 5 more variables: wind_gust , precip , pressure , - # visib , time_hour - Code - nyc_comp() %>% dm_zoom_to(weather) %>% pull_tbl() - Output - # A tibble: 144 x 15 - origin year month day hour temp dewp humid wind_dir wind_speed - - 1 EWR 2013 1 10 0 41 32 70.1 230 8.06 - 2 EWR 2013 1 10 1 39.0 30.0 69.9 210 9.21 - 3 EWR 2013 1 10 2 39.0 28.9 66.8 230 6.90 - 4 EWR 2013 1 10 3 39.9 27.0 59.5 270 5.75 - 5 EWR 2013 1 10 4 41 26.1 55.0 320 6.90 - 6 EWR 2013 1 10 5 41 26.1 55.0 300 12.7 - 7 EWR 2013 1 10 6 39.9 25.0 54.8 280 6.90 - 8 EWR 2013 1 10 7 41 25.0 52.6 330 6.90 - 9 EWR 2013 1 10 8 43.0 25.0 48.7 330 8.06 - 10 EWR 2013 1 10 9 45.0 23 41.6 320 17.3 - # i 134 more rows - # i 5 more variables: wind_gust , precip , pressure , - # visib , time_hour - -# glimpse.dm() works - - Code - glimpse(empty_dm()) - Output - dm of 0 tables - Code - glimpse(dm_for_disambiguate()) - Output - dm of 3 tables: `iris_1`, `iris_2`, `iris_3` - - -------------------------------------------------------------------------------- - - Table: `iris_1` - Primary key: `key` - - Rows: 150 - Columns: 6 - $ key 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17~ - $ Sepal.Length 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9, 5.4, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 1.5, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.~ - $ Species "setosa", "setosa", "setosa", "setosa", "setosa", "setosa~ - - -------------------------------------------------------------------------------- - - Table: `iris_2` - 1 outgoing foreign key(s): - `key` -> `iris_1$key` no_action - - Rows: 150 - Columns: 7 - $ key 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17~ - $ Sepal.Length 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9, 5.4, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 1.5, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.~ - $ Species "setosa", "setosa", "setosa", "setosa", "setosa", "setosa~ - $ other_col 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - - -------------------------------------------------------------------------------- - - Table: `iris_3` - - Rows: 150 - Columns: 8 - $ key 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17~ - $ Sepal.Length 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9, 5.4, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 1.5, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.~ - $ Species "setosa", "setosa", "setosa", "setosa", "setosa", "setosa~ - $ other_col 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - $ one_more_col 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - - -------------------------------------------------------------------------------- - Code - glimpse(dm_for_disambiguate(), width = 40) - Output - dm of 3 tables: `iris_1`, `iris_2`, `iri... - - -------------------------------------------------------------------------------- - - Table: `iris_1` - Primary key: `key` - - Rows: 150 - Columns: 6 - $ key 1, 2, 3, 4, 5, 6,~ - $ Sepal.Length 5.1, 4.9, 4.7, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.~ - $ Species "setosa", "setosa~ - - -------------------------------------------------------------------------------- - - Table: `iris_2` - 1 outgoing foreign key(s): - `key` -> `iris_1$key` no_action - - Rows: 150 - Columns: 7 - $ key 1, 2, 3, 4, 5, 6,~ - $ Sepal.Length 5.1, 4.9, 4.7, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.~ - $ Species "setosa", "setosa~ - $ other_col 1, 1, 1, 1, 1, 1,~ - - -------------------------------------------------------------------------------- - - Table: `iris_3` - - Rows: 150 - Columns: 8 - $ key 1, 2, 3, 4, 5, 6,~ - $ Sepal.Length 5.1, 4.9, 4.7, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.~ - $ Species "setosa", "setosa~ - $ other_col 1, 1, 1, 1, 1, 1,~ - $ one_more_col 1, 1, 1, 1, 1, 1,~ - - -------------------------------------------------------------------------------- - Code - getOption("width") - Output - [1] 80 - Code - glimpse(dm_for_disambiguate() %>% dm_rename(iris_1, - gdsjgiodsjgdisogjdsiogjdsigjsdiogjisdjgiodsjgiosdjgiojsdiogjgrjihjrehoierjhiorejhrieojhreiojhieorhjioerjhierjhioerjhioerjhioerjiohjeriosdiogjsdjigjsd = key) %>% - dm_rename_tbl( - gdsjgiodsjgdisogjdsiogjdsigjsdiogjisdjgiodsjgiosdjgiojsdiogjgrjihjrehoierjhiorejhrieojhreiojhieorhjioerjhierjhioerjhioerjhioerjiohjeriosdiogjsdjigjsd = iris_1)) - Output - dm of 3 tables: `gdsjgiodsjgdisogjdsiogjdsigjsdiogjisdjgiodsjgiosdjgiojsdiogjgrj... - - -------------------------------------------------------------------------------- - - Table: `gdsjgiodsjgdisogjdsiogjdsigjsdiogjisdjgiodsjgiosdjgiojsdiogjgrjihjrehoie... - Primary key: `gdsjgiodsjgdisogjdsiogjdsigjsdiogjisdjgiodsjgiosdjgiojsdiogjgrjihj... - - Rows: 150 - Columns: 6 - $ gdsjgiodsjgdisogjdsiogjdsigjsdiogjisdjgiodsjgiosdjgiojsdiogjgrjihjrehoierjhiorejhrieojhreiojhieorhjioerjhierjhioerjhioerjhioerjiohjeriosdiogjsdjigjsd ~ - $ Sepal.Length ~ - $ Sepal.Width ~ - $ Petal.Length ~ - $ Petal.Width ~ - $ Species ~ - - -------------------------------------------------------------------------------- - - Table: `iris_2` - 1 outgoing foreign key(s): - `key` -> `gdsjgiodsjgdisogjdsiogjdsigjsdiogjisdjgiodsjgiosdjgiojsdiogjgrjihjre... - - Rows: 150 - Columns: 7 - $ key 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17~ - $ Sepal.Length 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9, 5.4, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 1.5, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.~ - $ Species "setosa", "setosa", "setosa", "setosa", "setosa", "setosa~ - $ other_col 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - - -------------------------------------------------------------------------------- - - Table: `iris_3` - - Rows: 150 - Columns: 8 - $ key 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17~ - $ Sepal.Length 5.1, 4.9, 4.7, 4.6, 5.0, 5.4, 4.6, 5.0, 4.4, 4.9, 5.4, 4.~ - $ Sepal.Width 3.5, 3.0, 3.2, 3.1, 3.6, 3.9, 3.4, 3.4, 2.9, 3.1, 3.7, 3.~ - $ Petal.Length 1.4, 1.4, 1.3, 1.5, 1.4, 1.7, 1.4, 1.5, 1.4, 1.5, 1.5, 1.~ - $ Petal.Width 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.~ - $ Species "setosa", "setosa", "setosa", "setosa", "setosa", "setosa~ - $ other_col 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - $ one_more_col 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - - -------------------------------------------------------------------------------- - Code - dm_nycflights13() %>% dm_select_tbl(weather) %>% dm_select(weather, -origin) %>% - glimpse() - Output - dm of 1 tables: `weather` - - -------------------------------------------------------------------------------- - - Table: `weather` - - Rows: 144 - Columns: 14 - $ year 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013,~ - $ month 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,~ - $ day 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,~ - $ hour 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1~ - $ temp 41.00, 39.02, 39.02, 39.92, 41.00, 41.00, 39.92, 41.00, 42.~ - $ dewp 32.00, 30.02, 28.94, 26.96, 26.06, 26.06, 24.98, 24.98, 24.~ - $ humid 70.08, 69.86, 66.85, 59.50, 54.97, 54.97, 54.81, 52.56, 48.~ - $ wind_dir 230, 210, 230, 270, 320, 300, 280, 330, 330, 320, 320, 330,~ - $ wind_speed 8.05546, 9.20624, 6.90468, 5.75390, 6.90468, 12.65858, 6.90~ - $ wind_gust NA, NA, NA, NA, NA, 20.71404, 17.26170, NA, NA, 26.46794, N~ - $ precip 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,~ - $ pressure 1024.6, 1025.9, 1026.9, 1027.5, 1028.2, 1029.0, 1030.0, 103~ - $ visib 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,~ - $ time_hour 2013-01-10 00:00:00, 2013-01-10 01:00:00, 2013-01-10 02:00~ - - -------------------------------------------------------------------------------- - -# glimpse.dm_zoomed() works - - Code - dm_nycflights13() %>% dm_zoom_to(airports) %>% glimpse() - Output - dm of 5 tables: `airlines`, `airports`, `flights`, `planes`, `weather` - - Zoomed table: `airports` - Primary key: `faa` - - Rows: 86 - Columns: 8 - $ faa "ALB", "ATL", "AUS", "BDL", "BHM", "BNA", "BOS", "BTV", "BUF", "~ - $ name "Albany Intl", "Hartsfield Jackson Atlanta Intl", "Austin Bergst~ - $ lat 42.74827, 33.63672, 30.19453, 41.93889, 33.56294, 36.12447, 42.3~ - $ lon -73.80169, -84.42807, -97.66989, -72.68322, -86.75355, -86.67819~ - $ alt 285, 1026, 542, 173, 644, 599, 19, 335, 724, 778, 146, 236, 1228~ - $ tz -5, -5, -6, -5, -6, -6, -5, -5, -5, -8, -5, -5, -5, -5, -5, -5, ~ - $ dst "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A", "A",~ - $ tzone "America/New_York", "America/New_York", "America/Chicago", "Amer~ - Code - dm_nycflights13() %>% dm_zoom_to(flights) %>% glimpse(width = 100) - Output - dm of 5 tables: `airlines`, `airports`, `flights`, `planes`, `weather` - - Zoomed table: `flights` - 4 outgoing foreign key(s): - `carrier` -> `airlines$carrier` no_action - `origin` -> `airports$faa` no_action - `tailnum` -> `planes$tailnum` no_action - (`origin`, `time_hour`) -> (`weather$origin`, `weather$time_hour`) no_action - - Rows: 1,761 - Columns: 19 - $ year 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 201~ - $ month 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - $ day 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,~ - $ dep_time 3, 16, 450, 520, 530, 531, 535, 546, 549, 550, 553, 553, 553, 553, 555, 555~ - $ sched_dep_time 2359, 2359, 500, 525, 530, 540, 540, 600, 600, 600, 600, 600, 600, 600, 600~ - $ dep_delay 4, 17, -10, -5, 0, -9, -5, -14, -11, -10, -7, -7, -7, -7, -5, -10, -5, -4, ~ - $ arr_time 426, 447, 634, 813, 824, 832, 1015, 645, 652, 649, 711, 837, 834, 733, 733,~ - $ sched_arr_time 437, 444, 648, 820, 829, 850, 1017, 709, 724, 703, 715, 910, 859, 759, 745,~ - $ arr_delay -11, 3, -14, -7, -5, -18, -2, -24, -32, -14, -4, -33, -25, -26, -12, -19, 2~ - $ carrier "B6", "B6", "US", "UA", "UA", "AA", "B6", "B6", "EV", "US", "EV", "AA", "B6~ - $ flight 727, 739, 1117, 1018, 404, 1141, 725, 380, 6055, 2114, 5716, 707, 507, 731,~ - $ tailnum "N571JB", "N564JB", "N171US", "N35204", "N815UA", "N5EAAA", "N784JB", "N337~ - $ origin "JFK", "JFK", "EWR", "EWR", "LGA", "JFK", "JFK", "EWR", "LGA", "LGA", "JFK"~ - $ dest "BQN", "PSE", "CLT", "IAH", "IAH", "MIA", "BQN", "BOS", "IAD", "BOS", "IAD"~ - $ air_time 183, 191, 78, 215, 210, 149, 191, 39, 48, 36, 51, 201, 144, 85, 126, 94, 42~ - $ distance 1576, 1617, 529, 1400, 1416, 1089, 1576, 200, 229, 184, 228, 1389, 1065, 50~ - $ hour 23, 23, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6~ - $ minute 59, 59, 0, 25, 30, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, ~ - $ time_hour 2013-01-10 23:00:00, 2013-01-10 23:00:00, 2013-01-10 05:00:00, 2013-01-10 ~ - Code - dm_nycflights13() %>% dm_zoom_to(weather) %>% select(-origin) %>% glimpse() - Output - dm of 5 tables: `airlines`, `airports`, `flights`, `planes`, `weather` - - Zoomed table: `weather` - - Rows: 144 - Columns: 14 - $ year 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013,~ - $ month 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,~ - $ day 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,~ - $ hour 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 1~ - $ temp 41.00, 39.02, 39.02, 39.92, 41.00, 41.00, 39.92, 41.00, 42.~ - $ dewp 32.00, 30.02, 28.94, 26.96, 26.06, 26.06, 24.98, 24.98, 24.~ - $ humid 70.08, 69.86, 66.85, 59.50, 54.97, 54.97, 54.81, 52.56, 48.~ - $ wind_dir 230, 210, 230, 270, 320, 300, 280, 330, 330, 320, 320, 330,~ - $ wind_speed 8.05546, 9.20624, 6.90468, 5.75390, 6.90468, 12.65858, 6.90~ - $ wind_gust NA, NA, NA, NA, NA, 20.71404, 17.26170, NA, NA, 26.46794, N~ - $ precip 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,~ - $ pressure 1024.6, 1025.9, 1026.9, 1027.5, 1028.2, 1029.0, 1030.0, 103~ - $ visib 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,~ - $ time_hour 2013-01-10 00:00:00, 2013-01-10 01:00:00, 2013-01-10 02:00~ - Code - dm_nycflights13() %>% dm_zoom_to(weather) %>% rename(origin_location = origin) %>% - glimpse() - Output - dm of 5 tables: `airlines`, `airports`, `flights`, `planes`, `weather` - - Zoomed table: `weather` - Primary key: (`origin_location`, `time_hour`) - - Rows: 144 - Columns: 15 - $ origin_location "EWR", "EWR", "EWR", "EWR", "EWR", "EWR", "EWR", "EWR"~ - $ year 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, ~ - $ month 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - $ day 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10~ - $ hour 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, ~ - $ temp 41.00, 39.02, 39.02, 39.92, 41.00, 41.00, 39.92, 41.00~ - $ dewp 32.00, 30.02, 28.94, 26.96, 26.06, 26.06, 24.98, 24.98~ - $ humid 70.08, 69.86, 66.85, 59.50, 54.97, 54.97, 54.81, 52.56~ - $ wind_dir 230, 210, 230, 270, 320, 300, 280, 330, 330, 320, 320,~ - $ wind_speed 8.05546, 9.20624, 6.90468, 5.75390, 6.90468, 12.65858,~ - $ wind_gust NA, NA, NA, NA, NA, 20.71404, 17.26170, NA, NA, 26.467~ - $ precip 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ~ - $ pressure 1024.6, 1025.9, 1026.9, 1027.5, 1028.2, 1029.0, 1030.0~ - $ visib 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10~ - $ time_hour 2013-01-10 00:00:00, 2013-01-10 01:00:00, 2013-01-10 ~ - Code - dm_nycflights13() %>% dm_zoom_to(flights) %>% select(-carrier) %>% glimpse() - Output - dm of 5 tables: `airlines`, `airports`, `flights`, `planes`, `weather` - - Zoomed table: `flights` - 3 outgoing foreign key(s): - `origin` -> `airports$faa` no_action - `tailnum` -> `planes$tailnum` no_action - (`origin`, `time_hour`) -> (`weather$origin`, `weather$time_hour`) no_action - - Rows: 1,761 - Columns: 18 - $ year 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2~ - $ month 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1~ - $ day 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,~ - $ dep_time 3, 16, 450, 520, 530, 531, 535, 546, 549, 550, 553, 553~ - $ sched_dep_time 2359, 2359, 500, 525, 530, 540, 540, 600, 600, 600, 600~ - $ dep_delay 4, 17, -10, -5, 0, -9, -5, -14, -11, -10, -7, -7, -7, -~ - $ arr_time 426, 447, 634, 813, 824, 832, 1015, 645, 652, 649, 711,~ - $ sched_arr_time 437, 444, 648, 820, 829, 850, 1017, 709, 724, 703, 715,~ - $ arr_delay -11, 3, -14, -7, -5, -18, -2, -24, -32, -14, -4, -33, -~ - $ flight 727, 739, 1117, 1018, 404, 1141, 725, 380, 6055, 2114, ~ - $ tailnum "N571JB", "N564JB", "N171US", "N35204", "N815UA", "N5EA~ - $ origin "JFK", "JFK", "EWR", "EWR", "LGA", "JFK", "JFK", "EWR",~ - $ dest "BQN", "PSE", "CLT", "IAH", "IAH", "MIA", "BQN", "BOS",~ - $ air_time 183, 191, 78, 215, 210, 149, 191, 39, 48, 36, 51, 201, ~ - $ distance 1576, 1617, 529, 1400, 1416, 1089, 1576, 200, 229, 184,~ - $ hour 23, 23, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,~ - $ minute 59, 59, 0, 25, 30, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0~ - $ time_hour 2013-01-10 23:00:00, 2013-01-10 23:00:00, 2013-01-10 0~ - Code - dm_nycflights13() %>% dm_zoom_to(flights) %>% select(-origin) %>% glimpse() - Output - dm of 5 tables: `airlines`, `airports`, `flights`, `planes`, `weather` - - Zoomed table: `flights` - 2 outgoing foreign key(s): - `carrier` -> `airlines$carrier` no_action - `tailnum` -> `planes$tailnum` no_action - - Rows: 1,761 - Columns: 18 - $ year 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2~ - $ month 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1~ - $ day 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,~ - $ dep_time 3, 16, 450, 520, 530, 531, 535, 546, 549, 550, 553, 553~ - $ sched_dep_time 2359, 2359, 500, 525, 530, 540, 540, 600, 600, 600, 600~ - $ dep_delay 4, 17, -10, -5, 0, -9, -5, -14, -11, -10, -7, -7, -7, -~ - $ arr_time 426, 447, 634, 813, 824, 832, 1015, 645, 652, 649, 711,~ - $ sched_arr_time 437, 444, 648, 820, 829, 850, 1017, 709, 724, 703, 715,~ - $ arr_delay -11, 3, -14, -7, -5, -18, -2, -24, -32, -14, -4, -33, -~ - $ carrier "B6", "B6", "US", "UA", "UA", "AA", "B6", "B6", "EV", "~ - $ flight 727, 739, 1117, 1018, 404, 1141, 725, 380, 6055, 2114, ~ - $ tailnum "N571JB", "N564JB", "N171US", "N35204", "N815UA", "N5EA~ - $ dest "BQN", "PSE", "CLT", "IAH", "IAH", "MIA", "BQN", "BOS",~ - $ air_time 183, 191, 78, 215, 210, 149, 191, 39, 48, 36, 51, 201, ~ - $ distance 1576, 1617, 529, 1400, 1416, 1089, 1576, 200, 229, 184,~ - $ hour 23, 23, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,~ - $ minute 59, 59, 0, 25, 30, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0~ - $ time_hour 2013-01-10 23:00:00, 2013-01-10 23:00:00, 2013-01-10 0~ - Code - dm_nycflights13() %>% dm_zoom_to(flights) %>% rename(origin_location = origin) %>% - glimpse() - Output - dm of 5 tables: `airlines`, `airports`, `flights`, `planes`, `weather` - - Zoomed table: `flights` - 4 outgoing foreign key(s): - `carrier` -> `airlines$carrier` no_action - `origin_location` -> `airports$faa` no_action - `tailnum` -> `planes$tailnum` no_action - (`origin_location`, `time_hour`) -> (`weather$origin`, `weather$time_hour`) no... - - Rows: 1,761 - Columns: 19 - $ year 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, 2013, ~ - $ month 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, ~ - $ day 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10~ - $ dep_time 3, 16, 450, 520, 530, 531, 535, 546, 549, 550, 553, 55~ - $ sched_dep_time 2359, 2359, 500, 525, 530, 540, 540, 600, 600, 600, 60~ - $ dep_delay 4, 17, -10, -5, 0, -9, -5, -14, -11, -10, -7, -7, -7, ~ - $ arr_time 426, 447, 634, 813, 824, 832, 1015, 645, 652, 649, 711~ - $ sched_arr_time 437, 444, 648, 820, 829, 850, 1017, 709, 724, 703, 715~ - $ arr_delay -11, 3, -14, -7, -5, -18, -2, -24, -32, -14, -4, -33, ~ - $ carrier "B6", "B6", "US", "UA", "UA", "AA", "B6", "B6", "EV", ~ - $ flight 727, 739, 1117, 1018, 404, 1141, 725, 380, 6055, 2114,~ - $ tailnum "N571JB", "N564JB", "N171US", "N35204", "N815UA", "N5E~ - $ origin_location "JFK", "JFK", "EWR", "EWR", "LGA", "JFK", "JFK", "EWR"~ - $ dest "BQN", "PSE", "CLT", "IAH", "IAH", "MIA", "BQN", "BOS"~ - $ air_time 183, 191, 78, 215, 210, 149, 191, 39, 48, 36, 51, 201,~ - $ distance 1576, 1617, 529, 1400, 1416, 1089, 1576, 200, 229, 184~ - $ hour 23, 23, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6~ - $ minute 59, 59, 0, 25, 30, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0, 5, ~ - $ time_hour 2013-01-10 23:00:00, 2013-01-10 23:00:00, 2013-01-10 ~ + Warning in `dm_for_filter()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `map()`: + i In index: 1. + Caused by error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) diff --git a/tests/testthat/_snaps/dplyr.md b/tests/testthat/_snaps/dplyr.md index 83a7bf2c8..ab67a33a1 100644 --- a/tests/testthat/_snaps/dplyr.md +++ b/tests/testthat/_snaps/dplyr.md @@ -57,531 +57,3 @@ 5 tf_5 m tf_6 n no_action -# key tracking works - - Code - # rename() - zoomed_grouped_out_dm %>% rename(c_new = c) %>% dm_update_zoomed() %>% - get_all_keys() - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c_new FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - zoomed_grouped_out_dm %>% rename(e_new = e) %>% dm_update_zoomed() %>% - get_all_keys() - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e_new, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - zoomed_grouped_in_dm %>% rename(f_new = f) %>% dm_update_zoomed() %>% - get_all_keys() - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f_new, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f_new, f1 no_action - 3 tf_4 j, j1 tf_3 f_new, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - # summarize() - zoomed_grouped_out_dm %>% summarize(d_mean = mean(d)) %>% dm_insert_zoomed( - "new_tbl") %>% get_all_keys() - Output - $pks - # A tibble: 7 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - 7 new_tbl c FALSE - - $fks - # A tibble: 6 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 new_tbl e, e1 tf_3 f, f1 no_action - 5 tf_5 l tf_4 h cascade - 6 tf_5 m tf_6 n no_action - - Code - zoomed_grouped_in_dm %>% summarize(g_list = list(g)) %>% dm_insert_zoomed( - "new_tbl") %>% get_all_keys() - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - -# key tracking works (2) - - Code - # transmute() - zoomed_grouped_out_dm %>% transmute(d_mean = mean(d)) %>% dm_insert_zoomed( - "new_tbl") %>% get_all_keys() - Output - $pks - # A tibble: 7 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - 7 new_tbl c FALSE - - $fks - # A tibble: 6 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 new_tbl e, e1 tf_3 f, f1 no_action - 5 tf_5 l tf_4 h cascade - 6 tf_5 m tf_6 n no_action - - -# key tracking works (3) - - Code - zoomed_grouped_in_dm %>% transmute(g_list = list(g)) %>% dm_insert_zoomed( - "new_tbl") %>% get_all_keys() - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - -# key tracking works (4) - - Code - # mutate() - zoomed_grouped_out_dm %>% mutate(d_mean = mean(d)) %>% select(-d) %>% - dm_insert_zoomed("new_tbl") %>% get_all_keys() - Output - $pks - # A tibble: 7 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - 7 new_tbl c FALSE - - $fks - # A tibble: 6 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 new_tbl e, e1 tf_3 f, f1 no_action - 5 tf_5 l tf_4 h cascade - 6 tf_5 m tf_6 n no_action - - Code - zoomed_grouped_in_dm %>% mutate(f = paste0(g, g)) %>% dm_insert_zoomed( - "new_tbl") %>% get_all_keys() - Output - $pks - # A tibble: 7 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - 7 new_tbl f, f1 FALSE - - $fks - # A tibble: 7 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - 6 tf_2 e, e1 new_tbl f, f1 no_action - 7 tf_4 j, j1 new_tbl f, f1 no_action - - Code - zoomed_grouped_in_dm %>% mutate(g_new = list(g)) %>% dm_insert_zoomed("new_tbl") %>% - get_all_keys() - Output - $pks - # A tibble: 7 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - 7 new_tbl f, f1 FALSE - - $fks - # A tibble: 7 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - 6 tf_2 e, e1 new_tbl f, f1 no_action - 7 tf_4 j, j1 new_tbl f, f1 no_action - - -# key tracking works (5) - - Code - # chain of renames & other transformations - zoomed_grouped_out_dm %>% summarize(d_mean = mean(d)) %>% ungroup() %>% rename( - e_new = e) %>% group_by(e_new, e1) %>% transmute(c = paste0(c, "_animal")) %>% - dm_insert_zoomed("new_tbl") %>% get_all_keys() - Output - $pks - # A tibble: 7 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - 7 new_tbl c FALSE - - $fks - # A tibble: 6 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 new_tbl e_new, e1 tf_3 f, f1 no_action - 5 tf_5 l tf_4 h cascade - 6 tf_5 m tf_6 n no_action - - -# key tracking works (6) - - Code - zoomed_grouped_in_dm %>% select(g_new = g) %>% get_all_keys("tf_3") - Output - $pks - # A tibble: 1 x 3 - table pk_col autoincrement - - 1 tf_3 f, f1 FALSE - - $fks - # A tibble: 2 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 e, e1 tf_3 f, f1 no_action - 2 tf_4 j, j1 tf_3 f, f1 no_action - - -# output for compound keys - - Code - grouped_zoomed_comp_dm_1 %>% mutate(count = n()) %>% col_tracker_zoomed() - Output - origin year month day hour temp - "origin" "year" "month" "day" "hour" "temp" - dewp humid wind_dir wind_speed wind_gust precip - "dewp" "humid" "wind_dir" "wind_speed" "wind_gust" "precip" - pressure visib time_hour - "pressure" "visib" "time_hour" - Code - grouped_zoomed_comp_dm_2 %>% mutate(count = n()) %>% col_tracker_zoomed() - Output - origin year month day hour temp - "origin" "year" "month" "day" "hour" "temp" - dewp humid wind_dir wind_speed wind_gust precip - "dewp" "humid" "wind_dir" "wind_speed" "wind_gust" "precip" - pressure visib time_hour - "pressure" "visib" "time_hour" - Code - grouped_zoomed_comp_dm_1 %>% transmute(count = n()) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 41 - Primary keys: 3 - Foreign keys: 3 - Code - grouped_zoomed_comp_dm_2 %>% transmute(count = n()) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 41 - Primary keys: 4 - Foreign keys: 4 - Code - grouped_zoomed_comp_dm_1 %>% summarize(count = n()) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 41 - Primary keys: 3 - Foreign keys: 3 - Code - grouped_zoomed_comp_dm_2 %>% summarize(count = n()) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 41 - Primary keys: 4 - Foreign keys: 4 - Code - zoomed_comp_dm %>% select(time_hour, wind_dir) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 40 - Primary keys: 3 - Foreign keys: 3 - Code - zoomed_comp_dm %>% select(time_hour, origin, wind_dir) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 41 - Primary keys: 4 - Foreign keys: 4 - Code - zoomed_comp_dm %>% rename(th = time_hour, wd = wind_dir) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 53 - Primary keys: 4 - Foreign keys: 4 - Code - zoomed_comp_dm %>% distinct(origin, wind_dir) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 40 - Primary keys: 3 - Foreign keys: 3 - Code - zoomed_comp_dm %>% distinct(origin, wind_dir, time_hour) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 41 - Primary keys: 4 - Foreign keys: 4 - Code - zoomed_comp_dm %>% filter(pressure < 1020) %>% dm_update_zoomed() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 53 - Primary keys: 4 - Foreign keys: 4 - Code - zoomed_comp_dm %>% pull(origin) %>% unique() - Output - [1] "EWR" "JFK" "LGA" - Code - zoomed_comp_dm %>% slice(c(1:3, 5:3)) - Message - Keeping PK column, but `slice.dm_zoomed()` can potentially damage the uniqueness of PK columns (duplicated indices). Set argument `.keep_pk` to `TRUE` or `FALSE` to ensure the behavior you intended. - Output - # Zoomed table: weather - # A tibble: 6 x 15 - origin year month day hour temp dewp humid wind_dir wind_speed wind_gust - - 1 EWR 2013 1 10 0 41 32 70.1 230 8.06 NA - 2 EWR 2013 1 10 1 39.0 30.0 69.9 210 9.21 NA - 3 EWR 2013 1 10 2 39.0 28.9 66.8 230 6.90 NA - 4 EWR 2013 1 10 4 41 26.1 55.0 320 6.90 NA - 5 EWR 2013 1 10 3 39.9 27.0 59.5 270 5.75 NA - 6 EWR 2013 1 10 2 39.0 28.9 66.8 230 6.90 NA - # i 4 more variables: precip , pressure , visib , - # time_hour - Code - zoomed_comp_dm %>% slice(c(1:3, 5:3), .keep_pk = TRUE) %>% col_tracker_zoomed() - Output - origin year month day hour temp - "origin" "year" "month" "day" "hour" "temp" - dewp humid wind_dir wind_speed wind_gust precip - "dewp" "humid" "wind_dir" "wind_speed" "wind_gust" "precip" - pressure visib time_hour - "pressure" "visib" "time_hour" - Code - zoomed_comp_dm %>% left_join(flights, multiple = "all") %>% nrow() - Message - Renaming ambiguous columns: %>% - dm_rename(weather, year.weather = year) %>% - dm_rename(weather, month.weather = month) %>% - dm_rename(weather, day.weather = day) %>% - dm_rename(weather, hour.weather = hour) %>% - dm_rename(flights, year.flights = year) %>% - dm_rename(flights, month.flights = month) %>% - dm_rename(flights, day.flights = day) %>% - dm_rename(flights, hour.flights = hour) - Output - [1] 1800 - Code - zoomed_comp_dm %>% right_join(flights, multiple = "all") %>% nrow() - Message - Renaming ambiguous columns: %>% - dm_rename(weather, year.weather = year) %>% - dm_rename(weather, month.weather = month) %>% - dm_rename(weather, day.weather = day) %>% - dm_rename(weather, hour.weather = hour) %>% - dm_rename(flights, year.flights = year) %>% - dm_rename(flights, month.flights = month) %>% - dm_rename(flights, day.flights = day) %>% - dm_rename(flights, hour.flights = hour) - Output - [1] 1761 - Code - zoomed_comp_dm %>% inner_join(flights, multiple = "all") %>% nrow() - Message - Renaming ambiguous columns: %>% - dm_rename(weather, year.weather = year) %>% - dm_rename(weather, month.weather = month) %>% - dm_rename(weather, day.weather = day) %>% - dm_rename(weather, hour.weather = hour) %>% - dm_rename(flights, year.flights = year) %>% - dm_rename(flights, month.flights = month) %>% - dm_rename(flights, day.flights = day) %>% - dm_rename(flights, hour.flights = hour) - Output - [1] 1761 - Code - zoomed_comp_dm %>% full_join(flights, multiple = "all") %>% nrow() - Message - Renaming ambiguous columns: %>% - dm_rename(weather, year.weather = year) %>% - dm_rename(weather, month.weather = month) %>% - dm_rename(weather, day.weather = day) %>% - dm_rename(weather, hour.weather = hour) %>% - dm_rename(flights, year.flights = year) %>% - dm_rename(flights, month.flights = month) %>% - dm_rename(flights, day.flights = day) %>% - dm_rename(flights, hour.flights = hour) - Output - [1] 1800 - Code - zoomed_comp_dm %>% semi_join(flights) %>% nrow() - Output - [1] 105 - Code - zoomed_comp_dm %>% anti_join(flights) %>% nrow() - Output - [1] 39 - Code - zoomed_comp_dm %>% nest_join(flights) %>% nrow() - Output - [1] 144 - diff --git a/tests/testthat/_snaps/error-helpers.md b/tests/testthat/_snaps/error-helpers.md index b8a65bfe2..6c8f4365e 100644 --- a/tests/testthat/_snaps/error-helpers.md +++ b/tests/testthat/_snaps/error-helpers.md @@ -65,9 +65,14 @@ Code abort_no_cycles(create_graph_from_dm(dm_for_filter_w_cycle())) Condition - Error in `abort_no_cycles()`: - ! Cycles in the relationship graph not yet supported. - i Shortest cycle: tf_5 -> tf_6 -> tf_7 -> tf_2 -> tf_3 -> tf_4 -> tf_5 + Warning in `dm_for_filter_w_cycle()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Code abort_tables_not_reachable_from_start() Condition diff --git a/tests/testthat/_snaps/foreign-keys.md b/tests/testthat/_snaps/foreign-keys.md index 396c08475..e8d39b725 100644 --- a/tests/testthat/_snaps/foreign-keys.md +++ b/tests/testthat/_snaps/foreign-keys.md @@ -1,210 +1,3 @@ -# dm_add_fk() works as intended? - - Code - dm_test_obj() %>% dm_add_pk(dm_table_4, c) %>% dm_add_fk(dm_table_1, a, - dm_table_4) %>% get_all_keys() - Output - $pks - # A tibble: 1 x 3 - table pk_col autoincrement - - 1 dm_table_4 c FALSE - - $fks - # A tibble: 1 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 dm_table_1 a dm_table_4 c no_action - - -# dm_rm_fk() works with partial matching - - Code - dm_for_filter() %>% dm_rm_fk(tf_5) %>% get_all_keys() - Message - Removing foreign keys: %>% - dm_rm_fk(tf_5, l, tf_4) %>% - dm_rm_fk(tf_5, m, tf_6, n)) - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 3 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - - Code - dm_for_filter() %>% dm_rm_fk(columns = l) %>% get_all_keys() - Message - Removing foreign keys: %>% - dm_rm_fk(tf_5, l, tf_4) - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 4 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_fk(columns = c(e, e1)) %>% get_all_keys() - Message - Removing foreign keys: %>% - dm_rm_fk(tf_2, c(e, e1), tf_3) - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 4 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_4 j, j1 tf_3 f, f1 no_action - 3 tf_5 l tf_4 h cascade - 4 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_fk(ref_table = tf_3) %>% get_all_keys() - Message - Removing foreign keys: %>% - dm_rm_fk(tf_2, c(e, e1), tf_3) %>% - dm_rm_fk(tf_4, c(j, j1), tf_3) - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 3 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_5 l tf_4 h cascade - 3 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_fk(ref_columns = c(f, f1)) %>% get_all_keys() - Message - Removing foreign keys: %>% - dm_rm_fk(tf_2, c(e, e1), tf_3) %>% - dm_rm_fk(tf_4, c(j, j1), tf_3) - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 3 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_5 l tf_4 h cascade - 3 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_fk() %>% get_all_keys() - Message - Removing foreign keys: %>% - dm_rm_fk(tf_2, d, tf_1) %>% - dm_rm_fk(tf_2, c(e, e1), tf_3) %>% - dm_rm_fk(tf_4, c(j, j1), tf_3) %>% - dm_rm_fk(tf_5, l, tf_4) %>% - dm_rm_fk(tf_5, m, tf_6, n)) - Output - $pks - # A tibble: 6 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - 6 tf_6 o FALSE - - $fks - # A tibble: 0 x 5 - # i 5 variables: child_table , child_fk_cols , parent_table , - # parent_key_cols , on_delete - - -# dm_enum_fk_candidates() works as intended? - - Code - dm_nycflights13() %>% dm_enum_fk_candidates(flights, airports) %>% mutate(why = if_else( - why != "", "", "")) - Output - # A tibble: 19 x 3 - columns candidate why - - 1 origin TRUE "" - 2 year FALSE "" - 3 month FALSE "" - 4 day FALSE "" - 5 dep_time FALSE "" - 6 sched_dep_time FALSE "" - 7 dep_delay FALSE "" - 8 arr_time FALSE "" - 9 sched_arr_time FALSE "" - 10 arr_delay FALSE "" - 11 carrier FALSE "" - 12 flight FALSE "" - 13 tailnum FALSE "" - 14 dest FALSE "" - 15 air_time FALSE "" - 16 distance FALSE "" - 17 hour FALSE "" - 18 minute FALSE "" - 19 time_hour FALSE "" - # can add foreign key with cascade Code @@ -229,43 +22,7 @@ Error in `dm_add_fk()`: ! `on_delete` must be one of "no_action" or "cascade", not "a". -# dm_get_all_fks() with parent_table arg - - Code - nyc_comp() %>% dm_get_all_fks(weather) - Output - # A tibble: 1 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 flights origin, time_hour weather origin, time_hour no_action - Code - nyc_comp() %>% dm_get_all_fks(c("airlines", "weather")) - Output - # A tibble: 2 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 flights carrier airlines carrier no_action - 2 flights origin, time_hour weather origin, time_hour no_action - Code - nyc_comp() %>% dm_get_all_fks(ends_with("ports")) - Output - # A tibble: 1 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 flights dest airports faa no_action - Code - nyc_comp() %>% dm_get_all_fks(everything()) - Output - # A tibble: 4 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 flights carrier airlines carrier no_action - 2 flights dest airports faa no_action - 3 flights tailnum planes tailnum no_action - 4 flights origin, time_hour weather origin, time_hour no_action - # dm_get_all_fks() with parent_table arg fails nicely - Can't subset tables that don't exist. - x Table `timetable` doesn't exist. + Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) diff --git a/tests/testthat/_snaps/key-helpers.md b/tests/testthat/_snaps/key-helpers.md index d21f4a7cd..9b1122c22 100644 --- a/tests/testthat/_snaps/key-helpers.md +++ b/tests/testthat/_snaps/key-helpers.md @@ -14,70 +14,43 @@ The `.data` argument of `check_key()` is deprecated as of dm 1.0.0. i Please use the `x` argument instead. -# output for legacy API - - Code - check_subset(data_mcard_1(), a, data_mcard_2(), a) - Condition - Warning: - The `c1` argument of `check_subset()` is deprecated as of dm 1.0.0. - i Please use the `x_select` argument instead. - i Use `y_select` instead of `c2`, and `x` and `y` instead of `t1` and `t2`. - i Using `by_position = TRUE` for compatibility. - # output Code check_subset(data_mcard_1(), data_mcard_2(), x_select = c(x = a)) Condition - Error in `check_api_impl()`: - ! `by_position = FALSE` or `by_position = NULL` require column names in `x` to match those in `y`. + Warning in `data_mcard_1()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) --- Code check_subset(data_mcard_2(), data_mcard_1(), x_select = a) - Output - # A tibble: 1 x 1 - a - - 1 3 Condition - Error in `abort_not_subset_of()`: - ! Column (`a`) of table `data_mcard_2()` contains values (see examples above) that are not present in column (`a`) of table `data_mcard_1()`. + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) # output for compound keys Code check_subset(data_mcard_2(), data_mcard_1(), x_select = c(a, b)) - Output - # A tibble: 3 x 2 - a b - - 1 1 4 - 2 2 5 - 3 3 6 - Condition - Error in `abort_not_subset_of()`: - ! Columns (`a`, `b`) of table `data_mcard_2()` contain values (see examples above) that are not present in columns (`a`, `b`) of table `data_mcard_1()`. - -# check_set_equality() checks properly if 2 sets of values are equal? - - Code - check_set_equality(data_mcard_1(), data_mcard_2(), x_select = c(a, c)) - Output - # A tibble: 2 x 2 - a c - - 1 1 5 - 2 2 6 - # A tibble: 2 x 2 - a c - - 1 2 8 - 2 3 9 Condition - Error in `abort_sets_not_equal()`: - ! Columns (`a`, `c`) of table `data_mcard_1()` contain values (see examples above) that are not present in columns (`a`, `c`) of table `data_mcard_2()`. - Columns (`a`, `c`) of table `data_mcard_2()` contain values (see examples above) that are not present in columns (`a`, `c`) of table `data_mcard_1()`. + Warning in `data_mcard_2()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) diff --git a/tests/testthat/_snaps/mysql.md b/tests/testthat/_snaps/mysql.md new file mode 100644 index 000000000..4a99f755a --- /dev/null +++ b/tests/testthat/_snaps/mysql.md @@ -0,0 +1,5 @@ +# dummy + + Code + # dummy + diff --git a/tests/testthat/_snaps/primary-keys.md b/tests/testthat/_snaps/primary-keys.md index 0940925ce..2a0a109a6 100644 --- a/tests/testthat/_snaps/primary-keys.md +++ b/tests/testthat/_snaps/primary-keys.md @@ -1,223 +1,3 @@ -# dm_add_pk() works as intended? - - Code - dm(x = tibble(x = integer())) %>% dm_add_pk(x) - Condition - Error in `dm_add_pk()`: - ! `columns` is absent but must be supplied. - -# dm_rm_pk() supports partial filters - - Code - dm_for_filter() %>% dm_rm_pk(tf_4) %>% get_all_keys() - Output - $pks - # A tibble: 5 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_5 k FALSE - 5 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_pk(tf_3) %>% get_all_keys() - Output - $pks - # A tibble: 5 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_4 h FALSE - 4 tf_5 k FALSE - 5 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_pk(tf_6) %>% get_all_keys() - Output - $pks - # A tibble: 5 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_4 h FALSE - 5 tf_5 k FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_pk(tf_4, rm_referencing_fks = TRUE) %>% get_all_keys() - Condition - Warning: - The `rm_referencing_fks` argument of `dm_rm_pk()` is deprecated as of dm 0.2.1. - i When removing a primary key, potential associated foreign keys will be pointing at an implicit unique key. - Output - $pks - # A tibble: 5 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_3 f, f1 FALSE - 4 tf_5 k FALSE - 5 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_pk(columns = c) %>% get_all_keys() - Message - Removing primary keys: %>% - dm_rm_pk(tf_2) - Output - $pks - # A tibble: 5 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_3 f, f1 FALSE - 3 tf_4 h FALSE - 4 tf_5 k FALSE - 5 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_pk(columns = c(f, f1)) %>% get_all_keys() - Message - Removing primary keys: %>% - dm_rm_pk(tf_3) - Output - $pks - # A tibble: 5 x 3 - table pk_col autoincrement - - 1 tf_1 a TRUE - 2 tf_2 c FALSE - 3 tf_4 h FALSE - 4 tf_5 k FALSE - 5 tf_6 o FALSE - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - Code - dm_for_filter() %>% dm_rm_pk(fail_fk = FALSE) %>% get_all_keys() - Condition - Warning: - The `fail_fk` argument of `dm_rm_pk()` is deprecated as of dm 1.0.4. - i When removing a primary key, potential associated foreign keys will be pointing at an implicit unique key. - Message - Removing primary keys: %>% - dm_rm_pk(tf_1) %>% - dm_rm_pk(tf_2) %>% - dm_rm_pk(tf_3) %>% - dm_rm_pk(tf_4) %>% - dm_rm_pk(tf_5) %>% - dm_rm_pk(tf_6) - Output - $pks - # A tibble: 0 x 3 - # i 3 variables: table , pk_col , autoincrement - - $fks - # A tibble: 5 x 5 - child_table child_fk_cols parent_table parent_key_cols on_delete - - 1 tf_2 d tf_1 a no_action - 2 tf_2 e, e1 tf_3 f, f1 no_action - 3 tf_4 j, j1 tf_3 f, f1 no_action - 4 tf_5 l tf_4 h cascade - 5 tf_5 m tf_6 n no_action - - -# dm_enum_pk_candidates() works properly? - - Code - dm_enum_pk_candidates(dm_test_obj(), dm_table_1) - Output - # A tibble: 2 x 3 - columns candidate why - - 1 a TRUE "" - 2 b TRUE "" - Code - dm_enum_pk_candidates(dm_test_obj(), dm_table_2) - Output - # A tibble: 1 x 3 - columns candidate why - - 1 c FALSE has duplicate values: 5 (2) - Code - dm_enum_pk_candidates(dm_test_obj(), dm_table_5) - Output - # A tibble: 1 x 3 - columns candidate why - - 1 c FALSE has 1 missing values - Code - dm_enum_pk_candidates(dm_test_obj(), dm_table_6) - Output - # A tibble: 1 x 3 - columns candidate why - - 1 c FALSE has 1 missing values, and duplicate values: 3 (2) - # output Code @@ -226,64 +6,9 @@ Error in `abort_not_unique_key()`: ! (`a`) not a unique key of `x`. -# dm_get_all_pks() with table arg - - Code - nyc_comp() %>% dm_get_all_pks("weather") - Output - # A tibble: 1 x 3 - table pk_col autoincrement - - 1 weather origin, time_hour FALSE - Code - nyc_comp() %>% dm_get_all_pks(c(airlines, weather)) - Output - # A tibble: 2 x 3 - table pk_col autoincrement - - 1 airlines carrier FALSE - 2 weather origin, time_hour FALSE - Code - nyc_comp() %>% dm_get_all_pks(starts_with("weat")) - Output - # A tibble: 1 x 3 - table pk_col autoincrement - - 1 weather origin, time_hour FALSE - Code - nyc_comp() %>% dm_get_all_pks(matches("^a.*s$")) - Output - # A tibble: 2 x 3 - table pk_col autoincrement - - 1 airlines carrier FALSE - 2 airports faa FALSE - # dm_get_all_pks() with table arg fails nicely - Can't subset tables that don't exist. - x Table `timetable` doesn't exist. - -# dm_get_all_pks() with compound keys - - Code - nyc_comp() - Output - -- Metadata -------------------------------------------------------------------- - Tables: `airlines`, `airports`, `flights`, `planes`, `weather` - Columns: 53 - Primary keys: 4 - Foreign keys: 4 - Code - nyc_comp() %>% dm_get_all_pks() - Output - # A tibble: 4 x 3 - table pk_col autoincrement - - 1 airlines carrier FALSE - 2 airports faa FALSE - 3 planes tailnum FALSE - 4 weather origin, time_hour FALSE + Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) # autoincrement fails with compound keys diff --git a/tests/testthat/_snaps/tidyselect.md b/tests/testthat/_snaps/tidyselect.md index 2728bc321..0cdf4d659 100644 --- a/tests/testthat/_snaps/tidyselect.md +++ b/tests/testthat/_snaps/tidyselect.md @@ -3,13 +3,23 @@ Code dm_for_filter() %>% dm_select_tbl(tf_7) Condition - Error in `eval_select_indices()`: - ! Can't subset tables that don't exist. - x Table `tf_7` doesn't exist. + Warning in `dm_for_filter()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Code dm_for_filter() %>% dm_rename_tbl(tf_0 = tf_7) Condition - Error in `eval_rename_indices()`: - ! Can't rename tables that don't exist. - x Table `tf_7` doesn't exist. + Warning in `dm_for_filter()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Warning in `my_test_src_cache()`: + restarting interrupted promise evaluation + Error in `value[[3L]]()`: + ! Data source mysql not accessible: Failed to connect: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) diff --git a/tests/testthat/helper-config-db.R b/tests/testthat/helper-config-db.R index b414656b2..6d3b08de6 100644 --- a/tests/testthat/helper-config-db.R +++ b/tests/testthat/helper-config-db.R @@ -45,6 +45,23 @@ test_src_maria <- function(root = FALSE) { dbplyr::src_dbi(con, auto_disconnect = TRUE) } +test_src_mysql <- function(root = FALSE) { + if (Sys.getenv("DM_TEST_DOCKER_HOST") != "") { + con <- DBI::dbConnect( + RMariaDB::MariaDB(), + host = Sys.getenv("DM_TEST_DOCKER_HOST"), + username = if (root) "root" else "compose", + password = "YourStrong!Passw0rd", + dbname = "test", + port = 3307, + mysql = TRUE + ) + } else { + con <- DBI::dbConnect(RMariaDB::MariaDB(), dbname = "test", mysql = TRUE) + } + dbplyr::src_dbi(con, auto_disconnect = TRUE) +} + test_src_mssql <- function(database = TRUE) { if (Sys.getenv("DM_TEST_DOCKER_HOST") != "") { con <- DBI::dbConnect( diff --git a/tests/testthat/helper-sync.R b/tests/testthat/helper-sync.R index ac00e0c73..b8def43e5 100644 --- a/tests/testthat/helper-sync.R +++ b/tests/testthat/helper-sync.R @@ -19,6 +19,7 @@ local({ sources <- c( "duckdb", "maria", + "mysql", "mssql", "postgres", "sqlite", diff --git a/tests/testthat/test-mysql.R b/tests/testthat/test-mysql.R new file mode 100644 index 000000000..92b457d48 --- /dev/null +++ b/tests/testthat/test-mysql.R @@ -0,0 +1,28 @@ +test_that("dummy", { + expect_snapshot({ + "dummy" + }) +}) + +test_that("dm_sql()", { + # Need skip in every test block, unfortunately + skip_if_src_not("mysql") + + # https://github.com/tidyverse/dbplyr/pull/1190 + skip_if(is(my_test_con(), "MySQLConnection") && packageVersion("dbplyr") < "2.4.0") + + expect_snapshot({ + dm_for_filter_df() %>% + dm_sql(my_test_con()) + }) + + expect_snapshot({ + dm(x = data.frame(a = strrep("x", 300))) %>% + dm_sql(my_test_con()) + }) + + expect_snapshot({ + dm(x = data.frame(a = strrep("x", 10000))) %>% + dm_sql(my_test_con()) + }) +})