-
Notifications
You must be signed in to change notification settings - Fork 168
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
str_detect always treats pattern as fixed string #168
Comments
What database are you using here? |
I have this issue too. I am using teradata. |
I have the same problem with MySQL database. Need to collect data to be able to use patterns in str_detect. |
Lines 68 to 70 in 79d2a03
Lines 93 to 96 in 79d2a03
According to #151 (comment), this seems a design decision.
You can directly specify a function particular to the backend, though. For example (this is only for illustration purpose and the SQLs are invalid for SQLite): library(DBI)
library(dplyr, warn.conflicts = FALSE)
library(dbplyr, warn.conflicts = FALSE)
con <- dbConnect(RSQLite::SQLite(), ":memory:")
copy_to(con, iris)
# MySQL has REGEXP
tbl(con, "iris") %>%
filter(FOO %regexp% "pen$") %>%
show_query
#> <SQL>
#> SELECT *
#> FROM `iris`
#> WHERE (`FOO` REGEXP 'pen$')
# Teradata has REGEXP_LIKE
tbl(con, "iris") %>%
filter(regexp_like(FOO, "pen$")) %>%
show_query
#> <SQL>
#> SELECT *
#> FROM `iris`
#> WHERE (REGEXP_LIKE(`FOO`, 'pen$')) Created on 2018-10-12 by the reprex package (v0.2.1) |
@KMace |
@yutannihilation |
@colearendt do you want to take this one on too? |
When
str_detect
is used in a call tofilter
on atbl
, I expectpattern
to be treated as a regular expression. Instead, it seems that it is treated as a fixed pattern:The SQL
INSTR
function performs a case-insensitive search, and does not treat its second argument as a regex.The text was updated successfully, but these errors were encountered: