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

Translation to REGEXP_INSTR errors in snowflake with options(dplyr.strict_sql = TRUE) #1570

Open
edward-burn opened this issue Jan 6, 2025 · 0 comments

Comments

@edward-burn
Copy link
Contributor

When setting options(dplyr.strict_sql = TRUE) on snowflake stringr::str_detect() errors, but it seems that the translation is working when I have this option set to FALSE with REGEXP_INSTR used. This does not seem to be an issue for str_replace which is translated to REGEXP_REPLACE.

library(dbplyr)
library(stringr)
options(dplyr.strict_sql = FALSE) 
translate_sql(str_detect(var, "b"),
              con = simulate_snowflake())
#> <SQL> REGEXP_INSTR(`var`, 'b') != 0
translate_sql(str_replace(var, "b", "c"),
              con = simulate_snowflake())
#> <SQL> REGEXP_REPLACE(`var`, 'b', 'c', 1.0, 1.0)
translate_sql(str_ends(var, "b"),
              con = simulate_snowflake())
#> <SQL> REGEXP_INSTR(`var`, 'b', 1, 1, 1) = (LENGTH(`var`) + 1)

options(dplyr.strict_sql = TRUE) 
translate_sql(str_detect(var, "b"),
              con = simulate_snowflake())
#> Error in `REGEXP_INSTR()`:
#> ! Don't know how to translate `REGEXP_INSTR()`
translate_sql(str_replace(var, "b", "c"),
              con = simulate_snowflake())
#> <SQL> REGEXP_REPLACE(`var`, 'b', 'c', 1.0, 1.0)
translate_sql(str_ends(var, "b"),
              con = simulate_snowflake())
#> Error in `REGEXP_INSTR()`:
#> ! Don't know how to translate `REGEXP_INSTR()`

Created on 2025-01-06 with reprex v2.1.0

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

1 participant