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

Snowflake CAST(@a AS DATE) #372

Closed
anthonysena opened this issue Aug 8, 2024 · 0 comments · Fixed by #373
Closed

Snowflake CAST(@a AS DATE) #372

anthonysena opened this issue Aug 8, 2024 · 0 comments · Fixed by #373

Comments

@anthonysena
Copy link
Contributor

anthonysena commented Aug 8, 2024

Similar to #370, Snowflake has an issue with casting to date. Here is a reprex:

connectionDetails <- DatabaseConnector::createConnectionDetails(
  dbms = "snowflake",
  user = Sys.getenv("CDM_SNOWFLAKE_USER"),
  password = URLdecode(Sys.getenv("CDM_SNOWFLAKE_PASSWORD")),
  connectionString = Sys.getenv("CDM_SNOWFLAKE_CONNECTION_STRING")
)
cdmDatabaseSchema <- Sys.getenv("CDM_SNOWFLAKE_CDM53_SCHEMA")
vocabularyDatabaseSchema <- Sys.getenv("CDM_SNOWFLAKE_CDM53_SCHEMA")
cohortDatabaseSchema <- Sys.getenv("CDM_SNOWFLAKE_OHDSI_SCHEMA")
options(sqlRenderTempEmulationSchema = Sys.getenv("CDM_SNOWFLAKE_OHDSI_SCHEMA"))

sql <- "SELECT CAST('20231231' AS DATE);"
translatedSql <- SqlRender::translate(
  sql = sql,
  targetDialect = "snowflake"
)

connection <- DatabaseConnector::connect(connectionDetails)
#> Connecting using Snowflake driver
data <- DatabaseConnector::querySql(
  connection = connection,
  sql = translatedSql
)
print(data)
#>   CAST('20231231' AS DATE)
#> 1               1970-08-23
DatabaseConnector::disconnect(connection)

Created on 2024-08-08 with reprex v2.0.2

@anthonysena anthonysena linked a pull request Aug 8, 2024 that will close this issue
schuemie added a commit that referenced this issue Aug 9, 2024
CAST(@A AS DATE) handling for Snowflake - fixes #372
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

Successfully merging a pull request may close this issue.

1 participant