prestodb / RPresto

DBI-based adapter for Presto for the statistical programming language R.
Other
131 stars 42 forks source link

dbExistsTable always return FALSE #277

Open willshen99 opened 1 week ago

willshen99 commented 1 week ago

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 https://github.com/prestodb/RPresto/blob/804c29aff1e2cdfa59c0691b406b6116988eaeff/R/dbExistsTable.R#L17-L28

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 commented 1 week ago

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 https://github.com/r-dbi/DBI/pull/422.