Skip to content

Commit 04b5700

Browse files
committed
move duckdb functions to hfutils
1 parent 2700a25 commit 04b5700

4 files changed

Lines changed: 5 additions & 53 deletions

File tree

‎DESCRIPTION‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Imports:
1818
DBI,
1919
dbplyr,
2020
dplyr,
21-
duckdb,
2221
hfutils,
2322
igraph,
2423
rlang,

‎R/store-lynker-spatial.R‎

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#' @keywords internal
2-
lynker_spatial_store <- function(version, domain, kind, ..., conn = duckdb_connection(extensions = "httpfs")) {
2+
lynker_spatial_store <- function(version, domain, kind, ..., conn = hfutils::duckdb_connection(extensions = "httpfs")) {
33
# TODO(justin): this is a mess
44

55
if (startsWith(version, "v")) {
@@ -42,7 +42,7 @@ store_has_layer.lynker_spatial_store <- function(store, layer, ...) {
4242
p <- paste(store$src, layer, "vpuid=01", "part-0.parquet", sep = "/")
4343

4444
ok <- try({
45-
tbl_http_parquet(p, conn = store$conn)
45+
hfutils::tbl_http(p, conn = store$conn, read_func = "read_parquet")
4646
TRUE
4747
}, silent = TRUE)
4848

@@ -65,33 +65,5 @@ store_get_layer.lynker_spatial_store <- function(store, layer, ...) {
6565
sep = "/"
6666
)
6767

68-
tbl_http_parquet(urls, conn = store$conn)
69-
}
70-
71-
72-
#' Create a new DuckDB connection.
73-
#' @param ... Arguments passed to [DBI::dbConnect()].
74-
#' @param extensions Character vector of extensions to install and load on connect.
75-
#' @returns A DBI connection to a DuckDB instance.
76-
#' @keywords internal
77-
duckdb_connection <- function(..., extensions = character(0)) {
78-
conn <- DBI::dbConnect(duckdb::duckdb(), ...)
79-
80-
if (length(extensions) > 0) {
81-
for (ext in extensions) {
82-
DBI::dbExecute(conn, paste("INSTALL", ext))
83-
DBI::dbExecute(conn, paste("LOAD", ext))
84-
}
85-
}
86-
87-
conn
88-
}
89-
90-
#' @keywords internal
91-
tbl_http_parquet <- function(urls, ..., conn = duckdb_connection(extensions = "httpfs")) {
92-
query <- paste0("SELECT * FROM read_parquet([",
93-
paste0("'", urls, "'", collapse = ","),
94-
"])")
95-
96-
dplyr::tbl(conn, dbplyr::sql(query))
68+
hfutils::tbl_http(urls, conn = store$conn, read_func = "read_parquet")
9769
}

‎man/duckdb_connection.Rd‎

Lines changed: 0 additions & 20 deletions
This file was deleted.

‎man/hfsubset.Rd‎

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)