You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue:
The approach used for copy_to with overwrite is: 1. if the table already exists, rename the old table to temp_*; 2. create a new empty table with the table name; 3. write data to new table; 4. if succeed, remove the temp_* table
However, the name for the temp table is not schema qualified. When doing removal, it will only look for tables in the default schema specified in connection.
The text was updated successfully, but these errors were encountered:
willshen99
changed the title
copy_to(overwrite=T) with in_schema() doesn't remove tmp_* table created
copy_to(overwrite=T) with in_schema() doesn't remove temp_* table created
Dec 9, 2024
Thanks for the detailed investigation. I can see how this could be problematic for in_schema() tables. I will find some time to work on it, but it's low priority right now.
I actually can't reproduce this. The temp table is created in the original schema and is removed from the original schema too. Can you provide a reprex in which the temp table is not correctly removed?
I can reproduce the error both on Hive and Postgres catalog connecting to Trino.
conn = DBI::dbConnect(
RPresto::Presto(),
host = "",
port = 8443,
catalog = "hive",
schema = "default", # Note this is the default schema for connection. It's different from the schema to write
user = "trino",
use.trino.headers = TRUE
)
DBI::dbWriteTable(conn, in_schema('reprex', 'iris'), iris, overwrite=T) # first writing to iris table in reprex schema
DBI::dbWriteTable(conn, in_schema('reprex', 'iris'), iris, overwrite=T) # try to overwrite
Above example executed without error. However, it creates an extra temp_ table in the 'reprex' schema.
What happened:
When running copy_to with overwrite=T and use in_schema for table name, an extra temp_* table is created.
How to reproduce:
Run below script twice. You will see a table temp_* in the output schema
Issue:
The approach used for copy_to with overwrite is: 1. if the table already exists, rename the old table to temp_*; 2. create a new empty table with the table name; 3. write data to new table; 4. if succeed, remove the temp_* table
However, the name for the temp table is not schema qualified. When doing removal, it will only look for tables in the default schema specified in connection.
RPresto/R/dbWriteTable.R
Lines 94 to 96 in 3bf0265
RPresto/R/dbWriteTable.R
Lines 166 to 170 in 3bf0265
The text was updated successfully, but these errors were encountered: