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

   Ah that's interesting that write_adbc() writes Parquet files, I wondered if 
it might be sending Arrow record batches instead.
   
   Inserting records and manually writing parquet files seem to work fine :)
   
   ```r
   # install.packages('adbcdrivermanager')
   # install.packages("adbcsnowflake", repos = 
"https://community.r-multiverse.org";)
   # install.packages('arrow')
   # install.packages('fs')
   
   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')
   
   # Inserting works
   execute_adbc(con, 'create or replace table x (a int, b int, c int)')
   execute_adbc(con, 'insert into x values (1, 2, 3)')
   read_adbc(con, 'select * from x') |> as.data.frame()
   #>   A B C
   #> 1 1 2 3
   
   
   # COPY INTO with Parquet works
   x <- data.frame(A = 1, B = 2, C = 3)
   execute_adbc(con, 'create or replace table x (a int, b int, c int)')
   parquet_file_path <- fs::file_temp(ext = '.parquet')
   parquet_file <- fs::path_file(parquet_file_path)
   arrow::write_parquet(x, parquet_file_path)
   put_command <- paste0("put 'file://", parquet_file_path,  "' @~")
   execute_adbc(con, put_command)
   execute_adbc(con, paste0("
         copy into x
         from @~/", parquet_file, "
         file_format = (type = parquet)
         match_by_column_name = case_sensitive
   "))
   read_adbc(con, 'select * from x') |> as.data.frame()
   #>   A B C
   #> 1 1 2 3
   
   
   # write_adbc() doesn't work
   x <- data.frame(A = 1, B = 2, C = 3)
   execute_adbc(con, 'drop table if exists x')
   write_adbc(x, con, 'X')
   #> Error in adbc_statement_execute_query(stmt): NOT_FOUND: 002003 (42S02): 
SQL compilation error:
   #> Object 'X' does not exist or not authorized.
   
   
   schema_tables <- read_adbc(con, ' show tables in schema reprex') |> 
as.data.frame()
   #> 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    X    0
   read_adbc(con, 'select * from x') |> as.data.frame()
   #> [1] A B C
   #> <0 rows> (or 0-length row.names)
   
   ```
   
   Created on 2024-12-15 with [reprex v2.1.1](https://reprex.tidyverse.org/)


-- 
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