liamnz commented on issue #2366:
URL: https://github.com/apache/arrow-adbc/issues/2366#issuecomment-2546697758

   Ah I think I see what the problem is now. In my original code, when the 
connection is first established a schema is not assigned but is created later 
with a `CREATE SCHEMA` command. Because the ADBC client is issuing commands 
over multiple sessions, the commands it issues with the default Snowflake 
session context in the connection object will fail because a schema isn't set.
   
   When I change the connection so that a schema is assigned at connection 
time, everything works fine.
   
   ```r
   # install.packages('adbcdrivermanager')
   # install.packages("adbcsnowflake", repos = 
"https://community.r-multiverse.org";)
   
   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"),
     adbc.snowflake.sql.schema = 'REPREX'
   )
   
   con <- adbc_connection_init(db)
   
   x <- data.frame(A = 1, B = 2, C = 3)
   execute_adbc(con, 'drop table if exists x')
   write_adbc(x, con, 'X')
   read_adbc(con, 'select * from x') |> as.data.frame()
   #>   A B C
   #> 1 1 2 3
   ```
   Created on 2024-12-17 with [reprex v2.1.1](https://reprex.tidyverse.org/)
   
   
![image](https://github.com/user-attachments/assets/abaa3a9c-c5e2-4631-b699-66e744f4a350)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to