Working with dbplyr on a Microsoft SQL Server odbc connection, I'm wondering why stringr::str_sub does not get translated to the SUBSTRING() window function but substr does. I've located the bit of code in the dbplyr github repo that does this translation for substr, but before submitting a pull request with a similiar code snippet for str_sub I wanted to ask around and see if anyone knew of any low-level differences between str_sub and substr that would result in this SQL translation being a bad idea, or even some other sort of reasoning (tidyverse philosophy) that would go against this. All input appreciated.
library(tidyverse)
library(stringr)
library(odbc)
library(dbplyr)
#Let's pretend we have a Microsoft SQL Server <OdbcConnection>
#where the data is nycflights13::flights
flights %>%
filter(substr(tailnum, 1L, 2L) != "N1") %>%
collect()
#This works
flights %>%
filter(substring(tailnum, 1L, 2L) != "N1") %>%
collect()
#This also works
flights %>%
filter(str_sub(tailnum, 1L, 2L) != "N1") %>%
collect()
#This doesn't work