Closed elysabethpc closed 7 months ago
Hi elysabethpc,
There are currently some known issues with installing extensions on windows. We're working on it! I think https://github.com/duckdb/duckdb/issues/8243 is probably related as well
Is this still an issue?
Is this still an issue?
Yes.
The spatial extension is installable with the latest dev version (r-universe), postgres not yet.
library(duckdb)
#> Loading required package: DBI
ddb_con <- dbConnect(duckdb())
dbExecute(ddb_con, "INSTALL spatial; LOAD spatial;")
#> [1] 0
dbExecute(ddb_con, "INSTALL postgres; LOAD postgres;")
#> Error: rapi_prepare: Failed to execute statement INSTALL postgres; LOAD postgres;
#> Error: HTTP Error: Failed to download extension "postgres_scanner" at URL "http://extensions.duckdb.org/v0.10.0/windows_amd64_rtools/postgres_scanner.duckdb_extension.gz"
#> Extension "postgres_scanner" is an existing extension.
dbDisconnect(ddb_con)
Apparently the extensions have to be built with the msys2/mingw flavor that R uses.
I got postgres_scanner build and run in Windows with rtools 4.3 doing this:
set PATH=C:\rtools43\x86_64-w64-mingw32.static.posix\bin;C:\rtools43\usr\bin;%PATH%
git clone https://github.com/duckdb/postgres_scanner.git
cd postgres_scanner\
git submodule init
git pull --recurse-submodules
cd duckdb
git checkout tags/v0.10.0
cd ..
git checkout 2eb532b17cdef1b
git apply ..\postgres_scanner_0.10.0_rtools_4.3.patch
# this will fail
make
patch -p1 < ..\win32_port.patch
# this should be ok
make
strip build/release/extension/postgres_scanner/postgres_scanner.duckdb_extension
mkdir C:\Users\user\AppData\Roaming\R\data\R\duckdb\extensions\v0.10.0\windows_amd64_rtools
cp build\release\extension\postgres_scanner\postgres_scanner.duckdb_extension C:\Users\user\AppData\Roaming\R\data\R\duckdb\extensions\v0.10.0\windows_amd64_rtools
in postgres
# in WSL postgres server
sudo -u postgres psql
postgres=# create database basedatos owner dev;
\q
psql -U dev -d basedatos
basedatos=> create table tabla(col1 int, col2 text, col3 timestamp with time zone);
basedatos=> insert into tabla values(5,'prueba', '2024-03-17 09:50:50' AT TIME ZONE 'Europe/Madrid');
\q
Test
"c:\Program Files\R\R-4.3.3\bin\Rscript.exe" ..\postgres_scanner_test.R
in R:
library(DBI)
library(duckdb)
library(tidyverse)
con <- dbConnect(duckdb::duckdb(config=list('allow_unsigned_extensions'='true')))
dbExecute(con,"load postgres_scanner;")
dbGetQuery(con,"from duckdb_extensions();") |> tibble() |>
filter(loaded==TRUE)
dbGetQuery(con,"select * from postgres_scan('dbname=basedatos user=dev password=password host=127.0.0.1', 'public', 'tabla');") |> glimpse()
dbExecute(con,"create schema abc;")
dbExecute(con,"CALL postgres_attach('dbname=basedatos user=dev password=password host=127.0.0.1', source_schema='public', sink_schema='abc');")
tbl(con,sql("SELECT * from information_schema.tables"))
tbl(con,"abc.tabla")
dbExecute(con,"install icu;")
dbExecute(con,"install json;")
dbExecute(con,"install fts;")
dbExecute(con,"install httpfs;")
dbExecute(con,"install spatial;")
dbExecute(con,"load icu;")
dbExecute(con,"load json;")
dbExecute(con,"load fts;")
dbExecute(con,"load httpfs;")
dbExecute(con,"load spatial;")
dbGetQuery(con,"from duckdb_extensions();") |> tibble() |>
filter(loaded==TRUE)
# tz lost
tbl(con,"abc.tabla") |> pull(col3)
tbl(con,"abc.tabla") |>
collect() |>
mutate(col3=with_tz(col3,"Europe/Madrid")) |>
pull(col3)
postgres_scanner_0.10.0_rtools_4.3.patch postgres_scanner_test.txt win32_port.patch
Thanks! I filed an issue upstream.
elysabethpc:
by chance do you have an update to the 3/17/24 comment above? i really need to get postgres_scanner working with duckdb in R but am using all the latest versions of duckdb and R, and cannot see how to get the patches to work...if you can guide or have examples of how to update thru the versions it would be much appreciated. Thanks.
Hello,
I cannot install some extension in R 4.3.1 in windows. I use duckdb duckdb_0.8.1-3 DBI_1.1.3 . I also tested v0.9.0 but in that version more extensions failed to install.
In v0.8.1 the extensions icu, json, httpfs and fts work ok, but postgres_scanner and spatial fail to install. It looks like them don't exists in the repository for platform windows_amd64_rtools. I tried to install manually from repository for platform windows_amd64 (without _rtools sufix) but they made R Session to crash in RStudio when I load them.
I test same thing in linux amd64 and arm64 and work ok with all extension in version 0.8.1 and 0.9.0
Thank you