Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbExistsTable always return FALSE #277

Closed
willshen99 opened this issue Nov 13, 2024 · 1 comment
Closed

dbExistsTable always return FALSE #277

willshen99 opened this issue Nov 13, 2024 · 1 comment

Comments

@willshen99
Copy link

willshen99 commented Nov 13, 2024

dbExistsTable always return FALSE for name type either character or in_schema.

dbCreateTable(con, 'iris', iris, use.one.query=T)
dbExistsTable(con, 'iris') # FALSE
dbExistsTable(con, in_schema('new_schema', 'iris')) #FALSE

Looked into the codes in dbExistsTable, the issue is that table and schema names are not rendered correctly

table_id <- DBI::dbQuoteIdentifier(conn, name)
table_name <- DBI::dbUnquoteIdentifier(conn, table_id)[[1]]@name
res <- DBI::dbGetQuery(
conn,
paste0("
SELECT COUNT(*) AS n
FROM information_schema.columns
WHERE
table_catalog = '", conn@catalog, "' AND
table_schema = '", ifelse(!"schema" %in% names(table_name), conn@schema, table_name["schema"]), "' AND
table_name = '", table_name["table"], "'
")

The check sql executed is:

"\n        SELECT COUNT(*) AS n\n        FROM information_schema.columns\n        WHERE\n          table_catalog = 'hive' AND\n          table_schema = 'default' AND\n          table_name = 'NA'\n      "

Package Version:

DBI: 1.2.3
dbplyr: 2.4.0
RPresto: 1.4.6.9000
@willshen99
Copy link
Author

willshen99 commented Nov 13, 2024

This is a compatibility issue with DBI >= 1.2.0

DBI::dbUnquoteIdentifier starts to create Id() objects without component names after version 1.2.0, see this PR r-dbi/DBI#422.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants