dbplyr 2.5.0
Improved tools for qualified table names
-
Specification of table names with schema/catalogs has been overhauled to
make it simpler. This includes the following features and fixes:-
The simplest way to refer to a qualified table is now to wrap it in
I(), e.g.I("schema_name.table_name"). -
Use of
sql()andident_q()insidein_catalog()andin_schema()
is once again supported (#1388). -
It's ok to use
ident_q()once again (#1413) and you should no longer
see unsuppressable warnings about usingin_schema()(#1408). -
The names of the arguments to
Id()no longer matter, only their order
(#1416). Additionally, thanks to changes to the DBI package, you no
longer need to name each argument. -
If you accidentally pass a named vector to any of the database identifer
functions, those names will be automatically stripped (#1404). -
tbl_sql(check_from)is now deprecated.
-
-
dbplyr now exports some tools to work with the internal
table_pathclass
which is useful for certain backends that need to work with this
data structure (#1300).
Improved SQL
-
New translations for clock functions
add_years(),add_days(),
date_build(),get_year(),get_month(),get_day(),
andbase::difftime()on SQL server, Redshift, Snowflake, and Postgres. -
select()will keep computed columns used toarrange()subqueries that are
eliminated by a subsequent select (@ejneer, #1437). -
semi_join()will no longer inline away an aggregate filter (i.e.HAVING
clause) that was followed by aselect()(@ejneer, #1474) -
Improved function translations:
-
Functions qualified with the base namespace are now also translated, e.g.
base::paste0(x, "_1")is now translated (@mgirlich, #1022). -
-1 + xnow generates a translation instead erroring (#1420). -
x$namenever attempts to evaluatename(#1368). -
You can once again use
NULLon the LHS of an infix operator in order
to generate SQL with unusual syntax (#1345). -
Namespaced calls now error if the function doesn't exist, or a translation
is not available (#1426). -
lead()translation coercesnto an integer.
-
-
Databricks: now supports creating non-temporary tables too (#1418).
-
Oracle:
-
db_explain()now works (@thomashulst, #1353). -
as.Date()works when applied to a string (#1389). -
head()is once again translated toFETCH FIRST. This does require Oracle
12c or newer, but it actually works, compared to the approach using
ROWNUMfrom #1292 (#1436). -
Added support for
str_replace()andstr_replace_all()via
REGEXP_REPLACE()(@thomashulst, #1402).
-
-
Snowflake (@nathanhaigh, #1406)
-
Added support for
str_starts()andstr_ends()viaREGEXP_INSTR() -
Refactored
str_detect()to useREGEXP_INSTR()so now supports
regular expressions. -
Refactored
grepl()to useREGEXP_INSTR()so now supports
case-insensitive matching throughgrepl(..., ignore.case = TRUE)
-
-
SQL server:
-
MySQL:
as.integer()gets correct translation (@krlmlr, #1375).
Minor improvements and bug fixes
-
Deprecation status of functions deprecated in previous versions (at least
2 years old) have been advanced. In particular,src_sql()is now defunct,
as is the use ofpartial_eval()with characterdata. -
Database errors now show the generated SQL, which hopefully will make it
faster to track down problems (#1401). -
When dbplyr creates an index on a table in a schema (e.g.
schema.table),
it now only includes the table name in the index name, not the schema name. -
The class of remote sources now includes all S4 class names, not just
the first (#918). -
compute()passes additional arguments all the way to
sql_query_save()-methods (@rsund). -
db_sql_render()correctly passes on...when re-calling with
sql_optionsset (#1394). -
reframe()now gives an informative error that it isn't supported (#1148). -
rows_patch(in_place = FALSE)now works when more than one column should be
patched (@gorcha, #1443). -
sql_translator()now checks for duplicated definitions (@krlmlr, #1374).