Skip to content

R: write_adbc() does not seem to work when writing to a Snowflake table #2366

Open
@liamnz

Description

@liamnz

What happened?

I'm using the adbcdrivermanager and adbcsnowflake packages in R and testing out writing a data-frame to a Snowflake table with write_adbc().

write_adbc() returns a NOT_FOUND error from Snowflake.

It looks like the table gets created, but the actual data is not written to the table.

Stack Trace

No response

How can we reproduce the bug?

install.packages('adbcdrivermanager')
#> package 'adbcdrivermanager' successfully unpacked and MD5 sums checked

install.packages("adbcsnowflake", repos = "https://community.r-multiverse.org")
#> package 'adbcsnowflake' successfully unpacked and MD5 sums checked

library(adbcdrivermanager)
library(adbcsnowflake)

db <- adbc_database_init(
  adbcsnowflake(),
  username = Sys.getenv('SNOWFLAKE_USER'),
  adbc.snowflake.sql.account = Sys.getenv('SNOWFLAKE_ACCOUNT'),
  adbc.snowflake.sql.uri.protocol = 'https',
  adbc.snowflake.sql.uri.host = paste0(Sys.getenv('SNOWFLAKE_ACCOUNT'), '.snowflakecomputing.com'),
  adbc.snowflake.sql.uri.port = '443',
  adbc.snowflake.sql.auth_type = 'auth_ext_browser',
  adbc.snowflake.sql.role = Sys.getenv("SNOWFLAKE_ROLE"),
  adbc.snowflake.sql.warehouse = Sys.getenv("SNOWFLAKE_WAREHOUSE"),
  adbc.snowflake.sql.db = Sys.getenv("SNOWFLAKE_DATABASE")
)

con <- adbc_connection_init(db)

execute_adbc(con, 'create or replace schema reprex')
execute_adbc(con, 'use schema reprex')

write_adbc(mtcars, con, 'MTCARS')
#> Error in adbc_statement_execute_query(stmt): NOT_FOUND: 002003 (42S02): SQL compilation error:
#> Object 'MTCARS' does not exist or not authorized.

schema_tables <- as.data.frame(read_adbc(con, 'show tables in schema reprex'))
#> Warning in convert_array_stream(x, to): 1 value(s) may have incurred loss of
#> precision in conversion to double()
schema_tables[, c('name', 'rows')]
#>     name rows
#> 1 MTCARS    0
as.data.frame(read_adbc(con, 'select * from mtcars'))
#>  [1] mpg  cyl  disp hp   drat wt   qsec vs   am   gear carb
#> <0 rows> (or 0-length row.names)

Created on 2024-12-13 with reprex v2.1.1

Environment/Setup

Windows 11
R 4.4.2
adbcdrivermanager 0.15.0
adbcsnowflake 0.15.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions