apache / apache/arrow-adbc

R: BOOLEAN column read as R character() when snowflake table has 0 rows

Open
#2,684 2 comments 0 reactions 0 assignees View on GitHub
Type: bug
Dominant language
C#
Stars
627
Forks
217
Avg merge
17h
Merged PRs (30d)
57

Description

### What happened?

When reading from an empty snowflake table (ie with 0 rows), BOOLEAN columns are read in to R data.frame as character() columns.

The write_adbc correctly created the table. On Snowflake, I see the table is made using this sql query.
```
create or replace TABLE EXAMPLE_DB.EXAMPLE_SCHEMA."empty" (
"x" BOOLEAN
);
```

```{r}
library(adbcdrivermanager)

uri <- "secret"
db <- adbc_database_init(adbcsnowflake::adbcsnowflake(), uri = uri)
snowflake_con <- adbc_connection_init(db)

df <- data.frame(x = logical(1))
write_adbc(df, snowflake_con, "non_empty", mode = "create")
df_read <- read_adbc(snowflake_con, 'SELECT * from "non_empty"') |> as.data.frame()
str(df_read)
#'data.frame': 1 obs. of 1 variable:
# $ x: logi FALSE

df <- data.frame(x = logical(0))
write_adbc(df, snowflake_con, "empty", mode = "create")
df_read <- read_adbc(snowflake_con, 'SELECT * from "empty"') |> as.data.frame()
str(df_read)
#'data.frame': 0 obs. of 1 variable:
# $ x: chr

```

sessionInfo():
```
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 11 x64 (build 22631)

Matrix products: default

locale:
[1] LC_COLLATE=English_Australia.utf8 LC_CTYPE=English_Australia.utf8 LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C
[5] LC_TIME=English_Australia.utf8

time zone: Australia/Sydney
tzcode source: internal

attached base packages:
[1] graphics grDevices utils methods base

other attached packages:
[1] adbcdrivermanager_0.17.0

loaded via a namespace (and not attached):
[1] compiler_4.3.2 tools_4.3.2 rstudioapi_0.16.0 adbcsnowflake_0.17.0 stats_4.3.2 nanoarrow_0.6.0 renv_1.0.3
```

### Stack Trace

_No response_

### How can we reproduce the bug?

_No response_

### Environment/Setup

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.